Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: kickoff release #3638

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ extension APICategory: CategoryConfigurable {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
for plugin in Array(plugins.values) {
try plugin.configure(using: amplifyOutputs)
}
isConfigured = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ extension AnalyticsCategory: CategoryConfigurable {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
for plugin in Array(plugins.values) {
try plugin.configure(using: amplifyOutputs)
}
isConfigured = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ extension AuthCategory: CategoryConfigurable {
func configure(using amplifyConfiguration: AmplifyConfiguration) throws {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
for plugin in Array(plugins.values) {
try plugin.configure(using: amplifyOutputs)
}
isConfigured = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ extension DataStoreCategory: CategoryConfigurable {
}
}

func configure(using amplifyConfiguration: AmplifyOutputsData) throws {
try configureFirstWithEmptyConfiguration()
}

func configure(using configuration: CategoryConfiguration?) throws {
guard !isConfigured else {
let error = ConfigurationError.amplifyAlreadyConfigured(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ extension GeoCategory: CategoryConfigurable {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
for plugin in Array(plugins.values) {
try plugin.configure(using: amplifyOutputs)
}
isConfigured = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@ extension HubCategory: CategoryConfigurable {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
guard configurationState.get() != .configured else {
let error = ConfigurationError.amplifyAlreadyConfigured(
"\(categoryType.displayName) has already been configured.",
"Remove the duplicate call to `Amplify.configure()`"
)
throw error
}

for plugin in Array(plugins.values) {
try plugin.configure(using: amplifyOutputs)
}
configurationState.set(.configured)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,30 @@ extension LoggingCategory: CategoryConfigurable {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
let plugin: LoggingCategoryPlugin
switch configurationState {
case .default:
// Default plugin is already assigned, and no configuration is applicable, exit early
configurationState = .configured
return
case .pendingConfiguration(let pendingPlugin):
plugin = pendingPlugin
case .configured:
let error = ConfigurationError.amplifyAlreadyConfigured(
"\(categoryType.displayName) has already been configured.",
"Remove the duplicate call to `Amplify.configure()`"
)
throw error
}

try plugin.configure(using: amplifyOutputs)
self.plugins[plugin.key] = plugin

if plugin.key != AWSUnifiedLoggingPlugin.key, let consolePlugin = try? self.getPlugin(for: AWSUnifiedLoggingPlugin.key) {
try consolePlugin.configure(using: amplifyOutputs)
}

configurationState = .configured
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ extension PushNotificationsCategory: CategoryConfigurable {
func configure(using amplifyConfiguration: AmplifyConfiguration) throws {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
for plugin in Array(plugins.values) {
try plugin.configure(using: amplifyOutputs)
}
isConfigured = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ extension PredictionsCategory: CategoryConfigurable {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
for plugin in Array(plugins.values) {
try plugin.configure(using: amplifyOutputs)
}
isConfigured = true
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ extension StorageCategory: CategoryConfigurable {
try configure(using: categoryConfiguration(from: amplifyConfiguration))
}

func configure(using amplifyOutputs: AmplifyOutputsData) throws {
for plugin in Array(plugins.values) {
try plugin.configure(using: amplifyOutputs)
}
isConfigured = true
}
}
4 changes: 2 additions & 2 deletions Amplify/Core/Configuration/AmplifyConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ extension Amplify {

/// Notifies all hub channels that Amplify is configured, in case any plugins need to be notified of the end of the
/// configuration phase (e.g., to set up cross-channel dependencies)
private static func notifyAllHubChannels() {
static func notifyAllHubChannels() {
let payload = HubPayload(eventName: HubPayload.EventName.Amplify.configured)
for channel in HubChannel.amplifyChannels {
Hub.plugins.values.forEach { $0.dispatch(to: channel, payload: payload) }
Expand Down Expand Up @@ -210,7 +210,7 @@ extension Amplify {
}

//// Indicates is the runtime is for SwiftUI Previews
private static var isRunningForSwiftUIPreviews: Bool {
static var isRunningForSwiftUIPreviews: Bool {
ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != nil
}

Expand Down
Loading
Loading