feat(core): make AmplifyOutputsData and all nested types public - #4190
Conversation
Remove @_spi(InternalAmplifyConfiguration) from AmplifyOutputsData and
all nested structs, enums, and type aliases. Make all internal
initializers public so customers can programmatically construct
configuration without requiring a special SPI import.
This enables:
- Programmatic configuration construction for testing and dynamic
environments using just `import Amplify`
- Runtime inspection of resolved configuration (e.g., reading the
configured region or user pool ID)
- Direct use of `Amplify.configure(_: AmplifyOutputsData)` without SPI
Usage examples:
import Amplify
// Construct configuration programmatically
let config = AmplifyOutputsData(
version: "1",
auth: .init(
awsRegion: "us-east-1",
userPoolId: "us-east-1_abc",
userPoolClientId: "client123"
),
storage: .init(
awsRegion: "us-east-1",
bucketName: "my-bucket"
)
)
try Amplify.configure(config)
// Inspect resolved configuration
let outputs = try AmplifyOutputs.amplifyOutputs.resolveConfiguration()
print(outputs.auth?.userPoolId)
print(outputs.storage?.bucketName)
The version field is an implementation detail of the JSON schema decoding. Customers constructing config programmatically do not need to specify it. The public init now defaults to the current supported schema version internally.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4190 +/- ##
==========================================
- Coverage 66.74% 66.71% -0.04%
==========================================
Files 1150 1150
Lines 43617 43672 +55
==========================================
+ Hits 29113 29135 +22
- Misses 14504 14537 +33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Address review feedback: - Add public initializers to PasswordPolicy, OAuth, Analytics, AmazonPinpoint, DataCategory, Notifications, Geo.Maps, Geo.SearchIndices, Geo.GeofenceCollections, and Geo.Maps.AmazonLocationServiceConfig - Keep internal init with version parameter for backward compatibility - Add tests with populated optional values (passwordPolicy, oauth, analytics, data, notifications, geo with maps/indices/collections)
|
Addressed all review feedback in the latest commit: version (line 25): It's already Public initializers: Added public inits to all nested structs: Tests with optional values: Added 5 new tests with fully populated optional values: |
Issue: #4030
Summary
@_spi(InternalAmplifyConfiguration)fromAmplifyOutputsDataand all 20+ nested structs, enums, and type aliasesAmplifyOutputsData,Auth,Geo,Storage,Storage.Bucket)versionas an internal implementation detail — the public init defaults to the current supported schema versionCustomers can now programmatically construct and inspect configuration using just
import Amplify:Test plan
AmplifyOutputsDataPublicAPITests)swift buildpassesswiftformat --lintpasses (0 files need formatting)