Skip to content

feat(core): make AmplifyOutputsData and all nested types public - #4190

Merged
harsh62 merged 7 commits into
mainfrom
feat/public-amplify-outputs-phase2
Apr 16, 2026
Merged

feat(core): make AmplifyOutputsData and all nested types public#4190
harsh62 merged 7 commits into
mainfrom
feat/public-amplify-outputs-phase2

Conversation

@harsh62

@harsh62 harsh62 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Issue: #4030

Summary

  • Remove @_spi(InternalAmplifyConfiguration) from AmplifyOutputsData and all 20+ nested structs, enums, and type aliases
  • Make all internal initializers public (AmplifyOutputsData, Auth, Geo, Storage, Storage.Bucket)
  • Keep version as an internal implementation detail — the public init defaults to the current supported schema version
  • Update ~50 import statements across source and test files to remove SPI annotations
  • Add 14 unit tests verifying the public API works without SPI imports

Customers can now programmatically construct and inspect configuration using just import Amplify:

import Amplify

let config = AmplifyOutputsData(
    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)

Test plan

  • 14 new public API tests pass (AmplifyOutputsDataPublicAPITests)
  • 289 core Amplify tests pass
  • 2761 plugin tests pass (0 failures from this change)
  • swift build passes
  • swiftformat --lint passes (0 files need formatting)

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)
@harsh62
harsh62 requested a review from a team as a code owner April 9, 2026 19:41
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

codecov Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.21429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.71%. Comparing base (9a91027) to head (d35a38d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...mplify/Core/Configuration/AmplifyOutputsData.swift 98.21% 1 Missing ⚠️
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     
Flag Coverage Δ
API_plugin_unit_test 68.39% <ø> (-0.03%) ⬇️
AWSPluginsCore 68.07% <ø> (ø)
Amplify 47.55% <98.21%> (+0.74%) ⬆️
Amplify_Foundation_Bridge_unit_test 62.28% <ø> (ø)
Amplify_Foundation_unit_test 67.64% <ø> (ø)
Analytics_plugin_unit_test 83.43% <ø> (ø)
Auth_plugin_unit_test 72.48% <ø> (+0.13%) ⬆️
DataStore_plugin_unit_test 81.72% <ø> (-1.01%) ⬇️
Firehose_plugin_unit_test 53.15% <ø> (ø)
Geo_plugin_unit_test 73.39% <ø> (ø)
Kinesis_plugin_unit_test 52.17% <ø> (ø)
Logging_plugin_unit_test 64.86% <ø> (ø)
Predictions_plugin_unit_test 33.89% <ø> (ø)
PushNotifications_plugin_unit_test 85.66% <ø> (ø)
RecordCache_unit_test 76.40% <ø> (ø)
Storage_plugin_unit_test 78.10% <ø> (ø)
unit_tests 66.71% <98.21%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread Amplify/Core/Configuration/AmplifyOutputsData.swift
Comment thread Amplify/Core/Configuration/AmplifyOutputsData.swift
Comment thread AmplifyTests/CoreTests/AmplifyOutputsDataPublicAPITests.swift Outdated
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)
@harsh62

harsh62 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all review feedback in the latest commit:

version (line 25): It's already internal (no access modifier = internal in Swift). Used only for Codable JSON decoding. The public init defaults to currentVersion internally.

Public initializers: Added public inits to all nested structs: PasswordPolicy, OAuth, Analytics, AmazonPinpoint, DataCategory, Notifications, Geo.Maps, Geo.SearchIndices, Geo.GeofenceCollections, and AmazonLocationServiceConfig.

Tests with optional values: Added 5 new tests with fully populated optional values: testConstructAuthWithAllFields (now includes passwordPolicy + oauth), testConstructAnalyticsConfig, testConstructDataCategoryConfig, testConstructNotificationsConfig, testConstructGeoWithMapsAndIndices. Total: 18 public API tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants