diff --git a/.github/workflows/integ_test_api.yml b/.github/workflows/integ_test_api.yml
index eee3d88d0a..9add090e68 100644
--- a/.github/workflows/integ_test_api.yml
+++ b/.github/workflows/integ_test_api.yml
@@ -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
@@ -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
diff --git a/.github/workflows/integ_test_api_graphql_auth_directive.yml b/.github/workflows/integ_test_api_graphql_auth_directive.yml
index 7c87361a7d..13ccb413a5 100644
--- a/.github/workflows/integ_test_api_graphql_auth_directive.yml
+++ b/.github/workflows/integ_test_api_graphql_auth_directive.yml
@@ -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
diff --git a/.github/workflows/integ_test_api_graphql_iam.yml b/.github/workflows/integ_test_api_graphql_iam.yml
index 699d31235f..930df47c26 100644
--- a/.github/workflows/integ_test_api_graphql_iam.yml
+++ b/.github/workflows/integ_test_api_graphql_iam.yml
@@ -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
diff --git a/.github/workflows/integ_test_api_rest_user_pool.yml b/.github/workflows/integ_test_api_rest_user_pool.yml
index 2919eb92e1..dc236c38fc 100644
--- a/.github/workflows/integ_test_api_rest_user_pool.yml
+++ b/.github/workflows/integ_test_api_rest_user_pool.yml
@@ -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
diff --git a/.github/workflows/issue_comment.yml b/.github/workflows/issue_comment.yml
index 2670f9d622..2c3fe1a625 100644
--- a/.github/workflows/issue_comment.yml
+++ b/.github/workflows/issue_comment.yml
@@ -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:
@@ -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"
diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml
new file mode 100644
index 0000000000..fc681f5b1a
--- /dev/null
+++ b/.github/workflows/swiftformat.yml
@@ -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
diff --git a/.swiftformat b/.swiftformat
index e42c8b27c6..4633ccd8d3 100644
--- a/.swiftformat
+++ b/.swiftformat
@@ -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
@@ -114,4 +119,4 @@
--enable strongifiedSelf
--disable todos
--enable typeSugar
---enable yodaConditions
+--enable yodaConditions
\ No newline at end of file
diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/AWSCloudWatchLoggingPlugin.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/AWSCloudWatchLoggingPlugin.xcscheme
index ce4dcb87b8..e1559fa543 100644
--- a/.swiftpm/xcode/xcshareddata/xcschemes/AWSCloudWatchLoggingPlugin.xcscheme
+++ b/.swiftpm/xcode/xcshareddata/xcschemes/AWSCloudWatchLoggingPlugin.xcscheme
@@ -62,6 +62,11 @@
BlueprintName = "AWSCloudWatchLoggingPluginTests"
ReferencedContainer = "container:">
+
+
+
+
diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/AWSS3StoragePlugin.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/AWSS3StoragePlugin.xcscheme
index 88c7293ac7..397b5c3bcf 100644
--- a/.swiftpm/xcode/xcshareddata/xcschemes/AWSS3StoragePlugin.xcscheme
+++ b/.swiftpm/xcode/xcshareddata/xcschemes/AWSS3StoragePlugin.xcscheme
@@ -48,6 +48,14 @@
BlueprintName = "AWSS3StoragePluginTests"
ReferencedContainer = "container:">
+
+
+
+
+
+
diff --git a/Amplify/Amplify.swift b/Amplify/Amplify.swift
index 0f2b8dc7da..ecbedc65d0 100644
--- a/Amplify/Amplify.swift
+++ b/Amplify/Amplify.swift
@@ -37,63 +37,63 @@ public class Amplify: @unchecked Sendable {
/// - Tag: Amplify.Analytics
private static let analyticsAtomic = AtomicValue(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(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(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(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(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(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(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(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(initialValue: StorageCategory())
- public static internal(set) var Storage: StorageCategory {
+ public internal(set) static var Storage: StorageCategory {
get { storageAtomic.get() }
set { storageAtomic.set(newValue) }
}
@@ -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()
}
@@ -112,13 +112,15 @@ public class Amplify: @unchecked Sendable {
}
private static let loggingAtomic = AtomicValue(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(plugin: P) throws {
+ public static func add(plugin: some Plugin) throws {
log.debug("Adding plugin: \(plugin))")
switch plugin {
case let plugin as AnalyticsCategoryPlugin:
@@ -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
}
}
diff --git a/Amplify/Categories/API/APICategory.swift b/Amplify/Categories/API/APICategory.swift
index 4725180daa..9478ff26d0 100644
--- a/Amplify/Categories/API/APICategory.swift
+++ b/Amplify/Categories/API/APICategory.swift
@@ -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
@@ -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
}
@@ -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
diff --git a/Amplify/Categories/API/ClientBehavior/APICategory+ReachabilityBehavior.swift b/Amplify/Categories/API/ClientBehavior/APICategory+ReachabilityBehavior.swift
index 1f714f94ef..050a0b7f68 100644
--- a/Amplify/Categories/API/ClientBehavior/APICategory+ReachabilityBehavior.swift
+++ b/Amplify/Categories/API/ClientBehavior/APICategory+ReachabilityBehavior.swift
@@ -6,8 +6,8 @@
//
#if canImport(Combine)
-import Foundation
import Combine
+import Foundation
extension APICategory: APICategoryReachabilityBehavior {
#if !os(watchOS)
diff --git a/Amplify/Categories/API/ClientBehavior/APICategoryBehavior.swift b/Amplify/Categories/API/ClientBehavior/APICategoryBehavior.swift
index 3c2356d564..d17b2f98d3 100644
--- a/Amplify/Categories/API/ClientBehavior/APICategoryBehavior.swift
+++ b/Amplify/Categories/API/ClientBehavior/APICategoryBehavior.swift
@@ -7,8 +7,8 @@
/// Behavior of the API category that clients will use
public typealias APICategoryBehavior =
- APICategoryRESTBehavior &
+ APICategoryAuthProviderFactoryBehavior &
APICategoryGraphQLBehavior &
APICategoryInterceptorBehavior &
- APICategoryReachabilityBehavior &
- APICategoryAuthProviderFactoryBehavior
+ APICategoryRESTBehavior &
+ APICategoryReachabilityBehavior
diff --git a/Amplify/Categories/API/ClientBehavior/APICategoryGraphQLBehavior.swift b/Amplify/Categories/API/ClientBehavior/APICategoryGraphQLBehavior.swift
index d149b5d945..05bda4d470 100644
--- a/Amplify/Categories/API/ClientBehavior/APICategoryGraphQLBehavior.swift
+++ b/Amplify/Categories/API/ClientBehavior/APICategoryGraphQLBehavior.swift
@@ -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(
request: GraphQLRequest
) -> AmplifyAsyncThrowingSequence>
diff --git a/Amplify/Categories/API/ClientBehavior/APICategoryReachabilityBehavior.swift b/Amplify/Categories/API/ClientBehavior/APICategoryReachabilityBehavior.swift
index d14ab48a3b..ad28239d43 100644
--- a/Amplify/Categories/API/ClientBehavior/APICategoryReachabilityBehavior.swift
+++ b/Amplify/Categories/API/ClientBehavior/APICategoryReachabilityBehavior.swift
@@ -6,8 +6,8 @@
//
#if canImport(Combine)
-import Foundation
import Combine
+import Foundation
/// API Reachability Behavior
public protocol APICategoryReachabilityBehavior {
diff --git a/Amplify/Categories/API/Error/APIError.swift b/Amplify/Categories/API/Error/APIError.swift
index 6d473e2f00..b8000562f6 100644
--- a/Amplify/Categories/API/Error/APIError.swift
+++ b/Amplify/Categories/API/Error/APIError.swift
@@ -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
}
diff --git a/Amplify/Categories/API/Operation/AmplifyOperation+APIPublishers.swift b/Amplify/Categories/API/Operation/AmplifyOperation+APIPublishers.swift
index 83a3d25e76..0f2132d04d 100644
--- a/Amplify/Categories/API/Operation/AmplifyOperation+APIPublishers.swift
+++ b/Amplify/Categories/API/Operation/AmplifyOperation+APIPublishers.swift
@@ -6,8 +6,8 @@
//
#if canImport(Combine)
-import Foundation
import Combine
+import Foundation
// MARK: - GraphQLSubscriptionOperation
diff --git a/Amplify/Categories/API/Operation/NondeterminsticOperation.swift b/Amplify/Categories/API/Operation/NondeterminsticOperation.swift
index cd17b65fe5..292cb7d1f3 100644
--- a/Amplify/Categories/API/Operation/NondeterminsticOperation.swift
+++ b/Amplify/Categories/API/Operation/NondeterminsticOperation.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-
import Combine
+
/**
A non-deterministic operation offers multiple paths to accomplish its task.
It attempts the next path if all preceding paths have failed with an error that allows for continuation.
@@ -62,7 +62,7 @@ final class NondeterminsticOperation {
self?.task = Task { [weak self] in
do {
if let self {
- promise(.success(try await self.run()))
+ try await promise(.success(run()))
} else {
promise(.failure(NondeterminsticOperationError.cancelled))
}
diff --git a/Amplify/Categories/API/Operation/RetryableGraphQLOperation.swift b/Amplify/Categories/API/Operation/RetryableGraphQLOperation.swift
index f60edfd970..03b07b6b6f 100644
--- a/Amplify/Categories/API/Operation/RetryableGraphQLOperation.swift
+++ b/Amplify/Categories/API/Operation/RetryableGraphQLOperation.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-import Foundation
import Combine
+import Foundation
// MARK: - RetryableGraphQLOperation
@@ -91,7 +91,7 @@ public final class RetryableGraphQLSubscriptionOperation where Payload:
public func subscribe() -> AnyPublisher {
let subject = PassthroughSubject()
- self.task = Task { await self.trySubscribe(subject) }
+ task = Task { await self.trySubscribe(subject) }
return subject.eraseToAnyPublisher()
}
@@ -99,7 +99,7 @@ public final class RetryableGraphQLSubscriptionOperation where Payload:
var apiError: APIError?
do {
try Task.checkCancellation()
- let sequence = try await self.nondeterminsticOperation.run()
+ let sequence = try await nondeterminsticOperation.run()
defer { sequence.cancel() }
for try await event in sequence {
try Task.checkCancellation()
@@ -122,13 +122,13 @@ public final class RetryableGraphQLSubscriptionOperation where Payload:
}
public func cancel() {
- self.task?.cancel()
- self.nondeterminsticOperation.cancel()
+ task?.cancel()
+ nondeterminsticOperation.cancel()
}
}
-extension AsyncSequence {
- fileprivate var asyncStream: AsyncStream {
+private extension AsyncSequence {
+ var asyncStream: AsyncStream {
AsyncStream { continuation in
Task {
var it = self.makeAsyncIterator()
@@ -145,11 +145,11 @@ extension AsyncSequence {
}
}
-extension RetryableGraphQLSubscriptionOperation {
- public static var log: Logger {
+public extension RetryableGraphQLSubscriptionOperation {
+ static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.api.displayName, forNamespace: String(describing: self))
}
- public var log: Logger {
+ var log: Logger {
Self.log
}
}
diff --git a/Amplify/Categories/API/Request/GraphQLOperationRequest.swift b/Amplify/Categories/API/Request/GraphQLOperationRequest.swift
index 2f5ebf1ed2..994b30c5b6 100644
--- a/Amplify/Categories/API/Request/GraphQLOperationRequest.swift
+++ b/Amplify/Categories/API/Request/GraphQLOperationRequest.swift
@@ -32,14 +32,16 @@ public struct GraphQLOperationRequest: AmplifyOperationRequest {
public let options: Options
/// Initializer for GraphQLOperationRequest
- public init(apiName: String?,
- operationType: GraphQLOperationType,
- document: String,
- variables: [String: Any]? = nil,
- responseType: R.Type,
- decodePath: String? = nil,
- authMode: AuthorizationMode? = nil,
- options: Options) {
+ public init(
+ apiName: String?,
+ operationType: GraphQLOperationType,
+ document: String,
+ variables: [String: Any]? = nil,
+ responseType: R.Type,
+ decodePath: String? = nil,
+ authMode: AuthorizationMode? = nil,
+ options: Options
+ ) {
self.apiName = apiName
self.operationType = operationType
self.document = document
diff --git a/Amplify/Categories/API/Request/GraphQLRequest.swift b/Amplify/Categories/API/Request/GraphQLRequest.swift
index ba0086de66..88915bb0ba 100644
--- a/Amplify/Categories/API/Request/GraphQLRequest.swift
+++ b/Amplify/Categories/API/Request/GraphQLRequest.swift
@@ -35,13 +35,15 @@ public struct GraphQLRequest {
/// Options to adjust the behavior of this request, including plugin-options
public var options: Options?
- public init(apiName: String? = nil,
- document: String,
- variables: [String: Any]? = nil,
- responseType: R.Type,
- decodePath: String? = nil,
- authMode: AuthorizationMode? = nil,
- options: GraphQLRequest.Options? = nil) {
+ public init(
+ apiName: String? = nil,
+ document: String,
+ variables: [String: Any]? = nil,
+ responseType: R.Type,
+ decodePath: String? = nil,
+ authMode: AuthorizationMode? = nil,
+ options: GraphQLRequest.Options? = nil
+ ) {
self.apiName = apiName
self.document = document
self.variables = variables
diff --git a/Amplify/Categories/API/Request/RESTOperationRequest.swift b/Amplify/Categories/API/Request/RESTOperationRequest.swift
index b1e5deaf8e..a9af7576b6 100644
--- a/Amplify/Categories/API/Request/RESTOperationRequest.swift
+++ b/Amplify/Categories/API/Request/RESTOperationRequest.swift
@@ -32,13 +32,15 @@ public struct RESTOperationRequest: AmplifyOperationRequest {
public let options: Options
/// Initializer with all properties
- public init(apiName: String?,
- operationType: RESTOperationType,
- path: String? = nil,
- headers: [String: String]? = nil,
- queryParameters: [String: String]? = nil,
- body: Data? = nil,
- options: Options) {
+ public init(
+ apiName: String?,
+ operationType: RESTOperationType,
+ path: String? = nil,
+ headers: [String: String]? = nil,
+ queryParameters: [String: String]? = nil,
+ body: Data? = nil,
+ options: Options
+ ) {
self.apiName = apiName
self.operationType = operationType
self.path = path
diff --git a/Amplify/Categories/API/Request/RESTRequest.swift b/Amplify/Categories/API/Request/RESTRequest.swift
index 5af207568e..a576983ee3 100644
--- a/Amplify/Categories/API/Request/RESTRequest.swift
+++ b/Amplify/Categories/API/Request/RESTRequest.swift
@@ -27,11 +27,13 @@ public class RESTRequest {
public let body: Data?
/// Initializer with all properties
- public init(apiName: String? = nil,
- path: String? = nil,
- headers: [String: String]? = nil,
- queryParameters: [String: String]? = nil,
- body: Data? = nil) {
+ public init(
+ apiName: String? = nil,
+ path: String? = nil,
+ headers: [String: String]? = nil,
+ queryParameters: [String: String]? = nil,
+ body: Data? = nil
+ ) {
let inputHeaders = headers ?? [:]
self.headers = inputHeaders.merging(
["Cache-Control": "no-store"],
diff --git a/Amplify/Categories/API/Response/GraphQLError.swift b/Amplify/Categories/API/Response/GraphQLError.swift
index a2f2f12e06..21b3cafb16 100644
--- a/Amplify/Categories/API/Response/GraphQLError.swift
+++ b/Amplify/Categories/API/Response/GraphQLError.swift
@@ -21,10 +21,12 @@ public struct GraphQLError: Decodable {
public let extensions: [String: JSONValue]?
/// Initializer with all properties
- public init(message: String,
- locations: [Location]? = nil,
- path: [JSONValue]? = nil,
- extensions: [String: JSONValue]? = nil) {
+ public init(
+ message: String,
+ locations: [Location]? = nil,
+ path: [JSONValue]? = nil,
+ extensions: [String: JSONValue]? = nil
+ ) {
self.message = message
self.locations = locations
self.path = path
@@ -32,10 +34,10 @@ public struct GraphQLError: Decodable {
}
}
-extension GraphQLError {
+public extension GraphQLError {
/// Both `line` and `column` are positive numbers describing the beginning of an associated syntax element
- public struct Location: Decodable, @unchecked Sendable {
+ struct Location: Decodable, @unchecked Sendable {
/// The line describing the associated syntax element
public let line: Int
diff --git a/Amplify/Categories/Analytics/AnalyticsCategory+ClientBehavior.swift b/Amplify/Categories/Analytics/AnalyticsCategory+ClientBehavior.swift
index e73abe1c15..0f184b96ff 100644
--- a/Amplify/Categories/Analytics/AnalyticsCategory+ClientBehavior.swift
+++ b/Amplify/Categories/Analytics/AnalyticsCategory+ClientBehavior.swift
@@ -40,14 +40,14 @@ extension AnalyticsCategory: AnalyticsCategoryBehavior {
}
/// Methods that wrap `AnalyticsCategoryBehavior` to provides additional useful calling patterns
-extension AnalyticsCategory {
+public extension AnalyticsCategory {
/// Registered global properties can be unregistered though this method. In case no keys are provided, *all*
/// registered global properties will be unregistered. Duplicate keys will be ignored. This method can be called
/// from `Amplify.Analytics` and is a wrapper for `unregisterGlobalProperties(_ keys: Set? = nil)`
///
/// - Parameter keys: one or more of property names to unregister
- public func unregisterGlobalProperties(_ keys: String...) {
+ func unregisterGlobalProperties(_ keys: String...) {
plugin.unregisterGlobalProperties(keys.isEmpty ? nil : Set(keys))
}
@@ -56,7 +56,7 @@ extension AnalyticsCategory {
/// from `Amplify.Analytics` and is a wrapper for `unregisterGlobalProperties(_ keys: Set? = nil)`
///
/// - Parameter keys: an array of property names to unregister
- public func unregisterGlobalProperties(_ keys: [String]) {
+ func unregisterGlobalProperties(_ keys: [String]) {
plugin.unregisterGlobalProperties(keys.isEmpty ? nil : Set(keys))
}
}
diff --git a/Amplify/Categories/Analytics/AnalyticsCategory.swift b/Amplify/Categories/Analytics/AnalyticsCategory.swift
index 4697d51685..79a0d53976 100644
--- a/Amplify/Categories/Analytics/AnalyticsCategory.swift
+++ b/Amplify/Categories/Analytics/AnalyticsCategory.swift
@@ -6,7 +6,7 @@
//
/// The Analytics category enables you to collect analytics data for your app.
-final public class AnalyticsCategory: Category {
+public final class AnalyticsCategory: Category {
/// Analytics category type
public let categoryType = CategoryType.analytics
@@ -56,7 +56,8 @@ final public class AnalyticsCategory: Category {
let pluginDescription = String(describing: plugin)
let error = AnalyticsError.configuration(
"Plugin \(pluginDescription) has an empty `key`.",
- "Set the `key` property for \(String(describing: plugin))")
+ "Set the `key` property for \(String(describing: plugin))"
+ )
throw error
}
@@ -81,7 +82,8 @@ final public class AnalyticsCategory: Category {
let keys = plugins.keys.joined(separator: ", ")
let error = AnalyticsError.configuration(
"No plugin has been added for '\(key)'.",
- "Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
+ "Either add a plugin for '\(key)', or use one of the known keys: \(keys)"
+ )
throw error
}
return plugin
diff --git a/Amplify/Categories/Analytics/AnalyticsProfile.swift b/Amplify/Categories/Analytics/AnalyticsProfile.swift
index d4f1d6e3e4..1f480a5e35 100644
--- a/Amplify/Categories/Analytics/AnalyticsProfile.swift
+++ b/Amplify/Categories/Analytics/AnalyticsProfile.swift
@@ -32,11 +32,13 @@ public struct AnalyticsUserProfile {
/// - plan: The plan for the user
/// - location: Location data about the user
/// - properties: Properties of the user profile
- public init(name: String? = nil,
- email: String? = nil,
- plan: String? = nil,
- location: Location? = nil,
- properties: AnalyticsProperties? = nil) {
+ public init(
+ name: String? = nil,
+ email: String? = nil,
+ plan: String? = nil,
+ location: Location? = nil,
+ properties: AnalyticsProperties? = nil
+ ) {
self.name = name
self.email = email
self.plan = plan
@@ -45,10 +47,10 @@ public struct AnalyticsUserProfile {
}
}
-extension AnalyticsUserProfile {
+public extension AnalyticsUserProfile {
/// Location specific data
- public typealias Location = UserProfileLocation
+ typealias Location = UserProfileLocation
}
extension AnalyticsUserProfile: UserProfile {
diff --git a/Amplify/Categories/Analytics/Event/BasicAnalyticsEvent.swift b/Amplify/Categories/Analytics/Event/BasicAnalyticsEvent.swift
index 2e2792a153..ce9762ac15 100644
--- a/Amplify/Categories/Analytics/Event/BasicAnalyticsEvent.swift
+++ b/Amplify/Categories/Analytics/Event/BasicAnalyticsEvent.swift
@@ -20,8 +20,10 @@ public struct BasicAnalyticsEvent: AnalyticsEvent {
/// - Parameters:
/// - name: The name of the event
/// - properties: Properties of the event
- public init(name: String,
- properties: AnalyticsProperties? = nil) {
+ public init(
+ name: String,
+ properties: AnalyticsProperties? = nil
+ ) {
self.name = name
self.properties = properties
}
diff --git a/Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift b/Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift
index b8d5a158c8..232d5c4970 100644
--- a/Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift
+++ b/Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift
@@ -17,9 +17,11 @@ extension AuthCategory: AuthCategoryBehavior {
return try await plugin.signUp(username: username, password: password, options: options)
}
- 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 {
return try await plugin.confirmSignUp(for: username, confirmationCode: confirmationCode, options: options)
}
@@ -30,26 +32,32 @@ extension AuthCategory: AuthCategoryBehavior {
return try await plugin.resendSignUpCode(for: username, options: options)
}
- 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 {
return try await plugin.signIn(username: username, password: password, options: options)
}
#if os(iOS) || os(macOS) || os(visionOS)
public func signInWithWebUI(
presentationAnchor: AuthUIPresentationAnchor? = nil,
- options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult {
+ options: AuthWebUISignInRequest.Options? = nil
+ ) async throws -> AuthSignInResult {
return try await plugin.signInWithWebUI(presentationAnchor: presentationAnchor, options: options)
}
public func signInWithWebUI(
for authProvider: AuthProvider,
presentationAnchor: AuthUIPresentationAnchor? = nil,
- options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult {
- return try await plugin.signInWithWebUI(for: authProvider,
- presentationAnchor: presentationAnchor,
- options: options)
+ options: AuthWebUISignInRequest.Options? = nil
+ ) async throws -> AuthSignInResult {
+ return try await plugin.signInWithWebUI(
+ for: authProvider,
+ presentationAnchor: presentationAnchor,
+ options: options
+ )
}
#endif
@@ -67,7 +75,7 @@ extension AuthCategory: AuthCategoryBehavior {
public func autoSignIn() async throws -> AuthSignInResult {
try await plugin.autoSignIn()
}
-
+
public func deleteUser() async throws {
try await plugin.deleteUser()
}
@@ -84,8 +92,8 @@ extension AuthCategory: AuthCategoryBehavior {
}
public func confirmResetPassword(
- for username: String, with
- newPassword: String,
+ for username: String,
+ with newPassword: String,
confirmationCode: String,
options: AuthConfirmResetPasswordRequest.Options? = nil
) async throws {
diff --git a/Amplify/Categories/Auth/AuthCategory+UserBehavior.swift b/Amplify/Categories/Auth/AuthCategory+UserBehavior.swift
index ab51dcd49a..9277e30cff 100644
--- a/Amplify/Categories/Auth/AuthCategory+UserBehavior.swift
+++ b/Amplify/Categories/Auth/AuthCategory+UserBehavior.swift
@@ -29,8 +29,10 @@ extension AuthCategory: AuthCategoryUserBehavior {
try await plugin.update(userAttribute: userAttribute, options: options)
}
- public func update(userAttributes: [AuthUserAttribute],
- options: AuthUpdateUserAttributesRequest.Options? = nil)
+ public func update(
+ userAttributes: [AuthUserAttribute],
+ options: AuthUpdateUserAttributesRequest.Options? = nil
+ )
async throws -> [AuthUserAttributeKey: AuthUpdateAttributeResult] {
try await plugin.update(userAttributes: userAttributes, options: options)
}
@@ -50,9 +52,11 @@ extension AuthCategory: AuthCategoryUserBehavior {
try await plugin.sendVerificationCode(forUserAttributeKey: userAttributeKey, options: options)
}
- 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 {
try await plugin.confirm(
userAttribute: userAttribute,
confirmationCode: confirmationCode,
diff --git a/Amplify/Categories/Auth/AuthCategory.swift b/Amplify/Categories/Auth/AuthCategory.swift
index 04fb854778..afa4b22c76 100644
--- a/Amplify/Categories/Auth/AuthCategory.swift
+++ b/Amplify/Categories/Auth/AuthCategory.swift
@@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0
//
-final public class AuthCategory: Category {
+public final class AuthCategory: Category {
public let categoryType = CategoryType.auth
@@ -51,8 +51,10 @@ final public class AuthCategory: Category {
let key = plugin.key
guard !key.isEmpty else {
let pluginDescription = String(describing: plugin)
- let error = AuthError.configuration("Plugin \(pluginDescription) has an empty `key`.",
- "Set the `key` property for \(String(describing: plugin))")
+ let error = AuthError.configuration(
+ "Plugin \(pluginDescription) has an empty `key`.",
+ "Set the `key` property for \(String(describing: plugin))"
+ )
throw error
}
@@ -75,8 +77,10 @@ final public class AuthCategory: Category {
public func getPlugin(for key: PluginKey) throws -> AuthCategoryPlugin {
guard let plugin = plugins[key] else {
let keys = plugins.keys.joined(separator: ", ")
- let error = AuthError.configuration("No plugin has been added for '\(key)'.",
- "Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
+ let error = AuthError.configuration(
+ "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
diff --git a/Amplify/Categories/Auth/AuthCategoryBehavior.swift b/Amplify/Categories/Auth/AuthCategoryBehavior.swift
index e33e3d09fb..24a29aab1f 100644
--- a/Amplify/Categories/Auth/AuthCategoryBehavior.swift
+++ b/Amplify/Categories/Auth/AuthCategoryBehavior.swift
@@ -8,6 +8,7 @@
import Foundation
#if os(iOS) || os(macOS) || os(visionOS)
import AuthenticationServices
+
public typealias AuthUIPresentationAnchor = ASPresentationAnchor
#endif
@@ -39,9 +40,11 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - username: Username used that was used to signUp.
/// - confirmationCode: Confirmation code received to the user.
/// - options: Parameters specific to plugin behavior
- func confirmSignUp(for username: String,
- confirmationCode: String,
- options: AuthConfirmSignUpRequest.Options?) async throws -> AuthSignUpResult
+ func confirmSignUp(
+ for username: String,
+ confirmationCode: String,
+ options: AuthConfirmSignUpRequest.Options?
+ ) async throws -> AuthSignUpResult
/// Resends the confirmation code to confirm the signUp process
///
@@ -62,9 +65,11 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - username: Username to signIn the user
/// - password: Password to signIn the user
/// - options: Parameters specific to plugin behavior
- func signIn(username: String?,
- password: String?,
- options: AuthSignInRequest.Options?) async throws -> AuthSignInResult
+ func signIn(
+ username: String?,
+ password: String?,
+ options: AuthSignInRequest.Options?
+ ) async throws -> AuthSignInResult
#if os(iOS) || os(macOS) || os(visionOS)
/// SignIn using pre configured web UI.
@@ -74,8 +79,10 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - Parameters:
/// - presentationAnchor: Anchor on which the UI is presented.
/// - options: Parameters specific to plugin behavior.
- func signInWithWebUI(presentationAnchor: AuthUIPresentationAnchor?,
- options: AuthWebUISignInRequest.Options?) async throws -> AuthSignInResult
+ func signInWithWebUI(
+ presentationAnchor: AuthUIPresentationAnchor?,
+ options: AuthWebUISignInRequest.Options?
+ ) async throws -> AuthSignInResult
/// SignIn using an auth provider on a web UI
///
@@ -87,9 +94,11 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - authProvider: Auth provider used to signIn.
/// - presentationAnchor: Anchor on which the UI is presented.
/// - options: Parameters specific to plugin behavior.
- func signInWithWebUI(for authProvider: AuthProvider,
- presentationAnchor: AuthUIPresentationAnchor?,
- options: AuthWebUISignInRequest.Options?) async throws -> AuthSignInResult
+ func signInWithWebUI(
+ for authProvider: AuthProvider,
+ presentationAnchor: AuthUIPresentationAnchor?,
+ options: AuthWebUISignInRequest.Options?
+ ) async throws -> AuthSignInResult
#endif
/// Confirms a next step in signIn flow.
@@ -102,10 +111,10 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
options: AuthConfirmSignInRequest.Options?
) async throws -> AuthSignInResult
-
+
/// Auto signs in the user for passwordless sign up
func autoSignIn() async throws -> AuthSignInResult
-
+
/// Sign out the currently logged-in user.
///
/// - Parameters:
@@ -126,8 +135,10 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - Parameters:
/// - username: username whose password need to reset
/// - options: Parameters specific to plugin behavior
- func resetPassword(for username: String,
- options: AuthResetPasswordRequest.Options?) async throws -> AuthResetPasswordResult
+ func resetPassword(
+ for username: String,
+ options: AuthResetPasswordRequest.Options?
+ ) async throws -> AuthResetPasswordResult
/// Confirms a reset password flow
///
@@ -144,10 +155,10 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
) async throws
/// Initiates TOTP Setup
- ///
+ ///
/// Invoke this operation to setup TOTP for the user while signed in.
- /// Calling this method will initiate TOTP setup process and
- /// returns a shared secret that can be used to generate QR code.
+ /// Calling this method will initiate TOTP setup process and
+ /// returns a shared secret that can be used to generate QR code.
/// The setup details also contains a URI generator helper that can be used to retireve a TOTP Setup URI.
///
func setUpTOTP() async throws -> TOTPSetupDetails
diff --git a/Amplify/Categories/Auth/Models/AccessGroup.swift b/Amplify/Categories/Auth/Models/AccessGroup.swift
index 5842598910..cb3102a7a8 100644
--- a/Amplify/Categories/Auth/Models/AccessGroup.swift
+++ b/Amplify/Categories/Auth/Models/AccessGroup.swift
@@ -11,13 +11,13 @@ import Foundation
public struct AccessGroup {
/// The name of the access group.
public let name: String?
-
+
/// A flag indicating whether to migrate keychain items.
public let migrateKeychainItems: Bool
/**
Initializes an `AccessGroup` with the specified name and migration option.
-
+
- Parameter name: The name of the access group.
- Parameter migrateKeychainItemsOfUserSession: A flag indicating whether to migrate keychain items. Defaults to `false`.
*/
@@ -27,7 +27,7 @@ public struct AccessGroup {
/**
Creates an `AccessGroup` instance with no specified name.
-
+
- Parameter migrateKeychainItemsOfUserSession: A flag indicating whether to migrate keychain items.
- Returns: An `AccessGroup` instance with the migration option set.
*/
@@ -37,13 +37,13 @@ public struct AccessGroup {
/**
A static property representing an `AccessGroup` with no name and no migration.
-
+
- Returns: An `AccessGroup` instance with no name and the migration option set to `false`.
*/
public static var none: AccessGroup {
return .none(migrateKeychainItemsOfUserSession: false)
}
-
+
private init(name: String? = nil, migrateKeychainItems: Bool) {
self.name = name
self.migrateKeychainItems = migrateKeychainItems
diff --git a/Amplify/Categories/Auth/Models/AuthCodeDeliveryDetails.swift b/Amplify/Categories/Auth/Models/AuthCodeDeliveryDetails.swift
index b595b63eba..f28c142c54 100644
--- a/Amplify/Categories/Auth/Models/AuthCodeDeliveryDetails.swift
+++ b/Amplify/Categories/Auth/Models/AuthCodeDeliveryDetails.swift
@@ -18,8 +18,10 @@ public struct AuthCodeDeliveryDetails {
/// Attribute that is confirmed or verified.
public let attributeKey: AuthUserAttributeKey?
- public init(destination: DeliveryDestination,
- attributeKey: AuthUserAttributeKey? = nil) {
+ public init(
+ destination: DeliveryDestination,
+ attributeKey: AuthUserAttributeKey? = nil
+ ) {
self.destination = destination
self.attributeKey = attributeKey
}
diff --git a/Amplify/Categories/Auth/Models/AuthSignUpStep.swift b/Amplify/Categories/Auth/Models/AuthSignUpStep.swift
index 8c0afeb183..c7fe8ef0c3 100644
--- a/Amplify/Categories/Auth/Models/AuthSignUpStep.swift
+++ b/Amplify/Categories/Auth/Models/AuthSignUpStep.swift
@@ -15,12 +15,13 @@ public enum AuthSignUpStep {
case confirmUser(
AuthCodeDeliveryDetails? = nil,
AdditionalInfo? = nil,
- UserId? = nil)
+ UserId? = nil
+ )
- /// Sign Up successfully completed
+ /// Sign Up successfully completed
/// The customers can use this step to determine if they want to complete sign in
case completeAutoSignIn(Session)
-
+
/// Sign up is complete
case done
}
diff --git a/Amplify/Categories/Auth/Models/TOTPSetupDetails.swift b/Amplify/Categories/Auth/Models/TOTPSetupDetails.swift
index 165912706d..de490b02a9 100644
--- a/Amplify/Categories/Auth/Models/TOTPSetupDetails.swift
+++ b/Amplify/Categories/Auth/Models/TOTPSetupDetails.swift
@@ -26,15 +26,18 @@ public struct TOTPSetupDetails {
/// (for example, if the parameter string contains characters that are illegal in a URL, or is an empty string).
public func getSetupURI(
appName: String,
- accountName: String? = nil) throws -> URL {
+ accountName: String? = nil
+ ) throws -> URL {
guard let URL = URL(
- string: "otpauth://totp/\(appName):\(accountName ?? username)?secret=\(sharedSecret)&issuer=\(appName)") else {
+ string: "otpauth://totp/\(appName):\(accountName ?? username)?secret=\(sharedSecret)&issuer=\(appName)")
+ else {
throw AuthError.validation(
"appName or accountName",
"Invalid Parameters. Cannot form URL from the supplied appName or accountName",
"Please make sure that the supplied parameters don't contain any characters that are illegal in a URL or is an empty String",
- nil)
+ nil
+ )
}
return URL
}
diff --git a/Amplify/Categories/Auth/Request/AuthAttributeResendConfirmationCodeRequest.swift b/Amplify/Categories/Auth/Request/AuthAttributeResendConfirmationCodeRequest.swift
index 2718847043..7e2267f338 100644
--- a/Amplify/Categories/Auth/Request/AuthAttributeResendConfirmationCodeRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthAttributeResendConfirmationCodeRequest.swift
@@ -18,8 +18,10 @@ public struct AuthAttributeResendConfirmationCodeRequest: AmplifyOperationReques
/// Extra request options defined in `AuthAttributeResendConfirmationCodeRequest.Options`
public var options: Options
- public init(attributeKey: AuthUserAttributeKey,
- options: Options) {
+ public init(
+ attributeKey: AuthUserAttributeKey,
+ options: Options
+ ) {
self.attributeKey = attributeKey
self.options = options
}
diff --git a/Amplify/Categories/Auth/Request/AuthAttributeSendVerificationCodeRequest.swift b/Amplify/Categories/Auth/Request/AuthAttributeSendVerificationCodeRequest.swift
index 4af430c68d..d78deb3faf 100644
--- a/Amplify/Categories/Auth/Request/AuthAttributeSendVerificationCodeRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthAttributeSendVerificationCodeRequest.swift
@@ -18,8 +18,10 @@ public struct AuthSendUserAttributeVerificationCodeRequest: AmplifyOperationRequ
/// Extra request options defined in `AuthSendUserAttributeVerificationCodeRequest.Options`
public var options: Options
- public init(attributeKey: AuthUserAttributeKey,
- options: Options) {
+ public init(
+ attributeKey: AuthUserAttributeKey,
+ options: Options
+ ) {
self.attributeKey = attributeKey
self.options = options
}
diff --git a/Amplify/Categories/Auth/Request/AuthChangePasswordRequest.swift b/Amplify/Categories/Auth/Request/AuthChangePasswordRequest.swift
index cc507f85fe..fe73d7d16a 100644
--- a/Amplify/Categories/Auth/Request/AuthChangePasswordRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthChangePasswordRequest.swift
@@ -19,9 +19,11 @@ public struct AuthChangePasswordRequest: AmplifyOperationRequest {
/// Extra request options defined in `AuthChangePasswordRequest.Options`
public var options: Options
- public init(oldPassword: String,
- newPassword: String,
- options: Options) {
+ public init(
+ oldPassword: String,
+ newPassword: String,
+ options: Options
+ ) {
self.oldPassword = oldPassword
self.newPassword = newPassword
self.options = options
diff --git a/Amplify/Categories/Auth/Request/AuthConfirmResetPasswordRequest.swift b/Amplify/Categories/Auth/Request/AuthConfirmResetPasswordRequest.swift
index ad74cd8992..8ad4145976 100644
--- a/Amplify/Categories/Auth/Request/AuthConfirmResetPasswordRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthConfirmResetPasswordRequest.swift
@@ -22,10 +22,12 @@ public struct AuthConfirmResetPasswordRequest: AmplifyOperationRequest {
/// Extra request options defined in `AuthConfirmResetPasswordRequest.Options`
public var options: Options
- public init(username: String,
- newPassword: String,
- confirmationCode: String,
- options: Options) {
+ public init(
+ username: String,
+ newPassword: String,
+ confirmationCode: String,
+ options: Options
+ ) {
self.username = username
self.newPassword = newPassword
self.confirmationCode = confirmationCode
diff --git a/Amplify/Categories/Auth/Request/AuthConfirmUserAttributeRequest.swift b/Amplify/Categories/Auth/Request/AuthConfirmUserAttributeRequest.swift
index de40900ff8..2f533529fc 100644
--- a/Amplify/Categories/Auth/Request/AuthConfirmUserAttributeRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthConfirmUserAttributeRequest.swift
@@ -19,9 +19,11 @@ public struct AuthConfirmUserAttributeRequest: AmplifyOperationRequest {
/// Extra request options defined in `AuthConfirmUserAttributeRequest.Options`
public var options: Options
- public init(attributeKey: AuthUserAttributeKey,
- confirmationCode: String,
- options: Options) {
+ public init(
+ attributeKey: AuthUserAttributeKey,
+ confirmationCode: String,
+ options: Options
+ ) {
self.attributeKey = attributeKey
self.confirmationCode = confirmationCode
self.options = options
diff --git a/Amplify/Categories/Auth/Request/AuthFetchSessionRequest.swift b/Amplify/Categories/Auth/Request/AuthFetchSessionRequest.swift
index 5f02a7c14d..d139e2d2fc 100644
--- a/Amplify/Categories/Auth/Request/AuthFetchSessionRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthFetchSessionRequest.swift
@@ -35,7 +35,8 @@ public extension AuthFetchSessionRequest {
public init(
forceRefresh: Bool = false,
- pluginOptions: Any? = nil) {
+ pluginOptions: Any? = nil
+ ) {
self.forceRefresh = forceRefresh
self.pluginOptions = pluginOptions
}
@@ -44,8 +45,8 @@ public extension AuthFetchSessionRequest {
extension AuthFetchSessionRequest.Options: @unchecked Sendable { }
-extension AuthFetchSessionRequest.Options {
- public static func forceRefresh() -> AuthFetchSessionRequest.Options {
+public extension AuthFetchSessionRequest.Options {
+ static func forceRefresh() -> AuthFetchSessionRequest.Options {
return AuthFetchSessionRequest.Options(forceRefresh: true)
}
}
diff --git a/Amplify/Categories/Auth/Request/AuthForgetDeviceRequest.swift b/Amplify/Categories/Auth/Request/AuthForgetDeviceRequest.swift
index ab1c6f5eb5..1ea524cfac 100644
--- a/Amplify/Categories/Auth/Request/AuthForgetDeviceRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthForgetDeviceRequest.swift
@@ -18,8 +18,10 @@ public struct AuthForgetDeviceRequest: AmplifyOperationRequest {
/// Extra request options defined in `AuthForgetDeviceRequest.Options`
public var options: Options
- public init(device: AuthDevice? = nil,
- options: Options) {
+ public init(
+ device: AuthDevice? = nil,
+ options: Options
+ ) {
self.device = device
self.options = options
}
diff --git a/Amplify/Categories/Auth/Request/AuthResetPasswordRequest.swift b/Amplify/Categories/Auth/Request/AuthResetPasswordRequest.swift
index c21f260a3f..d7b0a431f7 100644
--- a/Amplify/Categories/Auth/Request/AuthResetPasswordRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthResetPasswordRequest.swift
@@ -15,8 +15,10 @@ public struct AuthResetPasswordRequest: AmplifyOperationRequest {
/// Extra request options defined in `AuthResetPasswordRequest.Options`
public var options: Options
- public init(username: String,
- options: Options) {
+ public init(
+ username: String,
+ options: Options
+ ) {
self.username = username
self.options = options
}
diff --git a/Amplify/Categories/Auth/Request/AuthSignOutRequest.swift b/Amplify/Categories/Auth/Request/AuthSignOutRequest.swift
index 59aa316f1d..bcb002b7b0 100644
--- a/Amplify/Categories/Auth/Request/AuthSignOutRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthSignOutRequest.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-import Foundation
import AuthenticationServices
+import Foundation
/// Request for sign out user
public struct AuthSignOutRequest: AmplifyOperationRequest {
@@ -37,9 +37,11 @@ public extension AuthSignOutRequest {
/// in the presentation anchor provided.
public let presentationAnchorForWebUI: AuthUIPresentationAnchor?
- public init(globalSignOut: Bool = false,
- presentationAnchor: AuthUIPresentationAnchor? = nil,
- pluginOptions: Any? = nil) {
+ public init(
+ globalSignOut: Bool = false,
+ presentationAnchor: AuthUIPresentationAnchor? = nil,
+ pluginOptions: Any? = nil
+ ) {
self.globalSignOut = globalSignOut
self.pluginOptions = pluginOptions
self.presentationAnchorForWebUI = presentationAnchor
@@ -57,8 +59,8 @@ public extension AuthSignOutRequest {
extension AuthSignOutRequest.Options: @unchecked Sendable { }
#if os(iOS) || os(macOS) || os(visionOS)
-extension AuthSignOutRequest.Options {
- public static func presentationAnchor(_ anchor: AuthUIPresentationAnchor) -> AuthSignOutRequest.Options {
+public extension AuthSignOutRequest.Options {
+ static func presentationAnchor(_ anchor: AuthUIPresentationAnchor) -> AuthSignOutRequest.Options {
return AuthSignOutRequest.Options(presentationAnchor: anchor)
}
}
diff --git a/Amplify/Categories/Auth/Request/AuthSignUpRequest.swift b/Amplify/Categories/Auth/Request/AuthSignUpRequest.swift
index a145a4abea..b98607ccf0 100644
--- a/Amplify/Categories/Auth/Request/AuthSignUpRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthSignUpRequest.swift
@@ -38,8 +38,10 @@ public extension AuthSignUpRequest {
/// key/values
public let pluginOptions: Any?
- public init(userAttributes: [AuthUserAttribute]? = nil,
- pluginOptions: Any? = nil) {
+ public init(
+ userAttributes: [AuthUserAttribute]? = nil,
+ pluginOptions: Any? = nil
+ ) {
self.userAttributes = userAttributes
self.pluginOptions = pluginOptions
}
diff --git a/Amplify/Categories/Auth/Request/AuthUpdateUserAttributeRequest.swift b/Amplify/Categories/Auth/Request/AuthUpdateUserAttributeRequest.swift
index dce07808af..7e165d471b 100644
--- a/Amplify/Categories/Auth/Request/AuthUpdateUserAttributeRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthUpdateUserAttributeRequest.swift
@@ -16,8 +16,10 @@ public struct AuthUpdateUserAttributeRequest: AmplifyOperationRequest {
/// Extra request options defined in `AuthUpdateUserAttributeRequest.Options`
public var options: Options
- public init(userAttribute: AuthUserAttribute,
- options: Options) {
+ public init(
+ userAttribute: AuthUserAttribute,
+ options: Options
+ ) {
self.userAttribute = userAttribute
self.options = options
}
diff --git a/Amplify/Categories/Auth/Request/AuthUpdateUserAttributesRequest.swift b/Amplify/Categories/Auth/Request/AuthUpdateUserAttributesRequest.swift
index 459e3aeac2..e24c52ada3 100644
--- a/Amplify/Categories/Auth/Request/AuthUpdateUserAttributesRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthUpdateUserAttributesRequest.swift
@@ -16,8 +16,10 @@ public struct AuthUpdateUserAttributesRequest: AmplifyOperationRequest {
/// Extra request options defined in `AuthUpdateUserAttributesRequest.Options`
public var options: Options
- public init(userAttributes: [AuthUserAttribute],
- options: Options) {
+ public init(
+ userAttributes: [AuthUserAttribute],
+ options: Options
+ ) {
self.userAttributes = userAttributes
self.options = options
}
diff --git a/Amplify/Categories/Auth/Request/AuthWebUISignInRequest.swift b/Amplify/Categories/Auth/Request/AuthWebUISignInRequest.swift
index 767ceb8212..1340b8e86e 100644
--- a/Amplify/Categories/Auth/Request/AuthWebUISignInRequest.swift
+++ b/Amplify/Categories/Auth/Request/AuthWebUISignInRequest.swift
@@ -22,9 +22,11 @@ public struct AuthWebUISignInRequest: AmplifyOperationRequest {
/// Presentation anchor on which the webUI is displayed
public let presentationAnchor: AuthUIPresentationAnchor?
- public init(presentationAnchor: AuthUIPresentationAnchor?,
- authProvider: AuthProvider? = nil,
- options: Options) {
+ public init(
+ presentationAnchor: AuthUIPresentationAnchor?,
+ authProvider: AuthProvider? = nil,
+ options: Options
+ ) {
self.presentationAnchor = presentationAnchor
self.authProvider = authProvider
self.options = options
@@ -43,8 +45,10 @@ public extension AuthWebUISignInRequest {
/// key/values
public let pluginOptions: Any?
- public init(scopes: [String]? = nil,
- pluginOptions: Any? = nil) {
+ public init(
+ scopes: [String]? = nil,
+ pluginOptions: Any? = nil
+ ) {
self.scopes = scopes
self.pluginOptions = pluginOptions
}
diff --git a/Amplify/Categories/Auth/Request/VerifyTOTPSetupRequest.swift b/Amplify/Categories/Auth/Request/VerifyTOTPSetupRequest.swift
index b4dcb31f10..84d3ef3e92 100644
--- a/Amplify/Categories/Auth/Request/VerifyTOTPSetupRequest.swift
+++ b/Amplify/Categories/Auth/Request/VerifyTOTPSetupRequest.swift
@@ -18,7 +18,8 @@ public struct VerifyTOTPSetupRequest: AmplifyOperationRequest {
public init(
code: String,
- options: Options) {
+ options: Options
+ ) {
self.code = code
self.options = options
}
diff --git a/Amplify/Categories/DataStore/DataStoreCallback+Combine.swift b/Amplify/Categories/DataStore/DataStoreCallback+Combine.swift
index 58bae6f161..c5b9672604 100644
--- a/Amplify/Categories/DataStore/DataStoreCallback+Combine.swift
+++ b/Amplify/Categories/DataStore/DataStoreCallback+Combine.swift
@@ -7,9 +7,9 @@
import Combine
-extension DataStoreResult where Success: Any {
+public extension DataStoreResult where Success: Any {
- public func resolve(promise: Future.Promise) {
+ func resolve(promise: Future.Promise) {
switch self {
case .success(let result):
promise(.success(result))
diff --git a/Amplify/Categories/DataStore/DataStoreCallback.swift b/Amplify/Categories/DataStore/DataStoreCallback.swift
index be75ee967f..e3afc14dde 100644
--- a/Amplify/Categories/DataStore/DataStoreCallback.swift
+++ b/Amplify/Categories/DataStore/DataStoreCallback.swift
@@ -11,7 +11,7 @@ import Foundation
/// - seealso: [DataStoreCallback](#DataStoreCallback)
public typealias DataStoreResult = Result
-extension DataStoreResult {
+public extension DataStoreResult {
/// Creates a `DataStoreResult` based on a error raised during `DataStore` operations.
/// In case the error is not already a `DataStoreError`, it gets wrapped
@@ -19,12 +19,12 @@ extension DataStoreResult {
///
/// - Parameter error: the root cause of the failure
/// - Returns: a `DataStoreResult.error`
- public static func failure(causedBy error: Error) -> DataStoreResult {
+ static func failure(causedBy error: Error) -> DataStoreResult {
let dataStoreError = error as? DataStoreError ?? .invalidOperation(causedBy: error)
return .failure(dataStoreError)
}
- public static var emptyResult: DataStoreResult {
+ static var emptyResult: DataStoreResult {
.successfulVoid
}
diff --git a/Amplify/Categories/DataStore/DataStoreCategory+Behavior.swift b/Amplify/Categories/DataStore/DataStoreCategory+Behavior.swift
index 4d15a9bff1..489b02e8bf 100644
--- a/Amplify/Categories/DataStore/DataStoreCategory+Behavior.swift
+++ b/Amplify/Categories/DataStore/DataStoreCategory+Behavior.swift
@@ -8,61 +8,81 @@
extension DataStoreCategory: DataStoreBaseBehavior {
@discardableResult
- public func save(_ model: M,
- where condition: QueryPredicate? = nil) async throws -> M {
+ public func save(
+ _ model: M,
+ where condition: QueryPredicate? = nil
+ ) async throws -> M {
try await plugin.save(model, where: condition)
}
- public func query(_ modelType: M.Type,
- byId id: String) async throws -> M? {
+ public func query(
+ _ modelType: M.Type,
+ byId id: String
+ ) async throws -> M? {
try await plugin.query(modelType, byId: id)
}
- public func query(_ modelType: M.Type,
- byIdentifier id: String) async throws -> M?
+ public func query(
+ _ modelType: M.Type,
+ byIdentifier id: String
+ ) async throws -> M?
where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default {
try await plugin.query(modelType, byIdentifier: id)
}
- public func query(_ modelType: M.Type,
- byIdentifier identifier: ModelIdentifier)
+ public func query(
+ _ modelType: M.Type,
+ byIdentifier identifier: ModelIdentifier
+ )
async throws -> M? where M: ModelIdentifiable {
try await plugin.query(modelType, byIdentifier: identifier)
}
- public func query(_ modelType: M.Type,
- where predicate: QueryPredicate? = nil,
- sort sortInput: QuerySortInput? = nil,
- paginate paginationInput: QueryPaginationInput? = nil) async throws -> [M] {
+ public func query(
+ _ modelType: M.Type,
+ where predicate: QueryPredicate? = nil,
+ sort sortInput: QuerySortInput? = nil,
+ paginate paginationInput: QueryPaginationInput? = nil
+ ) async throws -> [M] {
try await plugin.query(modelType, where: predicate, sort: sortInput, paginate: paginationInput)
}
- public func delete(_ model: M,
- where predicate: QueryPredicate? = nil) async throws {
+ public func delete(
+ _ model: some Model,
+ where predicate: QueryPredicate? = nil
+ ) async throws {
try await plugin.delete(model, where: predicate)
}
- public func delete(_ modelType: M.Type,
- withId id: String,
- where predicate: QueryPredicate? = nil) async throws {
+ public func delete(
+ _ modelType: (some Model).Type,
+ withId id: String,
+ where predicate: QueryPredicate? = nil
+ ) async throws {
try await plugin.delete(modelType, withId: id, where: predicate)
}
- public func delete(_ modelType: M.Type,
- withIdentifier id: String,
- where predicate: QueryPredicate? = nil) async throws
+ public func delete(
+ _ modelType: M.Type,
+ withIdentifier id: String,
+ where predicate: QueryPredicate? = nil
+ ) async throws
where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default {
try await plugin.delete(modelType, withIdentifier: id, where: predicate)
}
- public func delete(_ modelType: M.Type,
- withIdentifier id: ModelIdentifier,
- where predicate: QueryPredicate? = nil) async throws where M: ModelIdentifiable {
+ public func delete(
+ _ modelType: M.Type,
+ withIdentifier id: ModelIdentifier,
+ where predicate: QueryPredicate? = nil
+ ) async throws where M: ModelIdentifiable {
try await plugin.delete(modelType, withIdentifier: id, where: predicate)
}
- public func delete(_ modelType: M.Type,
- where predicate: QueryPredicate) async throws {
+ public func delete(
+ _ modelType: (some Model).Type,
+ where predicate: QueryPredicate
+ ) async throws {
try await plugin.delete(modelType, where: predicate)
}
diff --git a/Amplify/Categories/DataStore/DataStoreCategory.swift b/Amplify/Categories/DataStore/DataStoreCategory.swift
index ec2e8a29ab..7e2fc4f85e 100644
--- a/Amplify/Categories/DataStore/DataStoreCategory.swift
+++ b/Amplify/Categories/DataStore/DataStoreCategory.swift
@@ -7,7 +7,7 @@
import Foundation
-final public class DataStoreCategory: Category {
+public final class DataStoreCategory: Category {
/// Always .dataStore
public let categoryType: CategoryType = .dataStore
@@ -54,8 +54,10 @@ final public class DataStoreCategory: Category {
let key = plugin.key
guard !key.isEmpty else {
let pluginDescription = String(describing: plugin)
- let error = DataStoreError.configuration("Plugin \(pluginDescription) has an empty `key`.",
- "Set the `key` property for \(String(describing: plugin))")
+ let error = DataStoreError.configuration(
+ "Plugin \(pluginDescription) has an empty `key`.",
+ "Set the `key` property for \(String(describing: plugin))"
+ )
throw error
}
@@ -78,8 +80,10 @@ final public class DataStoreCategory: Category {
public func getPlugin(for key: PluginKey) throws -> DataStoreCategoryPlugin {
guard let plugin = plugins[key] else {
let keys = plugins.keys.joined(separator: ", ")
- let error = DataStoreError.configuration("No plugin has been added for '\(key)'.",
- "Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
+ let error = DataStoreError.configuration(
+ "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
diff --git a/Amplify/Categories/DataStore/DataStoreCategoryBehavior.swift b/Amplify/Categories/DataStore/DataStoreCategoryBehavior.swift
index 43aa4d3892..11835058e6 100644
--- a/Amplify/Categories/DataStore/DataStoreCategoryBehavior.swift
+++ b/Amplify/Categories/DataStore/DataStoreCategoryBehavior.swift
@@ -13,44 +13,63 @@ public protocol DataStoreBaseBehavior {
/// Saves the model to storage. If sync is enabled, also initiates a sync of the mutation to the remote API
@discardableResult
- func save(_ model: M,
- where condition: QueryPredicate?) async throws -> M
+ func save(
+ _ model: M,
+ where condition: QueryPredicate?
+ ) async throws -> M
@available(*, deprecated, renamed: "query(byIdentifier:)")
- func query(_ modelType: M.Type,
- byId id: String) async throws -> M?
-
- func query(_ modelType: M.Type,
- byIdentifier id: String) async throws -> M?
+ func query(
+ _ modelType: M.Type,
+ byId id: String
+ ) async throws -> M?
+
+ func query(
+ _ modelType: M.Type,
+ byIdentifier id: String
+ ) async throws -> M?
where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default
- func query(_ modelType: M.Type,
- byIdentifier id: ModelIdentifier) async throws -> M?
+ func query(
+ _ modelType: M.Type,
+ byIdentifier id: ModelIdentifier
+ ) async throws -> M?
where M: ModelIdentifiable
- func query(_ modelType: M.Type,
- where predicate: QueryPredicate?,
- sort sortInput: QuerySortInput?,
- paginate paginationInput: QueryPaginationInput?) async throws -> [M]
-
- func delete(_ model: M,
- where predicate: QueryPredicate?) async throws
-
- func delete(_ modelType: M.Type,
- withId id: String,
- where predicate: QueryPredicate?) async throws
-
- func delete(_ modelType: M.Type,
- withIdentifier id: String,
- where predicate: QueryPredicate?) async throws where M: ModelIdentifiable,
- M.IdentifierFormat == ModelIdentifierFormat.Default
-
- func delete(_ modelType: M.Type,
- withIdentifier id: ModelIdentifier,
- where predicate: QueryPredicate?) async throws where M: ModelIdentifiable
-
- func delete(_ modelType: M.Type,
- where predicate: QueryPredicate) async throws
+ func query(
+ _ modelType: M.Type,
+ where predicate: QueryPredicate?,
+ sort sortInput: QuerySortInput?,
+ paginate paginationInput: QueryPaginationInput?
+ ) async throws -> [M]
+
+ func delete(
+ _ model: some Model,
+ where predicate: QueryPredicate?
+ ) async throws
+
+ func delete(
+ _ modelType: (some Model).Type,
+ withId id: String,
+ where predicate: QueryPredicate?
+ ) async throws
+
+ func delete(
+ _ modelType: M.Type,
+ withIdentifier id: String,
+ where predicate: QueryPredicate?
+ ) async throws where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default
+
+ func delete(
+ _ modelType: M.Type,
+ withIdentifier id: ModelIdentifier,
+ where predicate: QueryPredicate?
+ ) async throws where M: ModelIdentifiable
+
+ func delete(
+ _ modelType: (some Model).Type,
+ where predicate: QueryPredicate
+ ) async throws
/**
Synchronization starts automatically whenever you run any DataStore operation (query(), save(), delete())
@@ -81,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(_ modelType: M.Type) -> AmplifyAsyncThrowingSequence
+ func observe(_ modelType: (some Model).Type) -> AmplifyAsyncThrowingSequence
/// Returns a Publisher for query snapshots.
///
@@ -89,8 +108,10 @@ public protocol DataStoreSubscribeBehavior {
/// - modelType: The model type to observe
/// - predicate: The predicate to match for filtered results
/// - sortInput: The field and order of data to be returned
- func observeQuery(for modelType: M.Type,
- where predicate: QueryPredicate?,
- sort sortInput: QuerySortInput?)
+ func observeQuery(
+ for modelType: M.Type,
+ where predicate: QueryPredicate?,
+ sort sortInput: QuerySortInput?
+ )
-> AmplifyAsyncThrowingSequence>
}
diff --git a/Amplify/Categories/DataStore/Model/Internal/Embedded.swift b/Amplify/Categories/DataStore/Model/Internal/Embedded.swift
index 0a588d1d43..3e5adada7d 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Embedded.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Embedded.swift
@@ -23,12 +23,16 @@ public protocol Embeddable: Codable {
static var schema: ModelSchema { get }
}
-extension Embeddable {
- public static func defineSchema(name: String? = nil,
- attributes: ModelAttribute...,
- define: (inout ModelSchemaDefinition) -> Void) -> ModelSchema {
- var definition = ModelSchemaDefinition(name: name ?? "",
- attributes: attributes)
+public extension Embeddable {
+ static func defineSchema(
+ name: String? = nil,
+ attributes: ModelAttribute...,
+ define: (inout ModelSchemaDefinition) -> Void
+ ) -> ModelSchema {
+ var definition = ModelSchemaDefinition(
+ name: name ?? "",
+ attributes: attributes
+ )
define(&definition)
return definition.build()
}
diff --git a/Amplify/Categories/DataStore/Model/Internal/Model+Array.swift b/Amplify/Categories/DataStore/Model/Internal/Model+Array.swift
index 4054f30af8..8a0b17b405 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Model+Array.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Model+Array.swift
@@ -7,13 +7,13 @@
import Foundation
-extension Array where Element: Model {
+public extension Array where Element: Model {
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public func unique() throws -> Element? {
+ func unique() throws -> Element? {
guard (0 ... 1).contains(count) else {
throw DataStoreError.nonUniqueResult(model: Element.modelName, count: count)
}
@@ -21,13 +21,13 @@ extension Array where Element: Model {
}
}
-extension Array where Element == Model {
+public extension [Model] {
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public func unique() throws -> Element? {
+ func unique() throws -> Element? {
guard (0 ... 1).contains(count) else {
let firstModelName = self[0].modelName
throw DataStoreError.nonUniqueResult(model: firstModelName, count: count)
diff --git a/Amplify/Categories/DataStore/Model/Internal/Model+Codable.swift b/Amplify/Categories/DataStore/Model/Internal/Model+Codable.swift
index 2eff95f1e7..58fb41b0e2 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Model+Codable.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Model+Codable.swift
@@ -8,7 +8,7 @@
import Foundation
/// Adds JSON serialization behavior to all types that conform to the `Model` protocol.
-extension Model where Self: Codable {
+public extension Model where Self: Codable {
/// De-serialize a JSON string into an instance of the concrete type that conforms
/// to the `Model` protocol.
@@ -24,13 +24,14 @@ extension Model where Self: Codable {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public static func from(json: String,
- decoder: JSONDecoder? = nil) throws -> Self {
- let resolvedDecoder: JSONDecoder
- if let decoder = decoder {
- resolvedDecoder = decoder
+ static func from(
+ json: String,
+ decoder: JSONDecoder? = nil
+ ) throws -> Self {
+ let resolvedDecoder: JSONDecoder = if let decoder {
+ decoder
} else {
- resolvedDecoder = JSONDecoder(dateDecodingStrategy: ModelDateFormatting.decodingStrategy)
+ JSONDecoder(dateDecodingStrategy: ModelDateFormatting.decodingStrategy)
}
return try resolvedDecoder.decode(Self.self, from: Data(json.utf8))
@@ -47,7 +48,7 @@ extension Model where Self: Codable {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public static func from(dictionary: [String: Any]) throws -> Self {
+ static func from(dictionary: [String: Any]) throws -> Self {
let data = try JSONSerialization.data(withJSONObject: dictionary)
let decoder = JSONDecoder(dateDecodingStrategy: ModelDateFormatting.decodingStrategy)
return try decoder.decode(Self.self, from: data)
@@ -63,7 +64,7 @@ extension Model where Self: Codable {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public func toJSON(encoder: JSONEncoder? = nil) throws -> String {
+ func toJSON(encoder: JSONEncoder? = nil) throws -> String {
var resolvedEncoder = encoder ?? JSONEncoder(
dateEncodingStrategy: ModelDateFormatting.encodingStrategy
)
diff --git a/Amplify/Categories/DataStore/Model/Internal/Model+DateFormatting.swift b/Amplify/Categories/DataStore/Model/Internal/Model+DateFormatting.swift
index 8540f066a9..489f9d108e 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Model+DateFormatting.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Model+DateFormatting.swift
@@ -11,7 +11,7 @@ import Foundation
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
-public struct ModelDateFormatting {
+public enum ModelDateFormatting {
public static let decodingStrategy: JSONDecoder.DateDecodingStrategy = {
let strategy = JSONDecoder.DateDecodingStrategy.custom { decoder -> Date in
diff --git a/Amplify/Categories/DataStore/Model/Internal/Model+Subscript.swift b/Amplify/Categories/DataStore/Model/Internal/Model+Subscript.swift
index 97aed1b40c..4b5eff6930 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Model+Subscript.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Model+Subscript.swift
@@ -10,13 +10,13 @@
/// ```swift
/// let id = model["id"]
/// ```
-extension Model {
+public extension Model {
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public subscript(_ key: String) -> Any?? {
+ subscript(_ key: String) -> Any?? {
if let jsonModel = self as? JSONValueHolder {
let value = jsonModel.jsonValue(for: key)
diff --git a/Amplify/Categories/DataStore/Model/Internal/ModelListDecoder.swift b/Amplify/Categories/DataStore/Model/Internal/ModelListDecoder.swift
index ae4e0b9661..925299aaca 100644
--- a/Amplify/Categories/DataStore/Model/Internal/ModelListDecoder.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/ModelListDecoder.swift
@@ -14,8 +14,8 @@ import Foundation
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a breaking
/// change.
-public struct ModelListDecoderRegistry {
- nonisolated(unsafe) public static var listDecoders = AtomicValue(initialValue: [ModelListDecoder.Type]())
+public enum ModelListDecoderRegistry {
+ public nonisolated(unsafe) static var listDecoders = AtomicValue(initialValue: [ModelListDecoder.Type]())
/// Register a decoder during plugin configuration time, to allow runtime retrievals of list providers.
public static func registerDecoder(_ listDecoder: ModelListDecoder.Type) {
diff --git a/Amplify/Categories/DataStore/Model/Internal/ModelProvider.swift b/Amplify/Categories/DataStore/Model/Internal/ModelProvider.swift
index 98c93dfa00..384dffda7f 100644
--- a/Amplify/Categories/DataStore/Model/Internal/ModelProvider.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/ModelProvider.swift
@@ -6,6 +6,7 @@
//
import Foundation
+
// swiftlint:disable type_name
/// Protocol used as a marker to detect when the type is a `LazyReference`.
/// Used to retrieve either the `reference` or the `identifiers` of the Model directly, without having load a not
diff --git a/Amplify/Categories/DataStore/Model/Internal/ModelProviderDecoder.swift b/Amplify/Categories/DataStore/Model/Internal/ModelProviderDecoder.swift
index 5228e3e8a6..f18e49fe58 100644
--- a/Amplify/Categories/DataStore/Model/Internal/ModelProviderDecoder.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/ModelProviderDecoder.swift
@@ -14,7 +14,7 @@ import Foundation
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a breaking
/// change.
-public struct ModelProviderRegistry {
+public enum ModelProviderRegistry {
nonisolated(unsafe) static var decoders = AtomicValue(initialValue: [ModelProviderDecoder.Type]())
/// Register a decoder during plugin configuration time, to allow runtime retrievals of model providers.
@@ -33,8 +33,8 @@ extension ModelProviderRegistry {
public extension ModelProviderRegistry {
/// Static decoder sources that will be referenced to initialize different type of decoders having source as
- /// a metadata.
- struct DecoderSource {
+ /// a metadata.
+ enum DecoderSource {
public static let dataStore = "DataStore"
public static let appSync = "AppSync"
}
diff --git a/Amplify/Categories/DataStore/Model/Internal/ModelRegistry.swift b/Amplify/Categories/DataStore/Model/Internal/ModelRegistry.swift
index 2f0b53f339..1ad46b4826 100644
--- a/Amplify/Categories/DataStore/Model/Internal/ModelRegistry.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/ModelRegistry.swift
@@ -9,18 +9,20 @@ import Foundation
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
-public struct ModelRegistry {
- private static let concurrencyQueue = DispatchQueue(label: "com.amazonaws.ModelRegistry.concurrency",
- target: DispatchQueue.global())
+public enum ModelRegistry {
+ private static let concurrencyQueue = DispatchQueue(
+ label: "com.amazonaws.ModelRegistry.concurrency",
+ target: DispatchQueue.global()
+ )
/// ModelDecoders are used to decode untyped model data, looking up by model name
private typealias ModelDecoder = (String, JSONDecoder?) throws -> Model
- nonisolated(unsafe) private static var modelTypes = [ModelName: Model.Type]()
+ private nonisolated(unsafe) static var modelTypes = [ModelName: Model.Type]()
- nonisolated(unsafe) private static var modelDecoders = [ModelName: ModelDecoder]()
+ private nonisolated(unsafe) static var modelDecoders = [ModelName: ModelDecoder]()
- nonisolated(unsafe) private static var modelSchemaMapping = [ModelName: ModelSchema]()
+ private nonisolated(unsafe) static var modelSchemaMapping = [ModelName: ModelSchema]()
public static var models: [Model.Type] {
concurrencyQueue.sync {
@@ -35,16 +37,20 @@ public struct ModelRegistry {
}
public static func register(modelType: Model.Type) {
- register(modelType: modelType,
- modelSchema: modelType.schema) { (jsonString, jsonDecoder) -> Model in
+ register(
+ modelType: modelType,
+ modelSchema: modelType.schema
+ ) { jsonString, jsonDecoder -> Model in
let model = try modelType.from(json: jsonString, decoder: jsonDecoder)
return model
}
}
- public static func register(modelType: Model.Type,
- modelSchema: ModelSchema,
- jsonDecoder: @escaping (String, JSONDecoder?) throws -> Model) {
+ public static func register(
+ modelType: Model.Type,
+ modelSchema: ModelSchema,
+ jsonDecoder: @escaping (String, JSONDecoder?) throws -> Model
+ ) {
concurrencyQueue.sync {
let modelDecoder: ModelDecoder = { jsonString, decoder in
return try jsonDecoder(jsonString, decoder)
@@ -75,9 +81,11 @@ public struct ModelRegistry {
}
}
- public static func decode(modelName: ModelName,
- from jsonString: String,
- jsonDecoder: JSONDecoder? = nil) throws -> Model {
+ public static func decode(
+ modelName: ModelName,
+ from jsonString: String,
+ jsonDecoder: JSONDecoder? = nil
+ ) throws -> Model {
try concurrencyQueue.sync {
guard let decoder = modelDecoders[modelName] else {
throw DataStoreError.decodingError(
@@ -85,7 +93,8 @@ public struct ModelRegistry {
"""
There is no decoder registered for the model named \(modelName). \
Register models with `ModelRegistry.register(modelName:)` at startup.
- """)
+ """
+ )
}
return try decoder(jsonString, jsonDecoder)
diff --git a/Amplify/Categories/DataStore/Model/Internal/Persistable.swift b/Amplify/Categories/DataStore/Model/Internal/Persistable.swift
index 92fd149d8d..ac931d6abc 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Persistable.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Persistable.swift
@@ -30,7 +30,7 @@ extension Temporal.Date: Persistable {}
extension Temporal.DateTime: Persistable {}
extension Temporal.Time: Persistable {}
-struct PersistableHelper {
+enum PersistableHelper {
/// Polymorphic utility that allows two persistable references to be checked
/// for equality regardless of their concrete type.
@@ -46,7 +46,7 @@ struct PersistableHelper {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public static func isEqual(_ lhs: Persistable?, _ rhs: Persistable?) -> Bool {
+ static func isEqual(_ lhs: Persistable?, _ rhs: Persistable?) -> Bool {
if lhs == nil && rhs == nil {
return true
}
@@ -77,7 +77,7 @@ struct PersistableHelper {
}
// We are promoting Int to Double in the case where we are comparing these two types
- public static func isEqual(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
+ static func isEqual(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
if lhs == nil && rhs == nil {
return true
}
@@ -112,7 +112,7 @@ struct PersistableHelper {
}
// We are promoting Int to Double in the case where we are comparing these two types
- public static func isLessOrEqual(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
+ static func isLessOrEqual(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
if lhs == nil && rhs == nil {
return true
}
@@ -146,7 +146,7 @@ struct PersistableHelper {
}
// We are promoting Int to Double in the case where we are comparing these two types
- public static func isLessThan(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
+ static func isLessThan(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
if lhs == nil && rhs == nil {
return false
}
@@ -180,7 +180,7 @@ struct PersistableHelper {
}
// We are promoting Int to Double in the case where we are comparing these two types
- public static func isGreaterOrEqual(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
+ static func isGreaterOrEqual(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
if lhs == nil && rhs == nil {
return true
}
@@ -214,7 +214,7 @@ struct PersistableHelper {
}
// We are promoting Int to Double in the case where we are comparing these two types
- public static func isGreaterThan(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
+ static func isGreaterThan(_ lhs: Any?, _ rhs: Persistable?) -> Bool {
if lhs == nil && rhs == nil {
return false
}
@@ -247,7 +247,7 @@ struct PersistableHelper {
}
}
- public static func isBetween(_ start: Persistable, _ end: Persistable, _ value: Any?) -> Bool {
+ static func isBetween(_ start: Persistable, _ end: Persistable, _ value: Any?) -> Bool {
if value == nil {
return false
}
diff --git a/Amplify/Categories/DataStore/Model/Internal/Schema/AuthRule.swift b/Amplify/Categories/DataStore/Model/Internal/Schema/AuthRule.swift
index 8a5c6b4aeb..f50034b4d0 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Schema/AuthRule.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Schema/AuthRule.swift
@@ -50,14 +50,16 @@ public struct AuthRule {
public let operations: [ModelOperation]
public let provider: AuthRuleProvider?
- public init(allow: AuthStrategy,
- ownerField: String? = nil,
- identityClaim: String? = nil,
- groupClaim: String? = nil,
- groups: [String] = [],
- groupsField: String? = nil,
- provider: AuthRuleProvider? = nil,
- operations: [ModelOperation] = []) {
+ public init(
+ allow: AuthStrategy,
+ ownerField: String? = nil,
+ identityClaim: String? = nil,
+ groupClaim: String? = nil,
+ groups: [String] = [],
+ groupsField: String? = nil,
+ provider: AuthRuleProvider? = nil,
+ operations: [ModelOperation] = []
+ ) {
self.allow = allow
self.ownerField = ownerField
self.identityClaim = identityClaim
diff --git a/Amplify/Categories/DataStore/Model/Internal/Schema/Model+Schema.swift b/Amplify/Categories/DataStore/Model/Internal/Schema/Model+Schema.swift
index 7a09d82580..4139e01560 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Schema/Model+Schema.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Schema/Model+Schema.swift
@@ -7,13 +7,13 @@
import Foundation
-extension Model {
+public extension Model {
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public static var schema: ModelSchema {
+ static var schema: ModelSchema {
// TODO load schema from JSON when this it not overridden by specific models
ModelSchema(name: modelName, fields: [:])
}
@@ -22,7 +22,7 @@ extension Model {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var schema: ModelSchema {
+ var schema: ModelSchema {
type(of: self).schema
}
@@ -46,32 +46,40 @@ extension Model {
/// - Returns: a valid `ModelSchema` instance
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning.
- public static func defineSchema(name: String? = nil,
- attributes: ModelAttribute...,
- define: (inout ModelSchemaDefinition) -> Void) -> ModelSchema {
- var definition = ModelSchemaDefinition(name: name ?? modelName,
- attributes: attributes)
+ static func defineSchema(
+ name: String? = nil,
+ attributes: ModelAttribute...,
+ define: (inout ModelSchemaDefinition) -> Void
+ ) -> ModelSchema {
+ var definition = ModelSchemaDefinition(
+ name: name ?? modelName,
+ attributes: attributes
+ )
define(&definition)
return definition.build()
}
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning.
- public static func rule(allow: AuthStrategy,
- ownerField: String? = nil,
- identityClaim: String? = nil,
- groupClaim: String? = nil,
- groups: [String] = [],
- groupsField: String? = nil,
- provider: AuthRuleProvider? = nil,
- operations: [ModelOperation] = []) -> AuthRule {
- return AuthRule(allow: allow,
- ownerField: ownerField,
- identityClaim: identityClaim,
- groupClaim: groupClaim,
- groups: groups,
- groupsField: groupsField,
- provider: provider,
- operations: operations)
+ static func rule(
+ allow: AuthStrategy,
+ ownerField: String? = nil,
+ identityClaim: String? = nil,
+ groupClaim: String? = nil,
+ groups: [String] = [],
+ groupsField: String? = nil,
+ provider: AuthRuleProvider? = nil,
+ operations: [ModelOperation] = []
+ ) -> AuthRule {
+ return AuthRule(
+ allow: allow,
+ ownerField: ownerField,
+ identityClaim: identityClaim,
+ groupClaim: groupClaim,
+ groups: groups,
+ groupsField: groupsField,
+ provider: provider,
+ operations: operations
+ )
}
}
diff --git a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelField+Association.swift b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelField+Association.swift
index 44e64679f8..1b195ed899 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelField+Association.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelField+Association.swift
@@ -104,7 +104,7 @@ public enum ModelAssociation: @unchecked Sendable {
) -> ModelAssociation {
return .hasMany(
associatedFieldName: associatedWith?.stringValue,
- associatedFieldNames: associatedFields.map { $0.stringValue }
+ associatedFieldNames: associatedFields.map(\.stringValue)
)
}
@@ -117,11 +117,13 @@ public enum ModelAssociation: @unchecked Sendable {
public static func hasOne(
associatedWith: CodingKey? = nil,
associatedFields: [CodingKey] = [],
- targetNames: [String] = []) -> ModelAssociation {
+ targetNames: [String] = []
+ ) -> ModelAssociation {
return .hasOne(
associatedFieldName: associatedWith?.stringValue,
- associatedFieldNames: associatedFields.map { $0.stringValue },
- targetNames: targetNames)
+ associatedFieldNames: associatedFields.map(\.stringValue),
+ targetNames: targetNames
+ )
}
@available(*, deprecated, message: "Use belongsTo(associatedWith:targetNames:)")
@@ -136,13 +138,13 @@ public enum ModelAssociation: @unchecked Sendable {
}
-extension ModelField {
+public extension ModelField {
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var hasAssociation: Bool {
+ var hasAssociation: Bool {
return association != nil
}
@@ -156,7 +158,7 @@ extension ModelField {
@available(*, deprecated, message: """
Use of associated model type is deprecated, use `associatedModelName` instead.
""")
- public var associatedModel: Model.Type? {
+ var associatedModel: Model.Type? {
switch type {
case .model(let modelName), .collection(let modelName):
return ModelRegistry.modelType(from: modelName)
@@ -172,7 +174,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var associatedModelName: ModelName? {
+ var associatedModelName: ModelName? {
switch type {
case .model(let modelName), .collection(let modelName):
return modelName
@@ -196,7 +198,7 @@ extension ModelField {
Use of requiredAssociatedModel with Model.Type is deprecated, use `requiredAssociatedModelName`
that return ModelName instead.
""")
- public var requiredAssociatedModel: Model.Type {
+ var requiredAssociatedModel: Model.Type {
guard let modelType = associatedModel else {
return Fatal.preconditionFailure("""
Model fields that are foreign keys must be connected to another Model.
@@ -217,7 +219,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var requiredAssociatedModelName: ModelName {
+ var requiredAssociatedModelName: ModelName {
guard let modelName = associatedModelName else {
return Fatal.preconditionFailure("""
Model fields that are foreign keys must be connected to another Model.
@@ -231,7 +233,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var isAssociationOwner: Bool {
+ var isAssociationOwner: Bool {
guard case .belongsTo = association else {
return false
}
@@ -242,7 +244,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var _isBelongsToOrHasOne: Bool { // swiftlint:disable:this identifier_name
+ var _isBelongsToOrHasOne: Bool { // swiftlint:disable:this identifier_name
switch association {
case .belongsTo, .hasOne:
return true
@@ -255,7 +257,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var associatedField: ModelField? {
+ var associatedField: ModelField? {
if hasAssociation {
let associatedModel = requiredAssociatedModelName
switch association {
@@ -277,10 +279,10 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var associatedFieldNames: [String] {
+ var associatedFieldNames: [String] {
switch association {
case .hasMany(let associatedKey, let associatedKeys):
- if associatedKeys.isEmpty, let associatedKey = associatedKey {
+ if associatedKeys.isEmpty, let associatedKey {
return [associatedKey]
}
return associatedKeys
@@ -300,7 +302,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var isOneToOne: Bool {
+ var isOneToOne: Bool {
if case .hasOne = association {
return true
}
@@ -314,7 +316,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var isOneToMany: Bool {
+ var isOneToMany: Bool {
if case .hasMany = association, case .belongsTo = associatedField?.association {
return true
}
@@ -325,7 +327,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var isManyToOne: Bool {
+ var isManyToOne: Bool {
if case .belongsTo = association, case .hasMany = associatedField?.association {
return true
}
@@ -339,7 +341,7 @@ extension ModelField {
@available(*, deprecated, message: """
Use `embeddedType` is deprecated, use `embeddedTypeSchema` instead.
""")
- public var embeddedType: Embeddable.Type? {
+ var embeddedType: Embeddable.Type? {
switch type {
case .embedded(let type, _), .embeddedCollection(let type, _):
if let embeddedType = type as? Embeddable.Type {
@@ -355,7 +357,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var embeddedTypeSchema: ModelSchema? {
+ var embeddedTypeSchema: ModelSchema? {
switch type {
case .embedded(_, let modelSchema), .embeddedCollection(_, let modelSchema):
return modelSchema
@@ -368,7 +370,7 @@ extension ModelField {
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
/// breaking change.
- public var isEmbeddedType: Bool {
+ var isEmbeddedType: Bool {
switch type {
case .embedded, .embeddedCollection:
return true
diff --git a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelPrimaryKey.swift b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelPrimaryKey.swift
index 38d8ccec63..cb38c40fa6 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelPrimaryKey.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelPrimaryKey.swift
@@ -13,18 +13,22 @@ public struct ModelPrimaryKey {
fields.count > 1
}
- init?(allFields: ModelFields,
- attributes: [ModelAttribute],
- primaryKeyFieldKeys: [String] = []) {
- self.fields = resolvePrimaryKeyFields(allFields: allFields,
- attributes: attributes,
- primaryKeyFieldKeys: primaryKeyFieldKeys)
+ init?(
+ allFields: ModelFields,
+ attributes: [ModelAttribute],
+ primaryKeyFieldKeys: [String] = []
+ ) {
+ self.fields = resolvePrimaryKeyFields(
+ allFields: allFields,
+ attributes: attributes,
+ primaryKeyFieldKeys: primaryKeyFieldKeys
+ )
if fields.isEmpty {
return nil
}
- self.fieldsLookup = Set(fields.map { $0.name })
+ self.fieldsLookup = Set(fields.map(\.name))
}
/// Returns the list of fields that make up the primary key for the model.
@@ -49,9 +53,11 @@ public struct ModelPrimaryKey {
/// It returns an array of fields as custom and composite primary keys are supported.
/// - Parameter fields: schema model fields
/// - Returns: an array of model fields
- func resolvePrimaryKeyFields(allFields: ModelFields,
- attributes: [ModelAttribute],
- primaryKeyFieldKeys: [String]) -> [ModelField] {
+ func resolvePrimaryKeyFields(
+ allFields: ModelFields,
+ attributes: [ModelAttribute],
+ primaryKeyFieldKeys: [String]
+ ) -> [ModelField] {
var primaryKeyFields: [ModelField] = []
if !primaryKeyFieldKeys.isEmpty {
@@ -64,8 +70,8 @@ public struct ModelPrimaryKey {
/// if indexes aren't defined most likely the model has a default `id` as PK
/// so we have to rely on the `.primaryKey` attribute of each individual field
- } else if attributes.indexes.filter({ $0.isPrimaryKeyIndex }).isEmpty {
- primaryKeyFields = allFields.values.filter { $0.isPrimaryKey }
+ } else if attributes.indexes.filter(\.isPrimaryKeyIndex).isEmpty {
+ primaryKeyFields = allFields.values.filter(\.isPrimaryKey)
/// Use the array of fields with a primary key index
} else if let fieldNames = primaryFieldsFromIndexes(attributes: attributes) {
diff --git a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+AuthRulesByOperation.swift b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+AuthRulesByOperation.swift
index d7d02d2b6a..f65b31c77f 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+AuthRulesByOperation.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+AuthRulesByOperation.swift
@@ -7,7 +7,7 @@
import Foundation
-public extension Array where Element == AuthRule {
+public extension [AuthRule] {
/// Returns all the `AuthRule` that apply to a given a `ModelOperation`
/// - Parameter operation: `ModelOperation` operation
diff --git a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+Definition.swift b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+Definition.swift
index 35e6f1210d..febe4cfc87 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+Definition.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema+Definition.swift
@@ -123,7 +123,7 @@ public enum ModelFieldNullability {
/// directly by host applications. The behavior of this may change without warning.
public struct ModelSchemaDefinition {
- internal let name: String
+ let name: String
@available(*, deprecated, message: "Use of pluralName is deprecated, use syncPluralName instead.")
public var pluralName: String?
@@ -132,16 +132,18 @@ public struct ModelSchemaDefinition {
public var syncPluralName: String?
public var authRules: AuthRules
- internal var fields: ModelFields
- internal var primarykeyFields: [ModelFieldName]
- internal var attributes: [ModelAttribute]
-
- init(name: String,
- pluralName: String? = nil,
- listPluralName: String? = nil,
- syncPluralName: String? = nil,
- authRules: AuthRules = [],
- attributes: [ModelAttribute] = []) {
+ var fields: ModelFields
+ var primarykeyFields: [ModelFieldName]
+ var attributes: [ModelAttribute]
+
+ init(
+ name: String,
+ pluralName: String? = nil,
+ listPluralName: String? = nil,
+ syncPluralName: String? = nil,
+ authRules: AuthRules = [],
+ attributes: [ModelAttribute] = []
+ ) {
self.name = name
self.pluralName = pluralName
self.listPluralName = listPluralName
@@ -153,7 +155,7 @@ public struct ModelSchemaDefinition {
}
public mutating func fields(_ fields: ModelFieldDefinition...) {
- fields.forEach { definition in
+ for definition in fields {
let field = definition.modelField
self.fields[field.name] = field
}
@@ -174,43 +176,51 @@ public struct ModelSchemaDefinition {
primarykeyFields = primaryKeyDefinition.first ?? []
}
- internal func build() -> ModelSchema {
- return ModelSchema(name: name,
- pluralName: pluralName,
- listPluralName: listPluralName,
- syncPluralName: syncPluralName,
- authRules: authRules,
- attributes: attributes,
- fields: fields,
- primaryKeyFieldKeys: primarykeyFields)
+ func build() -> ModelSchema {
+ return ModelSchema(
+ name: name,
+ pluralName: pluralName,
+ listPluralName: listPluralName,
+ syncPluralName: syncPluralName,
+ authRules: authRules,
+ attributes: attributes,
+ fields: fields,
+ primaryKeyFieldKeys: primarykeyFields
+ )
}
}
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning.
public enum ModelFieldDefinition {
- case field(name: String,
- type: ModelFieldType,
- nullability: ModelFieldNullability,
- isReadOnly: Bool,
- association: ModelAssociation?,
- attributes: [ModelFieldAttribute],
- authRules: AuthRules)
-
- public static func field(_ key: CodingKey,
- is nullability: ModelFieldNullability = .required,
- isReadOnly: Bool = false,
- ofType type: ModelFieldType = .string,
- attributes: [ModelFieldAttribute] = [],
- association: ModelAssociation? = nil,
- authRules: AuthRules = []) -> ModelFieldDefinition {
- return .field(name: key.stringValue,
- type: type,
- nullability: nullability,
- isReadOnly: isReadOnly,
- association: association,
- attributes: attributes,
- authRules: authRules)
+ case field(
+ name: String,
+ type: ModelFieldType,
+ nullability: ModelFieldNullability,
+ isReadOnly: Bool,
+ association: ModelAssociation?,
+ attributes: [ModelFieldAttribute],
+ authRules: AuthRules
+ )
+
+ public static func field(
+ _ key: CodingKey,
+ is nullability: ModelFieldNullability = .required,
+ isReadOnly: Bool = false,
+ ofType type: ModelFieldType = .string,
+ attributes: [ModelFieldAttribute] = [],
+ association: ModelAssociation? = nil,
+ authRules: AuthRules = []
+ ) -> ModelFieldDefinition {
+ return .field(
+ name: key.stringValue,
+ type: type,
+ nullability: nullability,
+ isReadOnly: isReadOnly,
+ association: association,
+ attributes: attributes,
+ authRules: authRules
+ )
}
@available(*, deprecated, message: "Use .primaryKey(fields:)")
@@ -220,123 +230,160 @@ public enum ModelFieldDefinition {
@available(*, deprecated, message: "Use .primaryKey(fields:)")
public static func id(_ name: String = "id") -> ModelFieldDefinition {
- return .field(name: name,
- type: .string,
- nullability: .required,
- isReadOnly: false,
- association: nil,
- attributes: [.primaryKey],
- authRules: [])
+ return .field(
+ name: name,
+ type: .string,
+ nullability: .required,
+ isReadOnly: false,
+ association: nil,
+ attributes: [.primaryKey],
+ authRules: []
+ )
}
- public static func hasMany(_ key: CodingKey,
- is nullability: ModelFieldNullability = .required,
- isReadOnly: Bool = false,
- ofType type: Model.Type,
- associatedWith associatedKey: CodingKey) -> ModelFieldDefinition {
- return .field(key,
- is: nullability,
- isReadOnly: isReadOnly,
- ofType: .collection(of: type),
- association: .hasMany(associatedWith: associatedKey))
+ public static func hasMany(
+ _ key: CodingKey,
+ is nullability: ModelFieldNullability = .required,
+ isReadOnly: Bool = false,
+ ofType type: Model.Type,
+ associatedWith associatedKey: CodingKey
+ ) -> ModelFieldDefinition {
+ return .field(
+ key,
+ is: nullability,
+ isReadOnly: isReadOnly,
+ ofType: .collection(of: type),
+ association: .hasMany(associatedWith: associatedKey)
+ )
}
- public static func hasMany(_ key: CodingKey,
- is nullability: ModelFieldNullability = .required,
- isReadOnly: Bool = false,
- ofType type: Model.Type,
- associatedFields associatedKeys: [CodingKey]) -> ModelFieldDefinition {
- return .field(key,
- is: nullability,
- isReadOnly: isReadOnly,
- ofType: .collection(of: type),
- association: .hasMany(associatedWith: associatedKeys.first, associatedFields: associatedKeys))
+ public static func hasMany(
+ _ key: CodingKey,
+ is nullability: ModelFieldNullability = .required,
+ isReadOnly: Bool = false,
+ ofType type: Model.Type,
+ associatedFields associatedKeys: [CodingKey]
+ ) -> ModelFieldDefinition {
+ return .field(
+ key,
+ is: nullability,
+ isReadOnly: isReadOnly,
+ ofType: .collection(of: type),
+ association: .hasMany(associatedWith: associatedKeys.first, associatedFields: associatedKeys)
+ )
}
- public static func hasOne(_ key: CodingKey,
- is nullability: ModelFieldNullability = .required,
- isReadOnly: Bool = false,
- ofType type: Model.Type,
- associatedWith associatedKey: CodingKey,
- targetName: String? = nil) -> ModelFieldDefinition {
- return .field(key,
- is: nullability,
- isReadOnly: isReadOnly,
- ofType: .model(type: type),
- association: .hasOne(associatedWith: associatedKey, targetNames: targetName.map { [$0] } ?? []))
+ public static func hasOne(
+ _ key: CodingKey,
+ is nullability: ModelFieldNullability = .required,
+ isReadOnly: Bool = false,
+ ofType type: Model.Type,
+ associatedWith associatedKey: CodingKey,
+ targetName: String? = nil
+ ) -> ModelFieldDefinition {
+ return .field(
+ key,
+ is: nullability,
+ isReadOnly: isReadOnly,
+ ofType: .model(type: type),
+ association: .hasOne(associatedWith: associatedKey, targetNames: targetName.map { [$0] } ?? [])
+ )
}
- public static func hasOne(_ key: CodingKey,
- is nullability: ModelFieldNullability = .required,
- isReadOnly: Bool = false,
- ofType type: Model.Type,
- associatedWith associatedKey: CodingKey,
- targetNames: [String]) -> ModelFieldDefinition {
- return .field(key,
- is: nullability,
- isReadOnly: isReadOnly,
- ofType: .model(type: type),
- association: .hasOne(associatedWith: associatedKey, targetNames: targetNames))
+ public static func hasOne(
+ _ key: CodingKey,
+ is nullability: ModelFieldNullability = .required,
+ isReadOnly: Bool = false,
+ ofType type: Model.Type,
+ associatedWith associatedKey: CodingKey,
+ targetNames: [String]
+ ) -> ModelFieldDefinition {
+ return .field(
+ key,
+ is: nullability,
+ isReadOnly: isReadOnly,
+ ofType: .model(type: type),
+ association: .hasOne(associatedWith: associatedKey, targetNames: targetNames)
+ )
}
- public static func hasOne(_ key: CodingKey,
- is nullability: ModelFieldNullability = .required,
- isReadOnly: Bool = false,
- ofType type: Model.Type,
- associatedFields associatedKeys: [CodingKey],
- targetNames: [String] = []) -> ModelFieldDefinition {
- return .field(key,
- is: nullability,
- isReadOnly: isReadOnly,
- ofType: .model(type: type),
- association: .hasOne(associatedWith: associatedKeys.first,
- associatedFields: associatedKeys,
- targetNames: targetNames))
+ public static func hasOne(
+ _ key: CodingKey,
+ is nullability: ModelFieldNullability = .required,
+ isReadOnly: Bool = false,
+ ofType type: Model.Type,
+ associatedFields associatedKeys: [CodingKey],
+ targetNames: [String] = []
+ ) -> ModelFieldDefinition {
+ return .field(
+ key,
+ is: nullability,
+ isReadOnly: isReadOnly,
+ ofType: .model(type: type),
+ association: .hasOne(
+ associatedWith: associatedKeys.first,
+ associatedFields: associatedKeys,
+ targetNames: targetNames
+ )
+ )
}
- public static func belongsTo(_ key: CodingKey,
- is nullability: ModelFieldNullability = .required,
- isReadOnly: Bool = false,
- ofType type: Model.Type,
- associatedWith associatedKey: CodingKey? = nil,
- targetName: String? = nil) -> ModelFieldDefinition {
- return .field(key,
- is: nullability,
- isReadOnly: isReadOnly,
- ofType: .model(type: type),
- association: .belongsTo(associatedWith: associatedKey, targetNames: targetName.map { [$0] } ?? []))
+ public static func belongsTo(
+ _ key: CodingKey,
+ is nullability: ModelFieldNullability = .required,
+ isReadOnly: Bool = false,
+ ofType type: Model.Type,
+ associatedWith associatedKey: CodingKey? = nil,
+ targetName: String? = nil
+ ) -> ModelFieldDefinition {
+ return .field(
+ key,
+ is: nullability,
+ isReadOnly: isReadOnly,
+ ofType: .model(type: type),
+ association: .belongsTo(associatedWith: associatedKey, targetNames: targetName.map { [$0] } ?? [])
+ )
}
- public static func belongsTo(_ key: CodingKey,
- is nullability: ModelFieldNullability = .required,
- isReadOnly: Bool = false,
- ofType type: Model.Type,
- associatedWith associatedKey: CodingKey? = nil,
- targetNames: [String]) -> ModelFieldDefinition {
- return .field(key,
- is: nullability,
- isReadOnly: isReadOnly,
- ofType: .model(type: type),
- association: .belongsTo(associatedWith: associatedKey, targetNames: targetNames))
+ public static func belongsTo(
+ _ key: CodingKey,
+ is nullability: ModelFieldNullability = .required,
+ isReadOnly: Bool = false,
+ ofType type: Model.Type,
+ associatedWith associatedKey: CodingKey? = nil,
+ targetNames: [String]
+ ) -> ModelFieldDefinition {
+ return .field(
+ key,
+ is: nullability,
+ isReadOnly: isReadOnly,
+ ofType: .model(type: type),
+ association: .belongsTo(associatedWith: associatedKey, targetNames: targetNames)
+ )
}
public var modelField: ModelField {
- guard case let .field(name,
- type,
- nullability,
- isReadOnly,
- association,
- attributes,
- authRules) = self else {
+ guard case let .field(
+ name,
+ type,
+ nullability,
+ isReadOnly,
+ association,
+ attributes,
+ authRules
+ ) = self
+ else {
return Fatal.preconditionFailure("Unexpected enum value found: \(String(describing: self))")
}
- return ModelField(name: name,
- type: type,
- isRequired: nullability.isRequired,
- isReadOnly: isReadOnly,
- isArray: type.isArray,
- attributes: attributes,
- association: association,
- authRules: authRules)
+ return ModelField(
+ name: name,
+ type: type,
+ isRequired: nullability.isRequired,
+ isReadOnly: isReadOnly,
+ isArray: type.isArray,
+ attributes: attributes,
+ association: association,
+ authRules: authRules
+ )
}
}
diff --git a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema.swift b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema.swift
index ac1045e523..f2ae1142fb 100644
--- a/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema.swift
+++ b/Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema.swift
@@ -24,7 +24,7 @@ public enum ModelAttribute: Equatable {
/// Convenience factory method to initialize a `.primaryKey` attribute by
/// using the model coding keys
public static func primaryKey(fields: [CodingKey]) -> ModelAttribute {
- return .primaryKey(fields: fields.map { $0.stringValue })
+ return .primaryKey(fields: fields.map(\.stringValue))
}
}
@@ -53,14 +53,16 @@ public struct ModelField {
return attributes.contains { $0 == .primaryKey }
}
- public init(name: String,
- type: ModelFieldType,
- isRequired: Bool = false,
- isReadOnly: Bool = false,
- isArray: Bool = false,
- attributes: [ModelFieldAttribute] = [],
- association: ModelAssociation? = nil,
- authRules: AuthRules = []) {
+ public init(
+ name: String,
+ type: ModelFieldType,
+ isRequired: Bool = false,
+ isReadOnly: Bool = false,
+ isArray: Bool = false,
+ attributes: [ModelFieldAttribute] = [],
+ association: ModelAssociation? = nil,
+ authRules: AuthRules = []
+ ) {
self.name = name
self.type = type
self.isRequired = isRequired
@@ -106,14 +108,16 @@ public struct ModelSchema {
return primaryKey
}
- public init(name: String,
- pluralName: String? = nil,
- listPluralName: String? = nil,
- syncPluralName: String? = nil,
- authRules: AuthRules = [],
- attributes: [ModelAttribute] = [],
- fields: ModelFields = [:],
- primaryKeyFieldKeys: [ModelFieldName] = []) {
+ public init(
+ name: String,
+ pluralName: String? = nil,
+ listPluralName: String? = nil,
+ syncPluralName: String? = nil,
+ authRules: AuthRules = [],
+ attributes: [ModelAttribute] = [],
+ fields: ModelFields = [:],
+ primaryKeyFieldKeys: [ModelFieldName] = []
+ ) {
self.name = name
self.pluralName = pluralName
self.listPluralName = listPluralName
@@ -122,9 +126,11 @@ public struct ModelSchema {
self.attributes = attributes
self.fields = fields
self.indexes = attributes.indexes
- self._primaryKey = ModelPrimaryKey(allFields: fields,
- attributes: attributes,
- primaryKeyFieldKeys: primaryKeyFieldKeys)
+ self._primaryKey = ModelPrimaryKey(
+ allFields: fields,
+ attributes: attributes,
+ primaryKeyFieldKeys: primaryKeyFieldKeys
+ )
let indexOfPrimaryKeyField = _primaryKey?.indexOfField ?? { (_: String) in nil }
self.sortedFields = fields.sortedFields(indexOfPrimaryKeyField: indexOfPrimaryKeyField)
@@ -150,7 +156,7 @@ extension ModelAttribute {
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
/// directly by host applications. The behavior of this may change without warning.
-extension Array where Element == ModelAttribute {
+extension [ModelAttribute] {
var indexes: [ModelAttribute] {
filter {
switch $0 {
@@ -179,7 +185,7 @@ public extension ModelSchema {
// MARK: - Dictionary + ModelField
-extension Dictionary where Key == String, Value == ModelField {
+extension [String: ModelField] {
/// Returns an array of the values sorted by some pre-defined rules:
///
diff --git a/Amplify/Categories/DataStore/Model/Lazy/ArrayLiteralListProvider.swift b/Amplify/Categories/DataStore/Model/Lazy/ArrayLiteralListProvider.swift
index 7c8e128853..8fc5fbf235 100644
--- a/Amplify/Categories/DataStore/Model/Lazy/ArrayLiteralListProvider.swift
+++ b/Amplify/Categories/DataStore/Model/Lazy/ArrayLiteralListProvider.swift
@@ -35,15 +35,19 @@ public struct ArrayLiteralListProvider: ModelListProvider {
}
public func getNextPage(completion: @escaping (Result, CoreError>) -> Void) {
- completion(.failure(CoreError.clientValidation("No pagination on an array literal",
- "Don't call this method",
- nil)))
+ completion(.failure(CoreError.clientValidation(
+ "No pagination on an array literal",
+ "Don't call this method",
+ nil
+ )))
}
public func getNextPage() async throws -> List {
- throw CoreError.clientValidation("No pagination on an array literal",
- "Don't call this method",
- nil)
+ throw CoreError.clientValidation(
+ "No pagination on an array literal",
+ "Don't call this method",
+ nil
+ )
}
public func encode(to encoder: Encoder) throws {
diff --git a/Amplify/Categories/DataStore/Model/Lazy/LazyReference.swift b/Amplify/Categories/DataStore/Model/Lazy/LazyReference.swift
index 343b059225..33e51c990a 100644
--- a/Amplify/Categories/DataStore/Model/Lazy/LazyReference.swift
+++ b/Amplify/Categories/DataStore/Model/Lazy/LazyReference.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-import Foundation
import Combine
+import Foundation
/// A Codable struct to hold key value pairs representing the identifier's field name and value.
/// Useful for maintaining order for key-value pairs when used as an Array type.
@@ -20,8 +20,8 @@ public struct LazyReferenceIdentifier: Codable {
}
}
-extension Array where Element == LazyReferenceIdentifier {
- public var stringValue: String {
+public extension [LazyReferenceIdentifier] {
+ var stringValue: String {
var fields = [(String, Persistable)]()
for id in self {
fields.append((id.name, id.value))
@@ -88,7 +88,7 @@ public class LazyReference: Codable, _LazyReferenceValue {
// MARK: - Codable implementation
/// Decodable implementation is delegated to the ModelProviders.
- required convenience public init(from decoder: Decoder) throws {
+ public required convenience init(from decoder: Decoder) throws {
for modelDecoder in ModelProviderRegistry.decoders.get() {
if let modelProvider = modelDecoder.decode(modelType: ModelType.self, decoder: decoder) {
self.init(modelProvider: modelProvider)
@@ -129,7 +129,7 @@ public class LazyReference: Codable, _LazyReferenceValue {
switch loadedState {
case .notLoaded:
let element = try await modelProvider.load()
- self.loadedState = .loaded(element)
+ loadedState = .loaded(element)
return element
case .loaded(let element):
return element
@@ -148,10 +148,10 @@ public class LazyReference: Codable, _LazyReferenceValue {
guard let element = try await modelProvider.load() else {
throw CoreError.clientValidation("Data is required but underlying data source successfully loaded no data. ", "")
}
- self.loadedState = .loaded(element)
+ loadedState = .loaded(element)
return element
case .loaded(let element):
- guard let element = element else {
+ guard let element else {
throw CoreError.clientValidation("Data is required but containing LazyReference is loaded with no data.", "")
}
return element
diff --git a/Amplify/Categories/DataStore/Model/Lazy/List+Combine.swift b/Amplify/Categories/DataStore/Model/Lazy/List+Combine.swift
index 271608fa2f..df6701cdff 100644
--- a/Amplify/Categories/DataStore/Model/Lazy/List+Combine.swift
+++ b/Amplify/Categories/DataStore/Model/Lazy/List+Combine.swift
@@ -8,9 +8,9 @@
#if canImport(Combine)
import Combine
-extension List {
+public extension List {
- public typealias LazyListPublisher = AnyPublisher<[Element], DataStoreError>
+ typealias LazyListPublisher = AnyPublisher<[Element], DataStoreError>
}
#endif
diff --git a/Amplify/Categories/DataStore/Model/Lazy/List+LazyLoad.swift b/Amplify/Categories/DataStore/Model/Lazy/List+LazyLoad.swift
index 71b833c976..8e40946bc4 100644
--- a/Amplify/Categories/DataStore/Model/Lazy/List+LazyLoad.swift
+++ b/Amplify/Categories/DataStore/Model/Lazy/List+LazyLoad.swift
@@ -10,7 +10,7 @@ import Foundation
/// This extension adds lazy load logic to the `List`. Lazy loading means
/// the contents of a list that represents an association between two models will only be
/// loaded when it's needed.
-extension List {
+public extension List {
// MARK: - Asynchronous API
@@ -26,12 +26,12 @@ extension List {
///
/// If you have directly created this list object (for example, by calling `List(elements:)`) then the collection
/// has already been initialized and calling this method will have no effect.
- public func fetch() async throws {
+ func fetch() async throws {
guard case .notLoaded = loadedState else {
return
}
do {
- self.elements = try await listProvider.load()
+ elements = try await listProvider.load()
} catch {
throw error
}
diff --git a/Amplify/Categories/DataStore/Model/Lazy/List+Model.swift b/Amplify/Categories/DataStore/Model/Lazy/List+Model.swift
index 283cc53ff7..af9965888f 100644
--- a/Amplify/Categories/DataStore/Model/Lazy/List+Model.swift
+++ b/Amplify/Categories/DataStore/Model/Lazy/List+Model.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-import Foundation
import Combine
+import Foundation
/// `List` is a custom `Collection` that is capable of loading records from a data source. This is especially
/// useful when dealing with Model associations that need to be lazy loaded. Lazy loading is performed when you access
@@ -89,7 +89,7 @@ public class List: Collection, Codable, ExpressibleByArrayLite
// MARK: - ExpressibleByArrayLiteral
- required convenience public init(arrayLiteral elements: Element...) {
+ public required convenience init(arrayLiteral elements: Element...) {
self.init(elements: elements)
}
@@ -150,7 +150,7 @@ public class List: Collection, Codable, ExpressibleByArrayLite
/// implementations of a `ModelListProvider` for `List`. The decoders should be added to the registry by the
/// plugin as part of its configuration steps. By delegating responsibility to the `ModelListDecoder`, it is up to
/// the plugin to successfully return an instance of `ModelListProvider`.
- required convenience public init(from decoder: Decoder) throws {
+ public required convenience init(from decoder: Decoder) throws {
for listDecoder in ModelListDecoderRegistry.listDecoders.get() {
if let listProvider = listDecoder.decode(modelType: ModelType.self, decoder: decoder) {
self.init(listProvider: listProvider)
diff --git a/Amplify/Categories/DataStore/Model/Lazy/List+Pagination.swift b/Amplify/Categories/DataStore/Model/Lazy/List+Pagination.swift
index 28d6fb2d02..da7c312bf1 100644
--- a/Amplify/Categories/DataStore/Model/Lazy/List+Pagination.swift
+++ b/Amplify/Categories/DataStore/Model/Lazy/List+Pagination.swift
@@ -7,12 +7,12 @@
import Foundation
-extension List {
+public extension List {
/// Check if there is subsequent data to retrieve. If true, the next page can be retrieved using
/// `getNextPage(completion:)`. Calling `hasNextPage()` will load the underlying elements from the data source if not yet
/// loaded before.
- public func hasNextPage() -> Bool {
+ func hasNextPage() -> Bool {
switch loadedState {
case .loaded:
return listProvider.hasNextPage()
@@ -26,7 +26,7 @@ extension List {
/// Retrieve the next page as a new in-memory List object. Calling `getNextPage(completion:)` will load the
/// underlying elements of the receiver from the data source if not yet loaded before
- public func getNextPage() async throws -> List {
+ func getNextPage() async throws -> List {
switch loadedState {
case .loaded:
return try await listProvider.getNextPage()
diff --git a/Amplify/Categories/DataStore/Model/Model+ModelName.swift b/Amplify/Categories/DataStore/Model/Model+ModelName.swift
index ac6b893d12..df69c900f1 100644
--- a/Amplify/Categories/DataStore/Model/Model+ModelName.swift
+++ b/Amplify/Categories/DataStore/Model/Model+ModelName.swift
@@ -5,13 +5,13 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Model {
+public extension Model {
- public static var modelName: String {
+ static var modelName: String {
return String(describing: self)
}
- public var modelName: String {
+ var modelName: String {
return type(of: self).modelName
}
}
diff --git a/Amplify/Categories/DataStore/Model/Model.swift b/Amplify/Categories/DataStore/Model/Model.swift
index 85b6c1a822..102997c672 100644
--- a/Amplify/Categories/DataStore/Model/Model.swift
+++ b/Amplify/Categories/DataStore/Model/Model.swift
@@ -38,15 +38,15 @@ public protocol Model: Codable {
var identifier: String { get }
}
-extension Model {
- public var identifier: String {
+public extension Model {
+ var identifier: String {
guard let schema = ModelRegistry.modelSchema(from: modelName) else {
preconditionFailure("Schema not found for \(modelName).")
}
return identifier(schema: schema).stringValue
}
- public func identifier(schema modelSchema: ModelSchema) -> ModelIdentifierProtocol {
+ func identifier(schema modelSchema: ModelSchema) -> ModelIdentifierProtocol {
// resolve current instance identifier fields
let fields: ModelIdentifierProtocol.Fields = modelSchema.primaryKey.fields.map {
guard let fieldValue = self[$0.name] else {
@@ -77,5 +77,5 @@ extension Model {
/// The `rootPath` is set to `nil` by default. Specific models should override this
/// behavior and provide the proper path reference when available.
- public static var rootPath: PropertyContainerPath? { nil }
+ static var rootPath: PropertyContainerPath? { nil }
}
diff --git a/Amplify/Categories/DataStore/Model/ModelIdentifiable.swift b/Amplify/Categories/DataStore/Model/ModelIdentifiable.swift
index 141a7ff03d..9946e0878a 100644
--- a/Amplify/Categories/DataStore/Model/ModelIdentifiable.swift
+++ b/Amplify/Categories/DataStore/Model/ModelIdentifiable.swift
@@ -62,11 +62,11 @@ public extension ModelIdentifierProtocol {
}
var keys: [String] {
- fields.map { $0.name }
+ fields.map(\.name)
}
var values: [Persistable] {
- fields.map { $0.value }
+ fields.map(\.value)
}
var predicate: QueryPredicate {
@@ -97,11 +97,11 @@ public extension ModelIdentifier where F == ModelIdentifierFormat.Custom {
/// Convenience type for a ModelIdentifier with a `ModelIdentifierFormat.Default` format
public typealias DefaultModelIdentifier = ModelIdentifier
-extension DefaultModelIdentifier {
+public extension DefaultModelIdentifier {
/// Factory to instantiate a `DefaultModelIdentifier`.
/// - Parameter id: model id value
/// - Returns: an instance of `ModelIdentifier` for the given model type
- public static func makeDefault(id: String) -> ModelIdentifier {
+ static func makeDefault(id: String) -> ModelIdentifier {
ModelIdentifier(fields: [
(name: ModelIdentifierFormat.Default.name, value: id)
])
@@ -110,7 +110,7 @@ extension DefaultModelIdentifier {
/// Convenience factory to instantiate a `DefaultModelIdentifier` from a given model
/// - Parameter model: model
/// - Returns: an instance of `ModelIdentifier` for the given model type
- public static func makeDefault(fromModel model: M) -> ModelIdentifier {
+ static func makeDefault(fromModel model: M) -> ModelIdentifier {
guard let idValue = model[ModelIdentifierFormat.Default.name] as? String else {
fatalError("Couldn't find default identifier for model \(model)")
}
@@ -121,19 +121,18 @@ extension DefaultModelIdentifier {
// MARK: - Persistable + stringValue
private extension Persistable {
var stringValue: String {
- var value: String
- switch self {
+ var value: String = switch self {
case let self as Temporal.Date:
- value = self.iso8601String
+ self.iso8601String
case let self as Temporal.DateTime:
- value = self.iso8601String
+ self.iso8601String
case let self as Temporal.Time:
- value = self.iso8601String
+ self.iso8601String
default:
- value = "\(self)"
+ "\(self)"
}
return value
}
diff --git a/Amplify/Categories/DataStore/Model/PropertyPath.swift b/Amplify/Categories/DataStore/Model/PropertyPath.swift
index 212430f56d..ad67734a66 100644
--- a/Amplify/Categories/DataStore/Model/PropertyPath.swift
+++ b/Amplify/Categories/DataStore/Model/PropertyPath.swift
@@ -34,7 +34,7 @@ public protocol PropertyPath {
/// - SeeAlso: `ModelPath`
public protocol PropertyContainerPath: PropertyPath {
- ///
+ ///
func getKeyPath() -> String
/// Must return a reference to the type containing the properties
@@ -42,9 +42,9 @@ public protocol PropertyContainerPath: PropertyPath {
}
-extension PropertyContainerPath {
+public extension PropertyContainerPath {
- public func getKeyPath() -> String {
+ func getKeyPath() -> String {
var metadata = getMetadata()
var path = [String]()
while let parent = metadata.parent {
diff --git a/Amplify/Categories/DataStore/Model/Temporal/DataStoreError+Temporal.swift b/Amplify/Categories/DataStore/Model/Temporal/DataStoreError+Temporal.swift
index 4cbec5437c..ef2ba29487 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/DataStoreError+Temporal.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/DataStoreError+Temporal.swift
@@ -7,9 +7,9 @@
import Foundation
-extension DataStoreError {
+public extension DataStoreError {
- public static func invalidDateFormat(_ value: String) -> DataStoreError {
+ static func invalidDateFormat(_ value: String) -> DataStoreError {
return DataStoreError.decodingError(
"""
Could not parse \(value) as a Date using the ISO8601 format.
@@ -17,7 +17,8 @@ extension DataStoreError {
"""
Check if the format used to parse the date is the correct one. Check
`TemporalFormat` for all the options.
- """)
+ """
+ )
}
}
diff --git a/Amplify/Categories/DataStore/Model/Temporal/Date+Operation.swift b/Amplify/Categories/DataStore/Model/Temporal/Date+Operation.swift
index 1230604ec6..175c6c6ac5 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/Date+Operation.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/Date+Operation.swift
@@ -92,7 +92,7 @@ public protocol DateUnitOperable {
static func - (left: Self, right: DateUnit) -> Self
}
-extension TemporalSpec where Self: DateUnitOperable {
+public extension TemporalSpec where Self: DateUnitOperable {
/// Add a `DateUnit` to a `Temporal.Date` or `Temporal.DateTime`
///
@@ -102,7 +102,7 @@ extension TemporalSpec where Self: DateUnitOperable {
/// - left: `Temporal.Date` or `Temporal.DateTime`
/// - right: `DateUnit` to add to `left`
/// - Returns: A new `Temporal.Date` or `Temporal.DateTime` the `DateUnit` was added to.
- public static func + (left: Self, right: DateUnit) -> Self {
+ static func + (left: Self, right: DateUnit) -> Self {
return left.add(value: right.value, to: right.calendarComponent)
}
@@ -114,7 +114,7 @@ extension TemporalSpec where Self: DateUnitOperable {
/// - left: `Temporal.Date` or `Temporal.DateTime`
/// - right: `DateUnit` to subtract from `left`
/// - Returns: A new `Temporal.Date` or `Temporal.DateTime` the `DateUnit` was subtracted from.
- public static func - (left: Self, right: DateUnit) -> Self {
+ static func - (left: Self, right: DateUnit) -> Self {
return left.add(value: -right.value, to: right.calendarComponent)
}
}
diff --git a/Amplify/Categories/DataStore/Model/Temporal/Date.swift b/Amplify/Categories/DataStore/Model/Temporal/Date.swift
index 9b27c313e0..0c955fee9e 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/Date.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/Date.swift
@@ -7,7 +7,7 @@
import Foundation
-extension Temporal {
+public extension Temporal {
/// `Temporal.Date` represents a `Date` with specific allowable formats.
///
@@ -17,7 +17,7 @@ extension Temporal {
/// * `.full` => `yyyy-MM-ddZZZZZ`
///
/// - Note: `.medium`, `.long`, and `.full` are the same date format.
- public struct Date: TemporalSpec {
+ struct Date: TemporalSpec {
// Inherits documentation from `TemporalSpec`
public let foundationDate: Foundation.Date
diff --git a/Amplify/Categories/DataStore/Model/Temporal/DateTime.swift b/Amplify/Categories/DataStore/Model/Temporal/DateTime.swift
index 95c65e5f6e..b694f094b3 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/DateTime.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/DateTime.swift
@@ -7,14 +7,14 @@
import Foundation
-extension Temporal {
+public extension Temporal {
/// `Temporal.DateTime` represents a `DateTime` with specific allowable formats.
///
/// * `.short` => `yyyy-MM-dd'T'HH:mm`
/// * `.medium` => `yyyy-MM-dd'T'HH:mm:ss`
/// * `.long` => `yyyy-MM-dd'T'HH:mm:ssZZZZZ`
/// * `.full` => `yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ`
- public struct DateTime: TemporalSpec {
+ struct DateTime: TemporalSpec {
// Inherits documentation from `TemporalSpec`
public let foundationDate: Foundation.Date
@@ -42,7 +42,7 @@ extension Temporal {
self.timeZone = timeZone
- foundationDate = calendar
+ self.foundationDate = calendar
.date(from: components) ?? date
}
diff --git a/Amplify/Categories/DataStore/Model/Temporal/SpecBasedDateConverting.swift b/Amplify/Categories/DataStore/Model/Temporal/SpecBasedDateConverting.swift
index 5aaa135d8d..26612ab195 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/SpecBasedDateConverting.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/SpecBasedDateConverting.swift
@@ -10,12 +10,12 @@ import Foundation
/// Internal generic method to reduce code reuse in the `init`s of `TemporalSpec`
/// conforming types
@usableFromInline
-internal struct SpecBasedDateConverting {
+struct SpecBasedDateConverting {
@usableFromInline
- internal typealias DateConverter = (_ string: String, _ format: TemporalFormat?) throws -> (Date, TimeZone)
+ typealias DateConverter = (_ string: String, _ format: TemporalFormat?) throws -> (Date, TimeZone)
@usableFromInline
- internal let convert: DateConverter
+ let convert: DateConverter
@inlinable
@inline(never)
@@ -25,13 +25,13 @@ internal struct SpecBasedDateConverting {
@inlinable
@inline(never)
- internal static func `default`(
+ static func `default`(
iso8601String: String,
format: TemporalFormat? = nil
) throws -> (Date, TimeZone) {
let date: Foundation.Date
- let tz: TimeZone = TimeZone(iso8601DateString: iso8601String) ?? .utc
- if let format = format {
+ let tz = TimeZone(iso8601DateString: iso8601String) ?? .utc
+ if let format {
date = try Temporal.date(
from: iso8601String,
with: [format(for: Spec.self)]
diff --git a/Amplify/Categories/DataStore/Model/Temporal/Temporal+Cache.swift b/Amplify/Categories/DataStore/Model/Temporal/Temporal+Cache.swift
index f9642a72a2..a30c1a4429 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/Temporal+Cache.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/Temporal+Cache.swift
@@ -12,21 +12,21 @@ extension Temporal {
// of the formatter cache dictionary.
//
// DateFormatter itself is thread safe.
- nonisolated(unsafe) private static var formatterCache: [String: DateFormatter] = [:]
+ private nonisolated(unsafe) static var formatterCache: [String: DateFormatter] = [:]
- @usableFromInline
/// The `Calendar` used for date operations.
///
/// `identifier` is `.iso8601`
/// `timeZome` is `.utc` a.k.a. `TimeZone(abbreviation: "UTC")`
- internal static let iso8601Calendar: Calendar = {
+ @usableFromInline
+ static let iso8601Calendar: Calendar = {
var calendar = Calendar(identifier: .iso8601)
calendar.timeZone = .utc
return calendar
}()
/// Pointer to lock to ensure exclusive access.
- nonisolated(unsafe) private static let lock: UnsafeMutablePointer = {
+ private nonisolated(unsafe) static let lock: UnsafeMutablePointer = {
let pointer = UnsafeMutablePointer.allocate(capacity: 1)
pointer.initialize(to: os_unfair_lock())
return pointer
@@ -37,7 +37,7 @@ extension Temporal {
/// - format: The `DateFormatter().dateFormat`
/// - timeZone: The `DateFormatter().timeZone`
/// - Returns: A `DateFormatter`
- internal static func formatter(
+ static func formatter(
for format: String,
in timeZone: TimeZone
) -> DateFormatter {
@@ -102,7 +102,6 @@ extension Temporal {
// defer takes care of unlock
}
- @usableFromInline
/// Turn a `String` into a `Foundation.Date`
/// - Parameters:
/// - string: The date in `String` form.
@@ -111,7 +110,8 @@ extension Temporal {
/// Default is `.utc` a.k.a. `TimeZone(abbreviation: "UTC")`
/// - Returns: A `Foundation.Date` if conversion was successful.
/// - Throws: `DataStoreError.invalidDateFormat(_:)` if conversion was unsuccessful.
- internal static func date(
+ @usableFromInline
+ static func date(
from string: String,
with formats: [String],
in timeZone: TimeZone = .utc
@@ -126,7 +126,6 @@ extension Temporal {
.invalidDateFormat(formats.joined(separator: " | "))
}
- @usableFromInline
/// Turn a `Foundation.Date` into a `String`
/// - Parameters:
/// - date: The `Foundation.Date` to be converted to `String` form.
@@ -134,7 +133,8 @@ extension Temporal {
/// - timeZone: The `TimeZone` used by the `DateFormatter` when converted.
/// Default is `.utc` a.k.a. `TimeZone(abbreviation: "UTC")`
/// - Returns: The `String` representation of the `date` formatted according to the `format` argument..
- internal static func string(
+ @usableFromInline
+ static func string(
from date: Foundation.Date,
with format: String,
in timeZone: TimeZone = .utc
diff --git a/Amplify/Categories/DataStore/Model/Temporal/Temporal+Codable.swift b/Amplify/Categories/DataStore/Model/Temporal/Temporal+Codable.swift
index 024b534d2d..15db66b141 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/Temporal+Codable.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/Temporal+Codable.swift
@@ -7,14 +7,14 @@
import Foundation
-extension TemporalSpec where Self: Codable {
- public init(from decoder: Decoder) throws {
+public extension TemporalSpec where Self: Codable {
+ init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let value = try container.decode(String.self)
try self.init(iso8601String: value)
}
- public func encode(to encoder: Encoder) throws {
+ func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(iso8601String)
}
diff --git a/Amplify/Categories/DataStore/Model/Temporal/Temporal+Comparable.swift b/Amplify/Categories/DataStore/Model/Temporal/Temporal+Comparable.swift
index bc9e9e47e0..a577817edf 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/Temporal+Comparable.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/Temporal+Comparable.swift
@@ -12,14 +12,14 @@ import Foundation
/// takes care of deriving the other operations from those two.
///
/// - Note: the implementation simply delegates to the `iso8601String` formatted date.
-extension TemporalSpec where Self: Comparable {
+public extension TemporalSpec where Self: Comparable {
- public static func == (lhs: Self, rhs: Self) -> Bool {
+ static func == (lhs: Self, rhs: Self) -> Bool {
return lhs.iso8601FormattedString(format: .full, timeZone: .utc)
== rhs.iso8601FormattedString(format: .full, timeZone: .utc)
}
- public static func < (lhs: Self, rhs: Self) -> Bool {
+ static func < (lhs: Self, rhs: Self) -> Bool {
return lhs.iso8601FormattedString(format: .full, timeZone: .utc)
< rhs.iso8601FormattedString(format: .full, timeZone: .utc)
}
diff --git a/Amplify/Categories/DataStore/Model/Temporal/Temporal.swift b/Amplify/Categories/DataStore/Model/Temporal/Temporal.swift
index e92f4f9435..ad6256d21c 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/Temporal.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/Temporal.swift
@@ -72,7 +72,7 @@ public protocol TemporalSpec {
func iso8601FormattedString(format: TemporalFormat, timeZone: TimeZone) -> String
}
-extension TemporalSpec {
+public extension TemporalSpec {
/// Create an iso8601 `String` with the desired format option for this spec.
/// - Parameters:
@@ -80,7 +80,7 @@ extension TemporalSpec {
/// - timeZone: `TimeZone` that the `DateFormatter` will use in conversion.
/// Default is `.utc` a.k.a. `TimeZone(abbreviation: "UTC")`
/// - Returns: A `String` formatted according to the `format` and `timeZone` arguments.
- public func iso8601FormattedString(
+ func iso8601FormattedString(
format: TemporalFormat,
timeZone: TimeZone = .utc
) -> String {
@@ -93,12 +93,12 @@ extension TemporalSpec {
/// The ISO8601 representation of the scalar using `.full` as the format and `.utc` as `TimeZone`.
/// - SeeAlso: `iso8601FormattedString(format:timeZone:)`
- public var iso8601String: String {
+ var iso8601String: String {
iso8601FormattedString(format: .full, timeZone: timeZone ?? .utc)
}
@inlinable
- public init(iso8601String: String, format: TemporalFormat) throws {
+ init(iso8601String: String, format: TemporalFormat) throws {
let (date, tz) = try SpecBasedDateConverting()
.convert(iso8601String, format)
@@ -106,7 +106,7 @@ extension TemporalSpec {
}
@inlinable
- public init(
+ init(
iso8601String: String
) throws {
let (date, tz) = try SpecBasedDateConverting()
@@ -116,9 +116,9 @@ extension TemporalSpec {
}
}
-extension TimeZone {
+public extension TimeZone {
/// Utility UTC ("Coordinated Universal Time") TimeZone instance.
- public static var utc: TimeZone {
+ static var utc: TimeZone {
TimeZone(abbreviation: "UTC")!
}
}
diff --git a/Amplify/Categories/DataStore/Model/Temporal/TemporalFormat.swift b/Amplify/Categories/DataStore/Model/Temporal/TemporalFormat.swift
index 3f245dd920..b553a0aa3a 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/TemporalFormat.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/TemporalFormat.swift
@@ -64,35 +64,33 @@ public struct TemporalFormat: @unchecked Sendable {
]
private func keyPath(for type: TemporalSpec.Type) -> KeyPath {
- let keyPath: KeyPath
- if type == Temporal.Time.self {
- keyPath = \TemporalFormat.timeFormat
+ let keyPath: KeyPath = if type == Temporal.Time.self {
+ \TemporalFormat.timeFormat
} else if type == Temporal.Date.self {
- keyPath = \TemporalFormat.dateFormat
+ \TemporalFormat.dateFormat
} else {
- keyPath = \TemporalFormat.dateTimeFormat
+ \TemporalFormat.dateTimeFormat
}
return keyPath
}
@usableFromInline
- internal static func sortedFormats(for type: TemporalSpec.Type) -> [String] {
- let formats: [String]
+ static func sortedFormats(for type: TemporalSpec.Type) -> [String] {
// If the TemporalSpec is `Date`, let's only return `.full` and `.short`
// because `.medium`, `.long`, and `.full` are all the same format.
// If the formats ever differ, this needs to be updated.
- if type == Temporal.Date.self {
- formats = [TemporalFormat.full, .short]
+ let formats: [String] = if type == Temporal.Date.self {
+ [TemporalFormat.full, .short]
.map { $0(for: type) }
} else {
- formats = Self.allCases
+ Self.allCases
.map { $0(for: type) }
}
return formats
}
@usableFromInline
- internal func callAsFunction(for type: TemporalSpec.Type) -> String {
+ func callAsFunction(for type: TemporalSpec.Type) -> String {
self[keyPath: keyPath(for: type)]
}
}
diff --git a/Amplify/Categories/DataStore/Model/Temporal/Time+Operation.swift b/Amplify/Categories/DataStore/Model/Temporal/Time+Operation.swift
index d35cc04582..e7dee4b56b 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/Time+Operation.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/Time+Operation.swift
@@ -109,14 +109,14 @@ public protocol TimeUnitOperable {
static func - (left: Self, right: TimeUnit) -> Self
}
-extension TemporalSpec where Self: TimeUnitOperable {
+public extension TemporalSpec where Self: TimeUnitOperable {
/// Add a `TimeUnit` to a `Temporal.Time` or `Temporal.DateTime`
/// - Parameters:
/// - left: `Temporal.Time` or `Temporal.DateTime`
/// - right: `TimeUnit` to add to `left`
/// - Returns: A new `Temporal.Time` or `Temporal.DateTime` the `TimeUnit` was added to.
- public static func + (left: Self, right: TimeUnit) -> Self {
+ static func + (left: Self, right: TimeUnit) -> Self {
return left.add(value: right.value, to: right.calendarComponent)
}
@@ -125,7 +125,7 @@ extension TemporalSpec where Self: TimeUnitOperable {
/// - left: `Temporal.Time` or `Temporal.DateTime`
/// - right: `TimeUnit` to subtract from `left`
/// - Returns: A new `Temporal.Time` or `Temporal.DateTime` the `TimeUnit` was subtracted from.
- public static func - (left: Self, right: TimeUnit) -> Self {
+ static func - (left: Self, right: TimeUnit) -> Self {
return left.add(value: -right.value, to: right.calendarComponent)
}
}
diff --git a/Amplify/Categories/DataStore/Model/Temporal/Time.swift b/Amplify/Categories/DataStore/Model/Temporal/Time.swift
index d4185e874d..b263b715a2 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/Time.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/Time.swift
@@ -7,14 +7,14 @@
import Foundation
-extension Temporal {
+public extension Temporal {
/// `Temporal.Time` represents a `Time` with specific allowable formats.
///
/// * `.short` => `HH:mm`
/// * `.medium` => `HH:mm:ss`
/// * `.long` => `HH:mm:ss.SSS`
/// * `.full` => `HH:mm:ss.SSSZZZZZ`
- public struct Time: TemporalSpec {
+ struct Time: TemporalSpec {
// Inherits documentation from `TemporalSpec`
public let foundationDate: Foundation.Date
diff --git a/Amplify/Categories/DataStore/Model/Temporal/TimeZone+Extension.swift b/Amplify/Categories/DataStore/Model/Temporal/TimeZone+Extension.swift
index efbbbfb673..530cd27063 100644
--- a/Amplify/Categories/DataStore/Model/Temporal/TimeZone+Extension.swift
+++ b/Amplify/Categories/DataStore/Model/Temporal/TimeZone+Extension.swift
@@ -10,7 +10,7 @@ import Foundation
extension TimeZone {
@usableFromInline
- internal init?(iso8601DateString: String) {
+ init?(iso8601DateString: String) {
switch ISO8601TimeZonePart.from(iso8601DateString: iso8601DateString) {
case .some(.utc):
self.init(abbreviation: "UTC")
diff --git a/Amplify/Categories/DataStore/Query/ModelKey.swift b/Amplify/Categories/DataStore/Query/ModelKey.swift
index 860cb17061..c2f3a32e66 100644
--- a/Amplify/Categories/DataStore/Query/ModelKey.swift
+++ b/Amplify/Categories/DataStore/Query/ModelKey.swift
@@ -34,111 +34,111 @@ import Foundation
/// ```
public protocol ModelKey: CodingKey, CaseIterable, QueryFieldOperation {}
-extension CodingKey where Self: ModelKey {
+public extension CodingKey where Self: ModelKey {
// MARK: - attributeExists
- public func attributeExists(_ value: Bool) -> QueryPredicateOperation {
+ func attributeExists(_ value: Bool) -> QueryPredicateOperation {
return field(stringValue).attributeExists(value)
}
// MARK: - beginsWith
- public func beginsWith(_ value: String) -> QueryPredicateOperation {
+ func beginsWith(_ value: String) -> QueryPredicateOperation {
return field(stringValue).beginsWith(value)
}
// MARK: - between
- public func between(start: Persistable, end: Persistable) -> QueryPredicateOperation {
+ func between(start: Persistable, end: Persistable) -> QueryPredicateOperation {
return field(stringValue).between(start: start, end: end)
}
// MARK: - contains
- public func contains(_ value: String) -> QueryPredicateOperation {
+ func contains(_ value: String) -> QueryPredicateOperation {
return field(stringValue).contains(value)
}
- public static func ~= (key: Self, value: String) -> QueryPredicateOperation {
+ static func ~= (key: Self, value: String) -> QueryPredicateOperation {
return key.contains(value)
}
// MARK: - not contains
- public func notContains(_ value: String) -> QueryPredicateOperation {
+ func notContains(_ value: String) -> QueryPredicateOperation {
return field(stringValue).notContains(value)
}
// MARK: - eq
- public func eq(_ value: Persistable?) -> QueryPredicateOperation {
+ func eq(_ value: Persistable?) -> QueryPredicateOperation {
return field(stringValue).eq(value)
}
- public func eq(_ value: EnumPersistable) -> QueryPredicateOperation {
+ func eq(_ value: EnumPersistable) -> QueryPredicateOperation {
return field(stringValue).eq(value)
}
- public static func == (key: Self, value: Persistable?) -> QueryPredicateOperation {
+ static func == (key: Self, value: Persistable?) -> QueryPredicateOperation {
return key.eq(value)
}
- public static func == (key: Self, value: EnumPersistable) -> QueryPredicateOperation {
+ static func == (key: Self, value: EnumPersistable) -> QueryPredicateOperation {
return key.eq(value)
}
// MARK: - ge
- public func ge(_ value: Persistable) -> QueryPredicateOperation {
+ func ge(_ value: Persistable) -> QueryPredicateOperation {
return field(stringValue).ge(value)
}
- public static func >= (key: Self, value: Persistable) -> QueryPredicateOperation {
+ static func >= (key: Self, value: Persistable) -> QueryPredicateOperation {
return key.ge(value)
}
// MARK: - gt
- public func gt(_ value: Persistable) -> QueryPredicateOperation {
+ func gt(_ value: Persistable) -> QueryPredicateOperation {
return field(stringValue).gt(value)
}
- public static func > (key: Self, value: Persistable) -> QueryPredicateOperation {
+ static func > (key: Self, value: Persistable) -> QueryPredicateOperation {
return key.gt(value)
}
// MARK: - le
- public func le(_ value: Persistable) -> QueryPredicateOperation {
+ func le(_ value: Persistable) -> QueryPredicateOperation {
return field(stringValue).le(value)
}
- public static func <= (key: Self, value: Persistable) -> QueryPredicateOperation {
+ static func <= (key: Self, value: Persistable) -> QueryPredicateOperation {
return key.le(value)
}
// MARK: - lt
- public func lt(_ value: Persistable) -> QueryPredicateOperation {
+ func lt(_ value: Persistable) -> QueryPredicateOperation {
return field(stringValue).lt(value)
}
- public static func < (key: Self, value: Persistable) -> QueryPredicateOperation {
+ static func < (key: Self, value: Persistable) -> QueryPredicateOperation {
return key.lt(value)
}
// MARK: - ne
- public func ne(_ value: Persistable?) -> QueryPredicateOperation {
+ func ne(_ value: Persistable?) -> QueryPredicateOperation {
return field(stringValue).ne(value)
}
- public func ne(_ value: EnumPersistable) -> QueryPredicateOperation {
+ func ne(_ value: EnumPersistable) -> QueryPredicateOperation {
return field(stringValue).ne(value)
}
- public static func != (key: Self, value: Persistable?) -> QueryPredicateOperation {
+ static func != (key: Self, value: Persistable?) -> QueryPredicateOperation {
return key.ne(value)
}
- public static func != (key: Self, value: EnumPersistable) -> QueryPredicateOperation {
+ static func != (key: Self, value: EnumPersistable) -> QueryPredicateOperation {
return key.ne(value)
}
diff --git a/Amplify/Categories/DataStore/Query/QueryOperator.swift b/Amplify/Categories/DataStore/Query/QueryOperator.swift
index e4897e5f0d..08ea007770 100644
--- a/Amplify/Categories/DataStore/Query/QueryOperator.swift
+++ b/Amplify/Categories/DataStore/Query/QueryOperator.swift
@@ -72,14 +72,16 @@ public enum QueryOperator: Encodable {
switch self {
case .notEqual(let value):
try container.encode("notEqual", forKey: .type)
- if let value = value {
+ if let value {
try container.encode(value, forKey: .value)
}
+
case .equals(let value):
try container.encode("equals", forKey: .type)
- if let value = value {
+ if let value {
try container.encode(value, forKey: .value)
}
+
case .lessOrEqual(let value):
try container.encode("lessOrEqual", forKey: .type)
try container.encode(value, forKey: .value)
diff --git a/Amplify/Categories/DataStore/Query/QueryPaginationInput.swift b/Amplify/Categories/DataStore/Query/QueryPaginationInput.swift
index 75b46ffbac..dd665aa475 100644
--- a/Amplify/Categories/DataStore/Query/QueryPaginationInput.swift
+++ b/Amplify/Categories/DataStore/Query/QueryPaginationInput.swift
@@ -21,7 +21,7 @@ public struct QueryPaginationInput {
}
-extension QueryPaginationInput {
+public extension QueryPaginationInput {
/// Creates a `QueryPaginationInput` in an expressive way, enabling a short
/// and developer friendly access to an instance of `QueryPaginationInput`.
@@ -30,18 +30,20 @@ extension QueryPaginationInput {
/// - page: the page number (starting at 0)
/// - limit: the page size (defaults to `QueryPaginationInput.defaultLimit`)
/// - Returns: a new instance of `QueryPaginationInput`
- public static func page(_ page: UInt,
- limit: UInt = QueryPaginationInput.defaultLimit) -> QueryPaginationInput {
+ static func page(
+ _ page: UInt,
+ limit: UInt = QueryPaginationInput.defaultLimit
+ ) -> QueryPaginationInput {
return QueryPaginationInput(page: page, limit: limit)
}
/// Utility that created a `QueryPaginationInput` with `page` 0 and `limit` 1
- public static var firstResult: QueryPaginationInput {
+ static var firstResult: QueryPaginationInput {
.page(0, limit: 1)
}
/// Utility that created a `QueryPaginationInput` with `page` 0 and the default `limit`
- public static var firstPage: QueryPaginationInput {
+ static var firstPage: QueryPaginationInput {
.page(0)
}
diff --git a/Amplify/Categories/DataStore/Query/QueryPredicate.swift b/Amplify/Categories/DataStore/Query/QueryPredicate.swift
index 222bd11c6e..2704f1b534 100644
--- a/Amplify/Categories/DataStore/Query/QueryPredicate.swift
+++ b/Amplify/Categories/DataStore/Query/QueryPredicate.swift
@@ -19,7 +19,7 @@ public enum QueryPredicateGroupType: String, Encodable {
/// The `not` function is used to wrap a `QueryPredicate` in a `QueryPredicateGroup` of type `.not`.
/// - Parameter predicate: the `QueryPredicate` (either operation or group)
/// - Returns: `QueryPredicateGroup` of type `.not`
-public func not(_ predicate: Predicate) -> QueryPredicateGroup {
+public func not(_ predicate: some QueryPredicate) -> QueryPredicateGroup {
return QueryPredicateGroup(type: .not, predicates: [predicate])
}
@@ -37,8 +37,10 @@ public class QueryPredicateGroup: QueryPredicate, Encodable {
public internal(set) var type: QueryPredicateGroupType
public internal(set) var predicates: [QueryPredicate]
- public init(type: QueryPredicateGroupType = .and,
- predicates: [QueryPredicate] = []) {
+ public init(
+ type: QueryPredicateGroupType = .and,
+ predicates: [QueryPredicate] = []
+ ) {
self.type = type
self.predicates = predicates
}
@@ -104,7 +106,7 @@ public class QueryPredicateGroup: QueryPredicate, Encodable {
private let _encode: (Encoder) throws -> Void
init(_ base: QueryPredicate) {
- _encode = base.encode
+ self._encode = base.encode
}
func encode(to encoder: Encoder) throws {
diff --git a/Amplify/Categories/DataStore/Subscribe/DataStoreCategory+Subscribe.swift b/Amplify/Categories/DataStore/Subscribe/DataStoreCategory+Subscribe.swift
index ae669c73f9..2c59c95f17 100644
--- a/Amplify/Categories/DataStore/Subscribe/DataStoreCategory+Subscribe.swift
+++ b/Amplify/Categories/DataStore/Subscribe/DataStoreCategory+Subscribe.swift
@@ -8,13 +8,15 @@
import Combine
extension DataStoreCategory: DataStoreSubscribeBehavior {
- public func observe(_ modelType: M.Type) -> AmplifyAsyncThrowingSequence {
+ public func observe(_ modelType: (some Model).Type) -> AmplifyAsyncThrowingSequence {
return plugin.observe(modelType)
}
- 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
+ )
-> AmplifyAsyncThrowingSequence> {
return plugin.observeQuery(for: modelType, where: predicate, sort: sortInput)
}
diff --git a/Amplify/Categories/DataStore/Subscribe/MutationEvent+Model.swift b/Amplify/Categories/DataStore/Subscribe/MutationEvent+Model.swift
index 332376b096..8e5f29e973 100644
--- a/Amplify/Categories/DataStore/Subscribe/MutationEvent+Model.swift
+++ b/Amplify/Categories/DataStore/Subscribe/MutationEvent+Model.swift
@@ -5,35 +5,43 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension MutationEvent {
+public extension MutationEvent {
- public init(untypedModel model: Model,
- mutationType: MutationType,
- version: Int? = nil) throws {
+ init(
+ untypedModel model: Model,
+ mutationType: MutationType,
+ version: Int? = nil
+ ) throws {
guard let modelType = ModelRegistry.modelType(from: model.modelName) else {
let dataStoreError = DataStoreError.invalidModelName(model.modelName)
throw dataStoreError
}
- try self.init(untypedModel: model,
- modelName: modelType.schema.name,
- mutationType: mutationType,
- version: version)
+ try self.init(
+ untypedModel: model,
+ modelName: modelType.schema.name,
+ mutationType: mutationType,
+ version: version
+ )
}
- public init(untypedModel model: Model,
- modelName: ModelName,
- mutationType: MutationType,
- version: Int? = nil) throws {
+ init(
+ untypedModel model: Model,
+ modelName: ModelName,
+ mutationType: MutationType,
+ version: Int? = nil
+ ) throws {
let json = try model.toJSON()
guard let modelSchema = ModelRegistry.modelSchema(from: modelName) else {
let dataStoreError = DataStoreError.invalidModelName(modelName)
throw dataStoreError
}
- self.init(modelId: model.identifier(schema: modelSchema).stringValue,
- modelName: modelName,
- json: json,
- mutationType: mutationType,
- version: version)
+ self.init(
+ modelId: model.identifier(schema: modelSchema).stringValue,
+ modelName: modelName,
+ json: json,
+ mutationType: mutationType,
+ version: version
+ )
}
}
diff --git a/Amplify/Categories/DataStore/Subscribe/MutationEvent+Schema.swift b/Amplify/Categories/DataStore/Subscribe/MutationEvent+Schema.swift
index 94cbf9bbbc..c5823c2dd4 100644
--- a/Amplify/Categories/DataStore/Subscribe/MutationEvent+Schema.swift
+++ b/Amplify/Categories/DataStore/Subscribe/MutationEvent+Schema.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension MutationEvent {
+public extension MutationEvent {
// MARK: - CodingKeys
- public enum CodingKeys: String, ModelKey {
+ enum CodingKeys: String, ModelKey {
case id
case modelId
case modelName
@@ -20,11 +20,11 @@ extension MutationEvent {
case graphQLFilterJSON
}
- public static let keys = CodingKeys.self
+ static let keys = CodingKeys.self
// MARK: - ModelSchema
- nonisolated(unsafe) public static let schema = defineSchema { definition in
+ nonisolated(unsafe) static let schema = defineSchema { definition in
let mutation = MutationEvent.keys
definition.listPluralName = "MutationEvents"
diff --git a/Amplify/Categories/DataStore/Subscribe/MutationEvent.swift b/Amplify/Categories/DataStore/Subscribe/MutationEvent.swift
index 988ba31994..8c1a3b8797 100644
--- a/Amplify/Categories/DataStore/Subscribe/MutationEvent.swift
+++ b/Amplify/Categories/DataStore/Subscribe/MutationEvent.swift
@@ -21,15 +21,17 @@ public struct MutationEvent: Model {
public var inProcess: Bool
public var graphQLFilterJSON: String?
- public init(id: EventIdentifier = UUID().uuidString,
- modelId: ModelId,
- modelName: String,
- json: String,
- mutationType: MutationType,
- createdAt: Temporal.DateTime = .now(),
- version: Int? = nil,
- inProcess: Bool = false,
- graphQLFilterJSON: String? = nil) {
+ public init(
+ id: EventIdentifier = UUID().uuidString,
+ modelId: ModelId,
+ modelName: String,
+ json: String,
+ mutationType: MutationType,
+ createdAt: Temporal.DateTime = .now(),
+ version: Int? = nil,
+ inProcess: Bool = false,
+ graphQLFilterJSON: String? = nil
+ ) {
self.id = id
self.modelId = modelId
self.modelName = modelName
@@ -41,18 +43,22 @@ public struct MutationEvent: Model {
self.graphQLFilterJSON = graphQLFilterJSON
}
- public init(model: M,
- modelSchema: ModelSchema,
- mutationType: MutationType,
- version: Int? = nil,
- graphQLFilterJSON: String? = nil) throws {
+ public init(
+ model: some Model,
+ modelSchema: ModelSchema,
+ mutationType: MutationType,
+ version: Int? = nil,
+ graphQLFilterJSON: String? = nil
+ ) throws {
let json = try model.toJSON()
- self.init(modelId: model.identifier(schema: modelSchema).stringValue,
- modelName: modelSchema.name,
- json: json,
- mutationType: mutationType,
- version: version,
- graphQLFilterJSON: graphQLFilterJSON)
+ self.init(
+ modelId: model.identifier(schema: modelSchema).stringValue,
+ modelName: modelSchema.name,
+ json: json,
+ mutationType: mutationType,
+ version: version,
+ graphQLFilterJSON: graphQLFilterJSON
+ )
}
@@ -60,15 +66,19 @@ public struct MutationEvent: Model {
Initializing from a model without a ModelSchema is deprecated.
Use init(model:modelSchema:mutationType:version:graphQLFilterJSON:) instead.
""")
- public init(model: M,
- mutationType: MutationType,
- version: Int? = nil,
- graphQLFilterJSON: String? = nil) throws {
- try self.init(model: model,
- modelSchema: model.schema,
- mutationType: mutationType,
- version: version,
- graphQLFilterJSON: graphQLFilterJSON)
+ public init(
+ model: some Model,
+ mutationType: MutationType,
+ version: Int? = nil,
+ graphQLFilterJSON: String? = nil
+ ) throws {
+ try self.init(
+ model: model,
+ modelSchema: model.schema,
+ mutationType: mutationType,
+ version: version,
+ graphQLFilterJSON: graphQLFilterJSON
+ )
}
@@ -89,7 +99,8 @@ public struct MutationEvent: Model {
it is a valid \(modelType.modelName) instance:
\(json)
- """)
+ """
+ )
}
return typedModel
diff --git a/Amplify/Categories/Geo/GeoCategory+ClientBehavior.swift b/Amplify/Categories/Geo/GeoCategory+ClientBehavior.swift
index b435e6931c..9427bf2cf1 100644
--- a/Amplify/Categories/Geo/GeoCategory+ClientBehavior.swift
+++ b/Amplify/Categories/Geo/GeoCategory+ClientBehavior.swift
@@ -22,8 +22,10 @@ extension GeoCategory: GeoCategoryBehavior {
/// `Geo.Error.networkError` if request failed or network unavailable
/// `Geo.Error.pluginError` if encapsulated error received by a dependent plugin
/// `Geo.Error.unknown` if error is unknown
- public func search(for text: String,
- options: Geo.SearchForTextOptions? = nil) async throws -> [Geo.Place] {
+ public func search(
+ for text: String,
+ options: Geo.SearchForTextOptions? = nil
+ ) async throws -> [Geo.Place] {
return try await plugin.search(for: text, options: options)
}
@@ -41,8 +43,10 @@ extension GeoCategory: GeoCategoryBehavior {
/// `Geo.Error.networkError` if request failed or network unavailable
/// `Geo.Error.pluginError` if encapsulated error received by a dependent plugin
/// `Geo.Error.unknown` if error is unknown
- public func search(for coordinates: Geo.Coordinates,
- options: Geo.SearchForCoordinatesOptions? = nil) async throws -> [Geo.Place] {
+ public func search(
+ for coordinates: Geo.Coordinates,
+ options: Geo.SearchForCoordinatesOptions? = nil
+ ) async throws -> [Geo.Place] {
return try await plugin.search(for: coordinates, options: options)
}
diff --git a/Amplify/Categories/Geo/GeoCategory.swift b/Amplify/Categories/Geo/GeoCategory.swift
index aa9579a9bb..6059187ae4 100644
--- a/Amplify/Categories/Geo/GeoCategory.swift
+++ b/Amplify/Categories/Geo/GeoCategory.swift
@@ -6,7 +6,7 @@
//
/// The Geo category enables you to interact with geospacial services.
-final public class GeoCategory: Category {
+public final class GeoCategory: Category {
/// Geo category type
public let categoryType = CategoryType.geo
@@ -56,7 +56,8 @@ final public class GeoCategory: Category {
let pluginDescription = String(describing: plugin)
let error = Geo.Error.invalidConfiguration(
"Plugin \(pluginDescription) has an empty `key`.",
- "Set the `key` property for \(String(describing: plugin))")
+ "Set the `key` property for \(String(describing: plugin))"
+ )
throw error
}
@@ -81,7 +82,8 @@ final public class GeoCategory: Category {
let keys = plugins.keys.joined(separator: ", ")
let error = Geo.Error.invalidConfiguration(
"No plugin has been added for '\(key)'.",
- "Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
+ "Either add a plugin for '\(key)', or use one of the known keys: \(keys)"
+ )
throw error
}
return plugin
diff --git a/Amplify/Categories/Geo/GeoCategoryBehavior.swift b/Amplify/Categories/Geo/GeoCategoryBehavior.swift
index 29fe16bf57..ee0a854ff8 100644
--- a/Amplify/Categories/Geo/GeoCategoryBehavior.swift
+++ b/Amplify/Categories/Geo/GeoCategoryBehavior.swift
@@ -25,8 +25,10 @@ public protocol GeoCategoryBehavior {
/// `Geo.Error.networkError` if request failed or network unavailable
/// `Geo.Error.pluginError` if encapsulated error received by a dependent plugin
/// `Geo.Error.unknown` if error is unknown
- func search(for text: String,
- options: Geo.SearchForTextOptions?) async throws -> [Geo.Place]
+ func search(
+ for text: String,
+ options: Geo.SearchForTextOptions?
+ ) async throws -> [Geo.Place]
/// Reverse geocodes a given pair of coordinates and returns a list of Places
/// closest to the specified position.
@@ -42,8 +44,10 @@ public protocol GeoCategoryBehavior {
/// `Geo.Error.networkError` if request failed or network unavailable
/// `Geo.Error.pluginError` if encapsulated error received by a dependent plugin
/// `Geo.Error.unknown` if error is unknown
- func search(for coordinates: Geo.Coordinates,
- options: Geo.SearchForCoordinatesOptions?) async throws -> [Geo.Place]
+ func search(
+ for coordinates: Geo.Coordinates,
+ options: Geo.SearchForCoordinatesOptions?
+ ) async throws -> [Geo.Place]
// MARK: - Maps
diff --git a/Amplify/Categories/Geo/Types/CLocationCoordinate2D+Geo.Coordinates.swift b/Amplify/Categories/Geo/Types/CLocationCoordinate2D+Geo.Coordinates.swift
index a67ce4c3a1..d016d5e25b 100644
--- a/Amplify/Categories/Geo/Types/CLocationCoordinate2D+Geo.Coordinates.swift
+++ b/Amplify/Categories/Geo/Types/CLocationCoordinate2D+Geo.Coordinates.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-import Foundation
import CoreLocation
+import Foundation
public extension CLLocationCoordinate2D {
/// Initialize a Location from a CLLocationCoordinate2D
diff --git a/Amplify/Categories/Geo/Types/Geo+Coordinates.swift b/Amplify/Categories/Geo/Types/Geo+Coordinates.swift
index b374b42e4f..0e30837097 100644
--- a/Amplify/Categories/Geo/Types/Geo+Coordinates.swift
+++ b/Amplify/Categories/Geo/Types/Geo+Coordinates.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-import Foundation
import CoreLocation
+import Foundation
public extension Geo {
/// A pair of coordinates to represent a location (point).
diff --git a/Amplify/Categories/Geo/Types/Geo+Error.swift b/Amplify/Categories/Geo/Types/Geo+Error.swift
index d7e6b81615..abd91e40d2 100644
--- a/Amplify/Categories/Geo/Types/Geo+Error.swift
+++ b/Amplify/Categories/Geo/Types/Geo+Error.swift
@@ -27,9 +27,11 @@ public extension Geo {
extension Geo.Error: AmplifyError {
/// Initializer
- public init(errorDescription: ErrorDescription = "An unknown error occurred",
- recoverySuggestion: RecoverySuggestion = "See `underlyingError` for more details",
- error: Error) {
+ public init(
+ errorDescription: ErrorDescription = "An unknown error occurred",
+ recoverySuggestion: RecoverySuggestion = "See `underlyingError` for more details",
+ error: Error
+ ) {
if let error = error as? Self {
self = error
} else if error.isOperationCancelledError {
diff --git a/Amplify/Categories/Geo/Types/Geo+Place.swift b/Amplify/Categories/Geo/Types/Geo+Place.swift
index 18d6e4c2dd..ebfedd6fc9 100644
--- a/Amplify/Categories/Geo/Types/Geo+Place.swift
+++ b/Amplify/Categories/Geo/Types/Geo+Place.swift
@@ -34,16 +34,18 @@ public extension Geo {
public let country: String?
/// Initializer
- public init(coordinates: Coordinates,
- label: String?,
- addressNumber: String?,
- street: String?,
- municipality: String?,
- neighborhood: String?,
- region: String?,
- subRegion: String?,
- postalCode: String?,
- country: String?) {
+ public init(
+ coordinates: Coordinates,
+ label: String?,
+ addressNumber: String?,
+ street: String?,
+ municipality: String?,
+ neighborhood: String?,
+ region: String?,
+ subRegion: String?,
+ postalCode: String?,
+ country: String?
+ ) {
self.coordinates = coordinates
self.label = label
self.addressNumber = addressNumber
diff --git a/Amplify/Categories/Geo/Types/Geo+SearchArea.swift b/Amplify/Categories/Geo/Types/Geo+SearchArea.swift
index c0a3b3c124..13c5c7a816 100644
--- a/Amplify/Categories/Geo/Types/Geo+SearchArea.swift
+++ b/Amplify/Categories/Geo/Types/Geo+SearchArea.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-import Foundation
import CoreLocation
+import Foundation
public extension Geo {
/// The area to search.
diff --git a/Amplify/Categories/Geo/Types/Geo+SearchOptions.swift b/Amplify/Categories/Geo/Types/Geo+SearchOptions.swift
index 88f683c5b9..5353d90fef 100644
--- a/Amplify/Categories/Geo/Types/Geo+SearchOptions.swift
+++ b/Amplify/Categories/Geo/Types/Geo+SearchOptions.swift
@@ -21,10 +21,12 @@ public extension Geo {
/// functionality. See plugin documentation for expected key/values.
public var pluginOptions: Any?
- public init(area: Geo.SearchArea? = nil,
- countries: [Geo.Country]? = nil,
- maxResults: Int? = nil,
- pluginOptions: Any? = nil) {
+ public init(
+ area: Geo.SearchArea? = nil,
+ countries: [Geo.Country]? = nil,
+ maxResults: Int? = nil,
+ pluginOptions: Any? = nil
+ ) {
self.area = area
self.countries = countries
self.maxResults = maxResults
@@ -43,8 +45,10 @@ public extension Geo {
/// functionality. See plugin documentation for expected key/values.
public var pluginOptions: Any?
- public init(maxResults: Int? = nil,
- pluginOptions: Any? = nil) {
+ public init(
+ maxResults: Int? = nil,
+ pluginOptions: Any? = nil
+ ) {
self.maxResults = maxResults
self.pluginOptions = pluginOptions
}
diff --git a/Amplify/Categories/Hub/HubCategory+ClientBehavior.swift b/Amplify/Categories/Hub/HubCategory+ClientBehavior.swift
index 14afd3581d..ced73c0d02 100644
--- a/Amplify/Categories/Hub/HubCategory+ClientBehavior.swift
+++ b/Amplify/Categories/Hub/HubCategory+ClientBehavior.swift
@@ -18,15 +18,19 @@ extension HubCategory: HubCategoryBehavior {
plugin.dispatch(to: channel, payload: payload)
}
- public func listen(to channel: HubChannel,
- eventName: HubPayloadEventName,
- listener: @escaping HubListener) -> UnsubscribeToken {
+ public func listen(
+ to channel: HubChannel,
+ eventName: HubPayloadEventName,
+ listener: @escaping HubListener
+ ) -> UnsubscribeToken {
plugin.listen(to: channel, eventName: eventName, listener: listener)
}
- public func listen(to channel: HubChannel,
- isIncluded filter: HubFilter? = nil,
- listener: @escaping HubListener) -> UnsubscribeToken {
+ public func listen(
+ to channel: HubChannel,
+ isIncluded filter: HubFilter? = nil,
+ listener: @escaping HubListener
+ ) -> UnsubscribeToken {
plugin.listen(to: channel, isIncluded: filter, listener: listener)
}
diff --git a/Amplify/Categories/Hub/HubCategory.swift b/Amplify/Categories/Hub/HubCategory.swift
index d12e45323a..e82135caae 100644
--- a/Amplify/Categories/Hub/HubCategory.swift
+++ b/Amplify/Categories/Hub/HubCategory.swift
@@ -10,7 +10,7 @@
/// between modules and components in your app. Hub enables different categories to
/// communicate with one another when specific events occur, such as authentication
/// events like a user sign-in or notification of a file download.
-final public class HubCategory: Category {
+public final class HubCategory: Category {
enum ConfigurationState {
/// Default configuration at initialization
@@ -87,8 +87,10 @@ final public class HubCategory: Category {
let key = plugin.key
guard !key.isEmpty else {
let pluginDescription = String(describing: plugin)
- let error = HubError.configuration("Plugin \(pluginDescription) has an empty `key`.",
- "Set the `key` property for \(String(describing: plugin))")
+ let error = HubError.configuration(
+ "Plugin \(pluginDescription) has an empty `key`.",
+ "Set the `key` property for \(String(describing: plugin))"
+ )
throw error
}
@@ -102,8 +104,10 @@ final public class HubCategory: Category {
public func getPlugin(for key: PluginKey) throws -> HubCategoryPlugin {
guard let plugin = plugins[key] else {
let keys = plugins.keys.joined(separator: ", ")
- let error = HubError.configuration("No plugin has been added for '\(key)'.",
- "Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
+ let error = HubError.configuration(
+ "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
diff --git a/Amplify/Categories/Hub/HubCategoryBehavior.swift b/Amplify/Categories/Hub/HubCategoryBehavior.swift
index 45b577f670..d969bbface 100644
--- a/Amplify/Categories/Hub/HubCategoryBehavior.swift
+++ b/Amplify/Categories/Hub/HubCategoryBehavior.swift
@@ -23,9 +23,11 @@ public protocol HubCategoryBehavior {
/// - Parameter channel: The channel to listen for messages on
/// - Parameter eventName: Only hub payloads with this event name will be dispatched to the listener
/// - Parameter listener: The closure to invoke with the received message
- func listen(to channel: HubChannel,
- eventName: HubPayloadEventName,
- listener: @escaping HubListener) -> UnsubscribeToken
+ func listen(
+ to channel: HubChannel,
+ eventName: HubPayloadEventName,
+ listener: @escaping HubListener
+ ) -> UnsubscribeToken
/// Listen to Hub messages on a particular channel, optionally filtering message prior to dispatching them
///
@@ -33,9 +35,11 @@ public protocol HubCategoryBehavior {
/// - Parameter filter: If specified, candidate messages will be passed to this closure prior to dispatching to
/// the `listener`. Only messages for which the filter returns `true` will be dispatched.
/// - Parameter listener: The closure to invoke with the received message
- func listen(to channel: HubChannel,
- isIncluded filter: HubFilter?,
- listener: @escaping HubListener) -> UnsubscribeToken
+ func listen(
+ to channel: HubChannel,
+ isIncluded filter: HubFilter?,
+ listener: @escaping HubListener
+ ) -> UnsubscribeToken
/// Removes the listener identified by `token`
/// - Parameter token: The UnsubscribeToken returned by `listen`
diff --git a/Amplify/Categories/Hub/HubChannel.swift b/Amplify/Categories/Hub/HubChannel.swift
index 65fb2286a8..e852315e87 100644
--- a/Amplify/Categories/Hub/HubChannel.swift
+++ b/Amplify/Categories/Hub/HubChannel.swift
@@ -75,8 +75,8 @@ extension HubChannel: Equatable {
}
}
-extension HubChannel {
- public init(from categoryType: CategoryType) {
+public extension HubChannel {
+ init(from categoryType: CategoryType) {
switch categoryType {
case .analytics:
self = .analytics
diff --git a/Amplify/Categories/Hub/HubFilter.swift b/Amplify/Categories/Hub/HubFilter.swift
index afaff5ba77..85cf24c493 100644
--- a/Amplify/Categories/Hub/HubFilter.swift
+++ b/Amplify/Categories/Hub/HubFilter.swift
@@ -11,7 +11,7 @@ import Foundation
public typealias HubFilter = (HubPayload) -> Bool
/// Convenience filters for common filtering use cases
-public struct HubFilters {
+public enum HubFilters {
/// True if all filters evaluate to true
public static func all(filters: HubFilter...) -> HubFilter {
@@ -31,8 +31,8 @@ public struct HubFilters {
/// Returns a HubFilter that is `true` if the event's `context` property has a UUID that matches `operation.id`
/// - Parameter operation: The operation to match
- public static func forOperation
- (_ operation: AmplifyOperation) -> HubFilter {
+ public static func forOperation
+ (_ operation: AmplifyOperation) -> HubFilter {
let operationId = operation.id
let filter: HubFilter = { payload in
guard let context = payload.context as? AmplifyOperationContext else {
diff --git a/Amplify/Categories/Hub/HubPayload.swift b/Amplify/Categories/Hub/HubPayload.swift
index 3c89b0d73c..52b9746a42 100644
--- a/Amplify/Categories/Hub/HubPayload.swift
+++ b/Amplify/Categories/Hub/HubPayload.swift
@@ -24,9 +24,11 @@ public struct HubPayload {
/// AmplifyOperations, this field will be the Operation's associated OperationResult.
public let data: Any?
- public init(eventName: String,
- context: Any? = nil,
- data: Any? = nil) {
+ public init(
+ eventName: String,
+ context: Any? = nil,
+ data: Any? = nil
+ ) {
self.eventName = eventName
self.context = context
self.data = data
diff --git a/Amplify/Categories/Logging/Internal/LoggingCategory+CategoryConfigurable.swift b/Amplify/Categories/Logging/Internal/LoggingCategory+CategoryConfigurable.swift
index 67a9c69899..0d716cb3d2 100644
--- a/Amplify/Categories/Logging/Internal/LoggingCategory+CategoryConfigurable.swift
+++ b/Amplify/Categories/Logging/Internal/LoggingCategory+CategoryConfigurable.swift
@@ -26,9 +26,9 @@ extension LoggingCategory: CategoryConfigurable {
}
try plugin.configure(using: configuration?.plugins[plugin.key])
- self.plugins[plugin.key] = plugin
+ plugins[plugin.key] = plugin
- if plugin.key != AWSUnifiedLoggingPlugin.key, let consolePlugin = try? self.getPlugin(for: AWSUnifiedLoggingPlugin.key) {
+ if plugin.key != AWSUnifiedLoggingPlugin.key, let consolePlugin = try? getPlugin(for: AWSUnifiedLoggingPlugin.key) {
try consolePlugin.configure(using: configuration?.plugins[consolePlugin.key])
}
@@ -57,9 +57,9 @@ extension LoggingCategory: CategoryConfigurable {
}
try plugin.configure(using: amplifyOutputs)
- self.plugins[plugin.key] = plugin
+ plugins[plugin.key] = plugin
- if plugin.key != AWSUnifiedLoggingPlugin.key, let consolePlugin = try? self.getPlugin(for: AWSUnifiedLoggingPlugin.key) {
+ if plugin.key != AWSUnifiedLoggingPlugin.key, let consolePlugin = try? getPlugin(for: AWSUnifiedLoggingPlugin.key) {
try consolePlugin.configure(using: amplifyOutputs)
}
diff --git a/Amplify/Categories/Logging/LoggingCategory.swift b/Amplify/Categories/Logging/LoggingCategory.swift
index b1dbd0e159..e23bba2c81 100644
--- a/Amplify/Categories/Logging/LoggingCategory.swift
+++ b/Amplify/Categories/Logging/LoggingCategory.swift
@@ -8,7 +8,7 @@
import Foundation
/// AWS Amplify writes console logs through Logger. You can use Logger in your apps for the same purpose.
-final public class LoggingCategory: Category {
+public final class LoggingCategory: Category {
enum ConfigurationState {
/// Default configuration at initialization
case `default`
@@ -81,8 +81,10 @@ final public class LoggingCategory: Category {
let key = plugin.key
guard !key.isEmpty else {
let pluginDescription = String(describing: plugin)
- let error = LoggingError.configuration("Plugin \(pluginDescription) has an empty `key`.",
- "Set the `key` property for \(String(describing: plugin))")
+ let error = LoggingError.configuration(
+ "Plugin \(pluginDescription) has an empty `key`.",
+ "Set the `key` property for \(String(describing: plugin))"
+ )
throw error
}
@@ -95,8 +97,10 @@ final public class LoggingCategory: Category {
/// - Returns: The wrapped plugin
public func getPlugin(for key: PluginKey) throws -> LoggingCategoryPlugin {
guard let plugin = plugins.first(where: { $0.key == key})?.value else {
- let error = LoggingError.configuration("No plugin has been added for '\(key)'.",
- "Either add a plugin for '\(key)', or use the installed plugin, which has the key '\(key)'")
+ let error = LoggingError.configuration(
+ "No plugin has been added for '\(key)'.",
+ "Either add a plugin for '\(key)', or use the installed plugin, which has the key '\(key)'"
+ )
throw error
}
return plugin
diff --git a/Amplify/Categories/Notifications/NotificationsCategory.swift b/Amplify/Categories/Notifications/NotificationsCategory.swift
index 02c4122b6f..e0e6371fec 100644
--- a/Amplify/Categories/Notifications/NotificationsCategory.swift
+++ b/Amplify/Categories/Notifications/NotificationsCategory.swift
@@ -19,6 +19,6 @@ public final class NotificationsCategory {
Push
]
- return allSubcategories.filter { $0.isConfigured }
+ return allSubcategories.filter(\.isConfigured)
}
}
diff --git a/Amplify/Categories/Notifications/PushNotifications/PushNotificationsCategory.swift b/Amplify/Categories/Notifications/PushNotifications/PushNotificationsCategory.swift
index 2b81b046d7..7c675fdb10 100644
--- a/Amplify/Categories/Notifications/PushNotifications/PushNotificationsCategory.swift
+++ b/Amplify/Categories/Notifications/PushNotifications/PushNotificationsCategory.swift
@@ -55,7 +55,8 @@ public final class PushNotificationsCategory: Category {
let pluginDescription = String(describing: plugin)
let error = PushNotificationsError.configuration(
"Plugin \(pluginDescription) has an empty `key`.",
- "Set the `key` property for \(String(describing: plugin))")
+ "Set the `key` property for \(String(describing: plugin))"
+ )
throw error
}
@@ -80,7 +81,8 @@ public final class PushNotificationsCategory: Category {
let keys = plugins.keys.joined(separator: ", ")
let error = PushNotificationsError.configuration(
"No plugin has been added for '\(key)'.",
- "Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
+ "Either add a plugin for '\(key)', or use one of the known keys: \(keys)"
+ )
throw error
}
return plugin
diff --git a/Amplify/Categories/Notifications/PushNotifications/Types/PushNotificationsCategory+Types.swift b/Amplify/Categories/Notifications/PushNotifications/Types/PushNotificationsCategory+Types.swift
index 5f2cf0966f..eaf7dc2f6e 100644
--- a/Amplify/Categories/Notifications/PushNotifications/Types/PushNotificationsCategory+Types.swift
+++ b/Amplify/Categories/Notifications/PushNotifications/Types/PushNotificationsCategory+Types.swift
@@ -7,6 +7,6 @@
import Foundation
-extension Notifications {
- public enum Push {}
+public extension Notifications {
+ enum Push {}
}
diff --git a/Amplify/Categories/Notifications/PushNotifications/Types/PushNotificationsCategory+UserInfo.swift b/Amplify/Categories/Notifications/PushNotifications/Types/PushNotificationsCategory+UserInfo.swift
index 4f513bdfbf..ccdfaab613 100644
--- a/Amplify/Categories/Notifications/PushNotifications/Types/PushNotificationsCategory+UserInfo.swift
+++ b/Amplify/Categories/Notifications/PushNotifications/Types/PushNotificationsCategory+UserInfo.swift
@@ -7,12 +7,12 @@
import Foundation
-extension Notifications.Push {
+public extension Notifications.Push {
#if canImport(UIKit)
/// A dictionary that contains information related to the remote notification
- public typealias UserInfo = [AnyHashable: Any]
+ typealias UserInfo = [AnyHashable: Any]
#elseif canImport(AppKit)
/// A dictionary that contains information related to the remote notification
- public typealias UserInfo = [String: Any]
+ typealias UserInfo = [String: Any]
#endif
}
diff --git a/Amplify/Categories/Predictions/Error/PredictionsError+ClientError.swift b/Amplify/Categories/Predictions/Error/PredictionsError+ClientError.swift
index c79bdaa132..27622d4cfb 100644
--- a/Amplify/Categories/Predictions/Error/PredictionsError+ClientError.swift
+++ b/Amplify/Categories/Predictions/Error/PredictionsError+ClientError.swift
@@ -7,8 +7,8 @@
import Foundation
-extension PredictionsError {
- public struct ClientError: Equatable {
+public extension PredictionsError {
+ struct ClientError: Equatable {
public static func == (lhs: PredictionsError.ClientError, rhs: PredictionsError.ClientError) -> Bool {
lhs.description == rhs.description
&& lhs.recoverySuggestion == rhs.recoverySuggestion
diff --git a/Amplify/Categories/Predictions/Error/PredictionsError+ServiceError.swift b/Amplify/Categories/Predictions/Error/PredictionsError+ServiceError.swift
index 4d3393ce89..d84b8e4e1e 100644
--- a/Amplify/Categories/Predictions/Error/PredictionsError+ServiceError.swift
+++ b/Amplify/Categories/Predictions/Error/PredictionsError+ServiceError.swift
@@ -7,8 +7,8 @@
import Foundation
-extension PredictionsError {
- public struct ServiceError: Equatable, @unchecked Sendable {
+public extension PredictionsError {
+ struct ServiceError: Equatable, @unchecked Sendable {
public static func == (lhs: PredictionsError.ServiceError, rhs: PredictionsError.ServiceError) -> Bool {
lhs.description == rhs.description
&& lhs.recoverySuggestion == rhs.recoverySuggestion
@@ -33,8 +33,8 @@ extension PredictionsError {
}
}
-extension PredictionsError.ServiceError {
- public static let translationFailed = Self(
+public extension PredictionsError.ServiceError {
+ static let translationFailed = Self(
description: "No result was found.",
recoverySuggestion: """
Please make sure a text string was sent over and
@@ -42,7 +42,7 @@ extension PredictionsError.ServiceError {
"""
)
- public static let internalServerError = Self(
+ static let internalServerError = Self(
description: "An internal server error occurred.",
recoverySuggestion: """
This shouldn't never happen. There is a possibility that there is a bug if this error persists.
@@ -51,27 +51,27 @@ extension PredictionsError.ServiceError {
"""
)
- public static let detectedLanguageLowConfidence = Self(
+ static let detectedLanguageLowConfidence = Self(
description: "A language was detected but with very low confidence.",
recoverySuggestion: "Please make sure you use one of the available languages."
)
- public static let invalidRequest = Self(
+ static let invalidRequest = Self(
description: "An invalid request was sent.",
recoverySuggestion: "Please check your request and try again."
)
- public static let resourceNotFound = Self(
+ static let resourceNotFound = Self(
description: "The specified resource doesn't exist.",
recoverySuggestion: "Please make sure you configured the resource properly."
)
- public static let textSizeLimitExceeded = Self(
+ static let textSizeLimitExceeded = Self(
description: "The size of the text string exceeded the limit.",
recoverySuggestion: "Please send a shorter text string."
)
- public static let unsupportedLanguagePair = Self(
+ static let unsupportedLanguagePair = Self(
description: "Your target language and source language are an unsupported language pair.",
recoverySuggestion: """
Please ensure the service supports translating from the specified source
@@ -79,22 +79,22 @@ extension PredictionsError.ServiceError {
"""
)
- public static let throttling = Self(
+ static let throttling = Self(
description: "Your rate of request increase is too fast.",
recoverySuggestion: "Slow down your request rate and gradually increase it."
)
- public static let unsupportedLanguage = Self(
+ static let unsupportedLanguage = Self(
description: "The language specified is not currently supported by the service.",
recoverySuggestion: "Choose a new language that is supported."
)
- public static let invalidSampleRate = Self(
+ static let invalidSampleRate = Self(
description: "The specified sample rate is not valid.",
recoverySuggestion: ""
)
- public static let accessDenied = Self(
+ static let accessDenied = Self(
description: "Access denied",
recoverySuggestion: """
Please check that your Cognito IAM role has permissions
diff --git a/Amplify/Categories/Predictions/Models/Attribute.swift b/Amplify/Categories/Predictions/Models/Attribute.swift
index 0948c46ae5..d388cd6b56 100644
--- a/Amplify/Categories/Predictions/Models/Attribute.swift
+++ b/Amplify/Categories/Predictions/Models/Attribute.swift
@@ -7,9 +7,9 @@
import Foundation
-extension Predictions {
+public extension Predictions {
/// Attribute of an entity identified as a result of identify() API
- public struct Attribute {
+ struct Attribute {
public let name: String
public let value: Bool
public let confidence: Double
diff --git a/Amplify/Categories/Predictions/Models/BoundedKeyValue.swift b/Amplify/Categories/Predictions/Models/BoundedKeyValue.swift
index 2bfc072ebb..b49bb59824 100644
--- a/Amplify/Categories/Predictions/Models/BoundedKeyValue.swift
+++ b/Amplify/Categories/Predictions/Models/BoundedKeyValue.swift
@@ -7,11 +7,11 @@
import CoreGraphics
-extension Predictions {
+public extension Predictions {
/// Describes the data extracted as key-value pair in
/// an image/document resulting from identify() API
/// e.g The text "Name: John Doe" present in an image/document
- public struct BoundedKeyValue {
+ struct BoundedKeyValue {
public let key: String
public let value: String
public let isSelected: Bool
diff --git a/Amplify/Categories/Predictions/Models/Celebrity+Metadata.swift b/Amplify/Categories/Predictions/Models/Celebrity+Metadata.swift
index 9ec8bb99b4..2b30975a87 100644
--- a/Amplify/Categories/Predictions/Models/Celebrity+Metadata.swift
+++ b/Amplify/Categories/Predictions/Models/Celebrity+Metadata.swift
@@ -7,9 +7,9 @@
import Foundation
-extension Predictions.Celebrity {
+public extension Predictions.Celebrity {
/// Celebrity metadata identified as a result of identify() API
- public struct Metadata {
+ struct Metadata {
public let name: String
public let identifier: String
public let urls: [URL]
diff --git a/Amplify/Categories/Predictions/Models/Celebrity.swift b/Amplify/Categories/Predictions/Models/Celebrity.swift
index 300955d199..2504a1f24a 100644
--- a/Amplify/Categories/Predictions/Models/Celebrity.swift
+++ b/Amplify/Categories/Predictions/Models/Celebrity.swift
@@ -5,14 +5,14 @@
// SPDX-License-Identifier: Apache-2.0
//
-import Foundation
import CoreGraphics
+import Foundation
-extension Predictions {
+public extension Predictions {
/// Describes a celebrity identified in an image
/// with information about its location(bounding box) and
/// facial features(landmarks)
- public struct Celebrity {
+ struct Celebrity {
public let metadata: Metadata
public let boundingBox: CGRect
public let landmarks: [Landmark]
diff --git a/Amplify/Categories/Predictions/Models/Emotion+Kind.swift b/Amplify/Categories/Predictions/Models/Emotion+Kind.swift
index d109c825a4..2a175de0e2 100644
--- a/Amplify/Categories/Predictions/Models/Emotion+Kind.swift
+++ b/Amplify/Categories/Predictions/Models/Emotion+Kind.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Emotion {
+public extension Predictions.Emotion {
/// Different emotion types returned as a result of
/// identify() API call
- public struct Kind: Equatable, @unchecked Sendable {
+ struct Kind: Equatable, @unchecked Sendable {
let id: UInt8
public static let unknown = Self(id: 0)
diff --git a/Amplify/Categories/Predictions/Models/Emotion.swift b/Amplify/Categories/Predictions/Models/Emotion.swift
index 1f593ccbc4..367db2004e 100644
--- a/Amplify/Categories/Predictions/Models/Emotion.swift
+++ b/Amplify/Categories/Predictions/Models/Emotion.swift
@@ -5,11 +5,11 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
+public extension Predictions {
/// Emotion identified in an entity(faces/celebrities)
/// as a result of identify() API with associated `EmotionType`
/// and confidence value
- public struct Emotion {
+ struct Emotion {
public let emotion: Kind
public let confidence: Double
diff --git a/Amplify/Categories/Predictions/Models/Entity+DetectionResult.swift b/Amplify/Categories/Predictions/Models/Entity+DetectionResult.swift
index c61656c954..21a7032dbf 100644
--- a/Amplify/Categories/Predictions/Models/Entity+DetectionResult.swift
+++ b/Amplify/Categories/Predictions/Models/Entity+DetectionResult.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Entity {
+public extension Predictions.Entity {
/// Describes the result of interpret() API when the analyzed text
/// contains a person/place
- public struct DetectionResult {
+ struct DetectionResult {
public let type: Predictions.Entity.Kind
public let targetText: String
public let score: Float?
diff --git a/Amplify/Categories/Predictions/Models/Entity+Kind.swift b/Amplify/Categories/Predictions/Models/Entity+Kind.swift
index 6d4d839bbf..edf3b8a481 100644
--- a/Amplify/Categories/Predictions/Models/Entity+Kind.swift
+++ b/Amplify/Categories/Predictions/Models/Entity+Kind.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Entity {
+public extension Predictions.Entity {
/// Different entity types detected in a text as a result of
/// interpret() API
- public struct Kind: Equatable, Hashable, @unchecked Sendable {
+ struct Kind: Equatable, Hashable, @unchecked Sendable {
let id: UInt8
public static let unknown = Self(id: 0)
diff --git a/Amplify/Categories/Predictions/Models/Entity+Match.swift b/Amplify/Categories/Predictions/Models/Entity+Match.swift
index c101004b9b..c1e6b3d0e5 100644
--- a/Amplify/Categories/Predictions/Models/Entity+Match.swift
+++ b/Amplify/Categories/Predictions/Models/Entity+Match.swift
@@ -7,10 +7,10 @@
import CoreGraphics
-extension Predictions.Entity {
+public extension Predictions.Entity {
/// Describes the result for an entity matched in an entity collection
/// created on AWS Rekogniton and detected from identify() API call
- public struct Match {
+ struct Match {
public let boundingBox: CGRect
public let metadata: Metadata
@@ -23,8 +23,8 @@ extension Predictions.Entity {
}
}
}
-extension Predictions.Entity.Match {
- public struct Metadata {
+public extension Predictions.Entity.Match {
+ struct Metadata {
public let externalImageId: String?
public let similarity: Double
diff --git a/Amplify/Categories/Predictions/Models/Entity+Metadata.swift b/Amplify/Categories/Predictions/Models/Entity+Metadata.swift
index 6c91db35b8..b81eccf7b3 100644
--- a/Amplify/Categories/Predictions/Models/Entity+Metadata.swift
+++ b/Amplify/Categories/Predictions/Models/Entity+Metadata.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Entity {
- public struct Metadata {
+public extension Predictions.Entity {
+ struct Metadata {
public let confidence: Double
public let pose: Predictions.Pose
diff --git a/Amplify/Categories/Predictions/Models/Entity.swift b/Amplify/Categories/Predictions/Models/Entity.swift
index 273ec38fbf..b5dc15902a 100644
--- a/Amplify/Categories/Predictions/Models/Entity.swift
+++ b/Amplify/Categories/Predictions/Models/Entity.swift
@@ -7,10 +7,10 @@
import CoreGraphics
-extension Predictions {
+public extension Predictions {
/// Result returned as part of identify() API call with
/// `IdentifyAction.detectEntities` type parameter
- public struct Entity {
+ struct Entity {
public let boundingBox: CGRect
public let landmarks: [Landmark]
public let ageRange: ClosedRange?
diff --git a/Amplify/Categories/Predictions/Models/Gender.swift b/Amplify/Categories/Predictions/Models/Gender.swift
index 7521f54e2c..a6917663df 100644
--- a/Amplify/Categories/Predictions/Models/Gender.swift
+++ b/Amplify/Categories/Predictions/Models/Gender.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
+public extension Predictions {
/// Describes gender of an entity identified as a result of
/// identify() API
- public struct Gender: @unchecked Sendable {
+ struct Gender: @unchecked Sendable {
let id: UInt8
public static let unknown = Self(id: 0)
diff --git a/Amplify/Categories/Predictions/Models/GenderAttribute.swift b/Amplify/Categories/Predictions/Models/GenderAttribute.swift
index c7c6849efb..4c658b9b98 100644
--- a/Amplify/Categories/Predictions/Models/GenderAttribute.swift
+++ b/Amplify/Categories/Predictions/Models/GenderAttribute.swift
@@ -7,10 +7,10 @@
import Foundation
-extension Predictions {
+public extension Predictions {
/// Gender of an entity(face/celebrity) identified with
/// associated confidence value
- public struct GenderAttribute {
+ struct GenderAttribute {
public var gender: Gender
public var confidence: Double
diff --git a/Amplify/Categories/Predictions/Models/IdentifiedLine.swift b/Amplify/Categories/Predictions/Models/IdentifiedLine.swift
index eaabadcd72..854f231b9a 100644
--- a/Amplify/Categories/Predictions/Models/IdentifiedLine.swift
+++ b/Amplify/Categories/Predictions/Models/IdentifiedLine.swift
@@ -7,10 +7,10 @@
import CoreGraphics
-extension Predictions {
+public extension Predictions {
/// Describes a line of text identified in an image as a result of
/// identify() API call
- public struct IdentifiedLine: IdentifiedText {
+ struct IdentifiedLine: IdentifiedText {
public let text: String
public let boundingBox: CGRect
public let polygon: Polygon?
diff --git a/Amplify/Categories/Predictions/Models/IdentifiedWord.swift b/Amplify/Categories/Predictions/Models/IdentifiedWord.swift
index 12a3b9d5ef..12e9fccce6 100644
--- a/Amplify/Categories/Predictions/Models/IdentifiedWord.swift
+++ b/Amplify/Categories/Predictions/Models/IdentifiedWord.swift
@@ -7,10 +7,10 @@
import CoreGraphics
-extension Predictions {
+public extension Predictions {
/// Describes a word identified in an image as a result of
/// identify() API call
- public struct IdentifiedWord: IdentifiedText {
+ struct IdentifiedWord: IdentifiedText {
public let text: String
public let boundingBox: CGRect
public let polygon: Polygon?
diff --git a/Amplify/Categories/Predictions/Models/KeyPhrase.swift b/Amplify/Categories/Predictions/Models/KeyPhrase.swift
index 656125ddb4..332983d2c1 100644
--- a/Amplify/Categories/Predictions/Models/KeyPhrase.swift
+++ b/Amplify/Categories/Predictions/Models/KeyPhrase.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
+public extension Predictions {
/// Describes a key phrase identified in a text as
/// a result of interpret() API call
- public struct KeyPhrase {
+ struct KeyPhrase {
public let score: Float?
public let text: String
public let range: Range
diff --git a/Amplify/Categories/Predictions/Models/LabelType.swift b/Amplify/Categories/Predictions/Models/LabelType.swift
index bbd123c77b..3c0027aced 100644
--- a/Amplify/Categories/Predictions/Models/LabelType.swift
+++ b/Amplify/Categories/Predictions/Models/LabelType.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
- public struct LabelType: Equatable, @unchecked Sendable {
+public extension Predictions {
+ struct LabelType: Equatable, @unchecked Sendable {
let id: UInt8
public static let all = Self(id: 0)
diff --git a/Amplify/Categories/Predictions/Models/Landmark.swift b/Amplify/Categories/Predictions/Models/Landmark.swift
index b101f2bd23..7e275e3c5e 100644
--- a/Amplify/Categories/Predictions/Models/Landmark.swift
+++ b/Amplify/Categories/Predictions/Models/Landmark.swift
@@ -7,10 +7,10 @@
import CoreGraphics
-extension Predictions {
+public extension Predictions {
/// Describes the facial feature in a celebrity/entity
/// identified as a result of identify() API
- public struct Landmark {
+ struct Landmark {
public let kind: Kind
public let points: [CGPoint]
@@ -24,9 +24,9 @@ extension Predictions {
}
}
-extension Predictions.Landmark {
+public extension Predictions.Landmark {
/// different types of facial features
- public struct Kind: @unchecked Sendable {
+ struct Kind: @unchecked Sendable {
let id: UInt8
public static let allPoints = Self(id: 0)
diff --git a/Amplify/Categories/Predictions/Models/Language+DetectionResult.swift b/Amplify/Categories/Predictions/Models/Language+DetectionResult.swift
index d31598288e..79635f7434 100644
--- a/Amplify/Categories/Predictions/Models/Language+DetectionResult.swift
+++ b/Amplify/Categories/Predictions/Models/Language+DetectionResult.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Language {
+public extension Predictions.Language {
/// Result describing language identified in a text
/// from interpret() API call
- public struct DetectionResult {
+ struct DetectionResult {
public let languageCode: Predictions.Language
public let score: Double?
diff --git a/Amplify/Categories/Predictions/Models/Language.swift b/Amplify/Categories/Predictions/Models/Language.swift
index 6d53fc30ac..06acd0288c 100644
--- a/Amplify/Categories/Predictions/Models/Language.swift
+++ b/Amplify/Categories/Predictions/Models/Language.swift
@@ -7,9 +7,9 @@
import Foundation
-extension Predictions {
+public extension Predictions {
// swiftlint:disable file_length type_body_length
- public struct Language: Equatable, Decodable, @unchecked Sendable {
+ struct Language: Equatable, Decodable, @unchecked Sendable {
public let code: String
public init(code: String) {
@@ -2396,8 +2396,8 @@ extension Predictions {
}
}
-extension Predictions.Language {
- public init(locale: Locale) {
+public extension Predictions.Language {
+ init(locale: Locale) {
guard let languageCode = locale.languageCode else {
self = .undetermined
return
diff --git a/Amplify/Categories/Predictions/Models/PartOfSpeech+DetectionResult.swift b/Amplify/Categories/Predictions/Models/PartOfSpeech+DetectionResult.swift
index 4104e9db10..a1e23aa397 100644
--- a/Amplify/Categories/Predictions/Models/PartOfSpeech+DetectionResult.swift
+++ b/Amplify/Categories/Predictions/Models/PartOfSpeech+DetectionResult.swift
@@ -7,9 +7,9 @@
import Foundation
-extension Predictions.PartOfSpeech {
+public extension Predictions.PartOfSpeech {
/// Part of speech identified in a text from interpret() API
- public struct DetectionResult {
+ struct DetectionResult {
public let partOfSpeech: Predictions.PartOfSpeech
public let score: Float?
diff --git a/Amplify/Categories/Predictions/Models/PartOfSpeech.swift b/Amplify/Categories/Predictions/Models/PartOfSpeech.swift
index 9a0a3ef9bd..780968e183 100644
--- a/Amplify/Categories/Predictions/Models/PartOfSpeech.swift
+++ b/Amplify/Categories/Predictions/Models/PartOfSpeech.swift
@@ -7,9 +7,9 @@
import Foundation
-extension Predictions {
+public extension Predictions {
/// Part of speech identified in a text from interpret() API
- public struct PartOfSpeech: Equatable, @unchecked Sendable {
+ struct PartOfSpeech: Equatable, @unchecked Sendable {
let description: String
public static let adjective = Self(description: "adjective")
diff --git a/Amplify/Categories/Predictions/Models/Polygon.swift b/Amplify/Categories/Predictions/Models/Polygon.swift
index bb38da8f64..f84ac8fd95 100644
--- a/Amplify/Categories/Predictions/Models/Polygon.swift
+++ b/Amplify/Categories/Predictions/Models/Polygon.swift
@@ -7,8 +7,8 @@
import CoreGraphics
-extension Predictions {
- public struct Polygon {
+public extension Predictions {
+ struct Polygon {
public let points: [CGPoint]
public init(points: [CGPoint]) {
diff --git a/Amplify/Categories/Predictions/Models/Pose.swift b/Amplify/Categories/Predictions/Models/Pose.swift
index 8aa116ba7b..57a0ecdb76 100644
--- a/Amplify/Categories/Predictions/Models/Pose.swift
+++ b/Amplify/Categories/Predictions/Models/Pose.swift
@@ -5,9 +5,9 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
+public extension Predictions {
/// Describes the pose of a person identified in an image from identify() API
- public struct Pose {
+ struct Pose {
public let pitch: Double
public let roll: Double
public let yaw: Double
diff --git a/Amplify/Categories/Predictions/Models/Selection.swift b/Amplify/Categories/Predictions/Models/Selection.swift
index d80fe53343..849104d849 100644
--- a/Amplify/Categories/Predictions/Models/Selection.swift
+++ b/Amplify/Categories/Predictions/Models/Selection.swift
@@ -7,8 +7,8 @@
import CoreGraphics
-extension Predictions {
- public struct Selection {
+public extension Predictions {
+ struct Selection {
public let boundingBox: CGRect
public let polygon: Polygon
public let isSelected: Bool
diff --git a/Amplify/Categories/Predictions/Models/Sentiment+Kind.swift b/Amplify/Categories/Predictions/Models/Sentiment+Kind.swift
index 6df87dc4dd..c5e8ba5a94 100644
--- a/Amplify/Categories/Predictions/Models/Sentiment+Kind.swift
+++ b/Amplify/Categories/Predictions/Models/Sentiment+Kind.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Sentiment {
- public struct Kind: Equatable, Hashable, @unchecked Sendable {
+public extension Predictions.Sentiment {
+ struct Kind: Equatable, Hashable, @unchecked Sendable {
let id: UInt8
public static let unknown = Self(id: 0)
diff --git a/Amplify/Categories/Predictions/Models/Sentiment.swift b/Amplify/Categories/Predictions/Models/Sentiment.swift
index 58a6e2dc70..5869e22aba 100644
--- a/Amplify/Categories/Predictions/Models/Sentiment.swift
+++ b/Amplify/Categories/Predictions/Models/Sentiment.swift
@@ -5,9 +5,9 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
+public extension Predictions {
/// Sentiment Analysis result for Predictions category
- public struct Sentiment {
+ struct Sentiment {
public let predominantSentiment: Kind
public let sentimentScores: [Kind: Double]?
diff --git a/Amplify/Categories/Predictions/Models/SyntaxToken.swift b/Amplify/Categories/Predictions/Models/SyntaxToken.swift
index 56163d7960..b1048766d4 100644
--- a/Amplify/Categories/Predictions/Models/SyntaxToken.swift
+++ b/Amplify/Categories/Predictions/Models/SyntaxToken.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
+public extension Predictions {
/// Describes syntactical information resulting from text interpretation as
/// a result of interpret() API
- public struct SyntaxToken {
+ struct SyntaxToken {
public let tokenId: Int
public let text: String
public let range: Range
diff --git a/Amplify/Categories/Predictions/Models/Table.swift b/Amplify/Categories/Predictions/Models/Table.swift
index 82e9a812dd..06f2bb8acc 100644
--- a/Amplify/Categories/Predictions/Models/Table.swift
+++ b/Amplify/Categories/Predictions/Models/Table.swift
@@ -7,8 +7,8 @@
import CoreGraphics
-extension Predictions {
- public struct Table {
+public extension Predictions {
+ struct Table {
public var rows: Int
public var columns: Int
public var cells: [Cell]
@@ -21,8 +21,8 @@ extension Predictions {
}
}
-extension Predictions.Table {
- public struct Cell {
+public extension Predictions.Table {
+ struct Cell {
public let text: String
/// The location of the recognized text on the image. It includes an axis-aligned,
diff --git a/Amplify/Categories/Predictions/Models/TextFormatType.swift b/Amplify/Categories/Predictions/Models/TextFormatType.swift
index 601d2809d5..92f19c6150 100644
--- a/Amplify/Categories/Predictions/Models/TextFormatType.swift
+++ b/Amplify/Categories/Predictions/Models/TextFormatType.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
+public extension Predictions {
/// Describes different text formats passed a type parameter
/// to identify().
- public struct TextFormatType: Equatable, @unchecked Sendable {
+ struct TextFormatType: Equatable, @unchecked Sendable {
let id: UInt8
public static let all = Self(id: 0)
diff --git a/Amplify/Categories/Predictions/Models/Voice.swift b/Amplify/Categories/Predictions/Models/Voice.swift
index 5cc73e87f4..ab72988572 100644
--- a/Amplify/Categories/Predictions/Models/Voice.swift
+++ b/Amplify/Categories/Predictions/Models/Voice.swift
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions {
- public struct Voice {
+public extension Predictions {
+ struct Voice {
public let id: String
public init(id: String) {
diff --git a/Amplify/Categories/Predictions/PredictionsCategory+ClientBehavior.swift b/Amplify/Categories/Predictions/PredictionsCategory+ClientBehavior.swift
index f9628e0b7d..1b0c2c2830 100644
--- a/Amplify/Categories/Predictions/PredictionsCategory+ClientBehavior.swift
+++ b/Amplify/Categories/Predictions/PredictionsCategory+ClientBehavior.swift
@@ -16,8 +16,8 @@ extension PredictionsCategory: PredictionsCategoryBehavior {
try await plugin.identify(request, in: image, options: options)
}
- public func convert(
- _ request: Predictions.Convert.Request,
+ public func convert(
+ _ request: Predictions.Convert.Request,
options: Options? = nil
) async throws -> Output {
try await plugin.convert(request, options: options)
diff --git a/Amplify/Categories/Predictions/PredictionsCategory.swift b/Amplify/Categories/Predictions/PredictionsCategory.swift
index 7a47cdfd82..2964626bfd 100644
--- a/Amplify/Categories/Predictions/PredictionsCategory.swift
+++ b/Amplify/Categories/Predictions/PredictionsCategory.swift
@@ -7,7 +7,7 @@
public enum Predictions {}
-final public class PredictionsCategory: Category {
+public final class PredictionsCategory: Category {
public let categoryType = CategoryType.predictions
diff --git a/Amplify/Categories/Predictions/PredictionsCategoryBehavior.swift b/Amplify/Categories/Predictions/PredictionsCategoryBehavior.swift
index c5639603fa..264a675627 100644
--- a/Amplify/Categories/Predictions/PredictionsCategoryBehavior.swift
+++ b/Amplify/Categories/Predictions/PredictionsCategoryBehavior.swift
@@ -26,8 +26,8 @@ public protocol PredictionsCategoryBehavior {
/// - request:
/// - options:
/// - Returns:
- func convert(
- _ request: Predictions.Convert.Request,
+ func convert(
+ _ request: Predictions.Convert.Request,
options: Options?
) async throws -> Output
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+Lift.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+Lift.swift
index 9f450dc17c..38bd3e3d18 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+Lift.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+Lift.swift
@@ -7,9 +7,9 @@
import Foundation
-extension Predictions.Convert.Request.Kind {
+public extension Predictions.Convert.Request.Kind {
@_spi(PredictionsConvertRequestKind)
- public struct Lift<
+ struct Lift<
SpecificInput,
GenericInput,
SpecificOptions,
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Options.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Options.swift
index b1a6f3a526..34d69c4aeb 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Options.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Options.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Convert.SpeechToText {
- public struct Options {
+public extension Predictions.Convert.SpeechToText {
+ struct Options {
/// The default NetworkPolicy for the operation. The default value will be `auto`.
public let defaultNetworkPolicy: DefaultNetworkPolicy
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Request.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Request.swift
index d20625afc6..e7e15606a2 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Request.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Request.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Convert.SpeechToText {
- public struct Request {
+public extension Predictions.Convert.SpeechToText {
+ struct Request {
/// The text to synthesize to speech
public let speechToText: URL
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Result.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Result.swift
index bc597ec3ba..fdcbdc5c62 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText+Result.swift
@@ -7,10 +7,10 @@
import Foundation
-extension Predictions.Convert.SpeechToText {
+public extension Predictions.Convert.SpeechToText {
/// Results are mapped to SpeechToTextResult when convert() API is
/// called to convert a text to audio
- public struct Result {
+ struct Result {
/// Resulting string from speech to text conversion
public let transcription: String
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText.swift
index c60d368d9c..d73222aa2c 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+SpeechToText.swift
@@ -7,16 +7,16 @@
import Foundation
-extension Predictions.Convert {
- public enum SpeechToText {}
+public extension Predictions.Convert {
+ enum SpeechToText {}
}
-extension Predictions.Convert.Request where
+public extension Predictions.Convert.Request where
Input == URL,
Options == Predictions.Convert.SpeechToText.Options,
Output == AsyncThrowingStream {
- public static func speechToText(url: URL) -> Self {
+ static func speechToText(url: URL) -> Self {
.init(input: url, kind: .speechToText(.lift))
}
}
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Options.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Options.swift
index 59d0ea93f1..e05c3e594f 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Options.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Options.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Convert.TextToSpeech {
- public struct Options {
+public extension Predictions.Convert.TextToSpeech {
+ struct Options {
/// The default NetworkPolicy for the operation. The default value will be `auto`.
public let defaultNetworkPolicy: DefaultNetworkPolicy
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Request.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Request.swift
index fa38c3fd28..6b5f61ae2d 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Request.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Request.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Convert.TextToSpeech {
- public struct Request {
+public extension Predictions.Convert.TextToSpeech {
+ struct Request {
/// The text to synthesize to speech
public let textToSpeech: String
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Result.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Result.swift
index d1ee3019d5..91fec245dc 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech+Result.swift
@@ -7,10 +7,10 @@
import Foundation
-extension Predictions.Convert.TextToSpeech {
+public extension Predictions.Convert.TextToSpeech {
/// Results are mapped to TextToSpeechResult when convert() API is
/// called to convert a text to audio
- public struct Result {
+ struct Result {
/// Resulting audio from text to speech conversion
public let audioData: Data
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech.swift
index d15b83fa4b..a76d055201 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+TextToSpeech.swift
@@ -7,16 +7,16 @@
import Foundation
-extension Predictions.Convert {
- public enum TextToSpeech {}
+public extension Predictions.Convert {
+ enum TextToSpeech {}
}
-extension Predictions.Convert.Request where
+public extension Predictions.Convert.Request where
Input == String,
Options == Predictions.Convert.TextToSpeech.Options,
Output == Predictions.Convert.TextToSpeech.Result {
- public static func textToSpeech(_ text: String) -> Self {
+ static func textToSpeech(_ text: String) -> Self {
.init(input: text, kind: .textToSpeech(.lift))
}
}
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Options.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Options.swift
index b26b75d33e..a8f28ed6c2 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Options.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Options.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Convert.TranslateText {
- public struct Options {
+public extension Predictions.Convert.TranslateText {
+ struct Options {
/// The default NetworkPolicy for the operation. The default value will be `auto`.
public let defaultNetworkPolicy: DefaultNetworkPolicy
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Request.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Request.swift
index e8832751e5..2f8080ef27 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Request.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Request.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Convert.TranslateText {
- public struct Request {
+public extension Predictions.Convert.TranslateText {
+ struct Request {
/// The text to translate.
public let textToTranslate: String
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Result.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Result.swift
index 920eff83ba..ed49a4fb06 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText+Result.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Convert.TranslateText {
+public extension Predictions.Convert.TranslateText {
/// Results are mapped to TranslateTextResult when convert() API is
/// called to translate a text into another language
- public struct Result {
+ struct Result {
/// Translated text
public let text: String
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText.swift b/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText.swift
index 572bb3c46c..22554b8e42 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert+TranslateText.swift
@@ -7,16 +7,16 @@
import Foundation
-extension Predictions.Convert {
- public enum TranslateText {}
+public extension Predictions.Convert {
+ enum TranslateText {}
}
-extension Predictions.Convert.Request where
+public extension Predictions.Convert.Request where
Input == (String, Predictions.Language?, Predictions.Language?),
Options == Predictions.Convert.TranslateText.Options,
Output == Predictions.Convert.TranslateText.Result {
- public static func translateText(
+ static func translateText(
_ text: String,
from: Predictions.Language? = nil,
to: Predictions.Language? = nil
diff --git a/Amplify/Categories/Predictions/Request/Convert/Convert.swift b/Amplify/Categories/Predictions/Request/Convert/Convert.swift
index 019bf95255..4f69f8682a 100644
--- a/Amplify/Categories/Predictions/Request/Convert/Convert.swift
+++ b/Amplify/Categories/Predictions/Request/Convert/Convert.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions {
- public enum Convert {
+public extension Predictions {
+ enum Convert {
public struct Request {
public let input: Input
@_spi(PredictionsConvertRequestKind)
@@ -17,32 +17,32 @@ extension Predictions {
}
}
-extension Predictions.Convert.Request {
+public extension Predictions.Convert.Request {
@_spi(PredictionsConvertRequestKind)
- public enum Kind {
+ enum Kind {
public typealias BidirectionalLift = ((T) -> U, (U) -> T)
case textToSpeech(
Lift<
- String, Input,
- Predictions.Convert.TextToSpeech.Options?, Options?,
- Predictions.Convert.TextToSpeech.Result, Output
+ String, Input,
+ Predictions.Convert.TextToSpeech.Options?, Options?,
+ Predictions.Convert.TextToSpeech.Result, Output
>
)
case speechToText(
Lift<
- URL, Input,
- Predictions.Convert.SpeechToText.Options?, Options?,
- AsyncThrowingStream, Output
+ URL, Input,
+ Predictions.Convert.SpeechToText.Options?, Options?,
+ AsyncThrowingStream, Output
>
)
case textToTranslate(
Lift<
- (String, Predictions.Language?, Predictions.Language?), Input,
- Predictions.Convert.TranslateText.Options?, Options?,
- Predictions.Convert.TranslateText.Result, Output
+ (String, Predictions.Language?, Predictions.Language?), Input,
+ Predictions.Convert.TranslateText.Options?, Options?,
+ Predictions.Convert.TranslateText.Result, Output
>
)
}
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Celebrities+Result.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Celebrities+Result.swift
index 8da0888ba6..77d3a23747 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Celebrities+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Celebrities+Result.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Identify.Celebrities {
+public extension Predictions.Identify.Celebrities {
/// Results are mapped to IdentifyCelebritiesResult when .detectCelebrity in passed in the type: field
/// in identify() API
- public struct Result {
+ struct Result {
public let celebrities: [Predictions.Celebrity]
public init(celebrities: [Predictions.Celebrity]) {
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Celebrities.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Celebrities.swift
index 996159d0ef..0f57203620 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Celebrities.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Celebrities.swift
@@ -7,12 +7,12 @@
import Foundation
-extension Predictions.Identify {
- public enum Celebrities {}
+public extension Predictions.Identify {
+ enum Celebrities {}
}
-extension Predictions.Identify.Request where Output == Predictions.Identify.Celebrities.Result {
- nonisolated(unsafe) public static let celebrities = Self(
+public extension Predictions.Identify.Request where Output == Predictions.Identify.Celebrities.Result {
+ nonisolated(unsafe) static let celebrities = Self(
kind: .detectCelebrities(.lift)
)
}
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Document.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Document.swift
index d8217fdc6a..8137ab7693 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Document.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Document.swift
@@ -7,12 +7,12 @@
import Foundation
-extension Predictions.Identify {
- public enum DocumentText {}
+public extension Predictions.Identify {
+ enum DocumentText {}
}
-extension Predictions.Identify.Request where Output == Predictions.Identify.DocumentText.Result {
- public static func textInDocument(textFormatType: Predictions.TextFormatType) -> Self {
+public extension Predictions.Identify.Request where Output == Predictions.Identify.DocumentText.Result {
+ static func textInDocument(textFormatType: Predictions.TextFormatType) -> Self {
.init(kind: .detectTextInDocument(textFormatType, .lift))
}
}
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+DocumentText+Result.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+DocumentText+Result.swift
index 430667429a..bc7a4b6686 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+DocumentText+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+DocumentText+Result.swift
@@ -5,11 +5,11 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Identify.DocumentText {
+public extension Predictions.Identify.DocumentText {
/// Results are mapped to IdentifyDocumentTextResult when .form, .table
/// or .all is passed for .detectText in the type: field
/// in identify() API
- public struct Result {
+ struct Result {
public let fullText: String
public let words: [Predictions.IdentifiedWord]
public let rawLineText: [String]
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Entities+Result.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Entities+Result.swift
index ba7d2041ea..e90d6d26a3 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Entities+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Entities+Result.swift
@@ -5,11 +5,11 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Identify.Entities {
+public extension Predictions.Identify.Entities {
/// Results are mapped to IdentifyEntitiesResult when .detectEntities is
/// passed to type: field in identify() API and general entities like facial features, landmarks etc.
/// are needed to be detected
- public struct Result {
+ struct Result {
/// List of 'Entity' as a result of Identify query
public let entities: [Predictions.Entity]
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Entities.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Entities.swift
index 9673de9d54..342669e030 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Entities.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Entities.swift
@@ -7,12 +7,12 @@
import Foundation
-extension Predictions.Identify {
- public enum Entities {}
+public extension Predictions.Identify {
+ enum Entities {}
}
-extension Predictions.Identify.Request where Output == Predictions.Identify.Entities.Result {
- nonisolated(unsafe) public static let entities = Self(
+public extension Predictions.Identify.Request where Output == Predictions.Identify.Entities.Result {
+ nonisolated(unsafe) static let entities = Self(
kind: .detectEntities(.lift)
)
}
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+EntityMatches+Result.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+EntityMatches+Result.swift
index 57878acea0..d2e19ff011 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+EntityMatches+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+EntityMatches+Result.swift
@@ -5,11 +5,11 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Identify.EntityMatches {
+public extension Predictions.Identify.EntityMatches {
/// Results are mapped to IdentifyEntityMatchesResult when .detectEntities is
/// passed to type: field in identify() API and matches from your Rekognition Collection
/// need to be identified
- public struct Result {
+ struct Result {
/// List of matched `Entity.Match`
public let entities: [Predictions.Entity.Match]
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+EntityMatches.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+EntityMatches.swift
index c31b8f1ed8..4f03705d68 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+EntityMatches.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+EntityMatches.swift
@@ -7,12 +7,12 @@
import Foundation
-extension Predictions.Identify {
- public enum EntityMatches {}
+public extension Predictions.Identify {
+ enum EntityMatches {}
}
-extension Predictions.Identify.Request where Output == Predictions.Identify.EntityMatches.Result {
- public static func entitiesFromCollection(withID collectionID: String) -> Self {
+public extension Predictions.Identify.Request where Output == Predictions.Identify.EntityMatches.Result {
+ static func entitiesFromCollection(withID collectionID: String) -> Self {
.init(kind: .detectEntitiesCollection(collectionID, .lift))
}
}
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Labels+Result.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Labels+Result.swift
index 245a2f14da..b5eb9e4e8d 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Labels+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Labels+Result.swift
@@ -7,10 +7,10 @@
import CoreGraphics
-extension Predictions.Identify.Labels {
+public extension Predictions.Identify.Labels {
/// Results are mapped to IdentifyLabelsResult when .labels in passed to .detectLabels
/// in the type: field in identify() API
- public struct Result {
+ struct Result {
public let labels: [Predictions.Label]
public let unsafeContent: Bool?
@@ -21,9 +21,9 @@ extension Predictions.Identify.Labels {
}
}
-extension Predictions {
+public extension Predictions {
/// Describes a real world object (e.g., chair, desk) identified in an image
- public struct Label {
+ struct Label {
public let name: String
public let metadata: Metadata?
public let boundingBoxes: [CGRect]?
@@ -39,7 +39,7 @@ extension Predictions {
}
}
- public struct Parent {
+ struct Parent {
public let name: String
public init(name: String) {
@@ -48,8 +48,8 @@ extension Predictions {
}
}
-extension Predictions.Label {
- public struct Metadata {
+public extension Predictions.Label {
+ struct Metadata {
public let confidence: Double
public let parents: [Predictions.Parent]?
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Labels.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Labels.swift
index 51698b50b9..a3724c9a27 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Labels.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Labels.swift
@@ -7,12 +7,12 @@
import Foundation
-extension Predictions.Identify {
- public enum Labels {}
+public extension Predictions.Identify {
+ enum Labels {}
}
-extension Predictions.Identify.Request where Output == Predictions.Identify.Labels.Result {
- public static func labels(type: Predictions.LabelType = .labels) -> Self {
+public extension Predictions.Identify.Request where Output == Predictions.Identify.Labels.Result {
+ static func labels(type: Predictions.LabelType = .labels) -> Self {
.init(kind: .detectLabels(type, .lift))
}
}
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Lift.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Lift.swift
index 09654ba367..a6cb98736f 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Lift.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Lift.swift
@@ -7,8 +7,8 @@
import Foundation
-extension Predictions.Identify.Request.Kind {
- public struct Lift<
+public extension Predictions.Identify.Request.Kind {
+ struct Lift<
SpecificOutput,
GenericOutput
> {
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Text+Result.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Text+Result.swift
index 39f66964a0..1bfb2858e5 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Text+Result.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Text+Result.swift
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: Apache-2.0
//
-extension Predictions.Identify.Text {
+public extension Predictions.Identify.Text {
/// Results are mapped to IdentifyTextResult when .plain is passed for .detectText in the type: field
/// in identify() API
- public struct Result {
+ struct Result {
public let fullText: String?
public let words: [Predictions.IdentifiedWord]?
public let rawLineText: [String]?
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify+Text.swift b/Amplify/Categories/Predictions/Request/Identify/Identify+Text.swift
index 34417a99c0..19ad078980 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify+Text.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify+Text.swift
@@ -7,12 +7,12 @@
import Foundation
-extension Predictions.Identify {
- public enum Text {}
+public extension Predictions.Identify {
+ enum Text {}
}
-extension Predictions.Identify.Request where Output == Predictions.Identify.Text.Result {
- nonisolated(unsafe) public static let text = Self(
+public extension Predictions.Identify.Request where Output == Predictions.Identify.Text.Result {
+ nonisolated(unsafe) static let text = Self(
kind: .detectText(.lift)
)
}
diff --git a/Amplify/Categories/Predictions/Request/Identify/Identify.swift b/Amplify/Categories/Predictions/Request/Identify/Identify.swift
index d033b26965..cacd204ae5 100644
--- a/Amplify/Categories/Predictions/Request/Identify/Identify.swift
+++ b/Amplify/Categories/Predictions/Request/Identify/Identify.swift
@@ -9,8 +9,8 @@ import Foundation
/// Identification criteria provided to
/// type parameter in identify() API
-extension Predictions {
- public enum Identify {
+public extension Predictions {
+ enum Identify {
public struct Request