Skip to content

fix(native-dart)!: one shared AuthActionInput for every Auth block - #1599

Merged
ekjotmultani merged 15 commits into
mainfrom
fix/native-auth-action-input-name
Nov 19, 2026
Merged

ekjotmultani merged 15 commits into
mainfrom
fix/native-auth-action-input-name

Conversation

@ekjotmultani

Copy link
Copy Markdown
Contributor

Problem

The Dart codegen gives each Auth block namespace its own setAuthState input type, named after the namespace. Every Auth block's state machine takes the same input shape, but an app with two Auth blocks gets two unrelated types, so code written for one doesn't work with the other. The type name is public API, so it has to settle before Dart 1.0.0.

Changes

  • core: the OpenRPC spec now names a type alias that is a union, through an x-blocks-type-name hint. Generators can then emit one shared type instead of an inline one per method. Patch changeset.
  • Dart codegen: every Auth block's setAuthState takes one shared AuthActionInput. Goldens regenerated in all three SDKs, and the example e2e uses AuthActionInput.fromJson.
  • Swift does the same in fix(swift)!: name generated enums and unions after their schema, share AuthActionInput, make models Sendable #1572. Kotlin nests a separate SetAuthState.Input per namespace, which doesn't rename when a block is added, so Kotlin is unchanged here.

Breaking

For Dart apps: the per-namespace setAuthState input classes are replaced by AuthActionInput. Listed under ## Unreleased in the codegen CHANGELOG, for 1.0.0.

Validation

  • core extract-ts-types and generate-spec tests; lint, lint:deps, scripts/sink-guards.
  • check-live-auth-fixtures against the live Auth block (fixtures 18, 23, 37 and the setAuthState methods match).
  • Codegen tests and fixture checks in Dart, Swift and Kotlin; Dart e2e against test-apps/native-bindings.

Merge notes

Checklist

  • PR description included
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f4c0b58

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-blocks/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

ekjotmultani and others added 3 commits November 17, 2026 21:58
An inline oneOf for a union declared as a type alias now carries
x-blocks-type-name with the alias name, so native codegen can name the
union after it. The union stays inline; generators that don't read the
key are unaffected.
Codegen names a param union after its x-blocks-type-name, so every Auth
namespace's setAuthState input is AuthActionInput instead of the first
namespace's <Ns>SetAuthStateInput. Adding a second Auth block no longer
renames the input. The old name stays as a deprecated typedef. When another
type already has the name, the union keeps the old name.

Refreshes fixtures 18 and 23 from the live Auth block, adds fixture 44 with
two Auth namespaces, and regenerates the Dart, Swift and Kotlin goldens. With
the hint in the spec, Swift now declares the shared AuthActionInput for
fixtures 18 and 44, and its codegen tests that read fixture 18 expect it. The
example's sign-up e2e uses AuthActionInput, and the sink-guard allowlist
entry for the toString literal moves with its line.
A generic alias's symbol is the generic, so Result<string> and
Result<number>, and TS utility types such as Partial<Action>, all got the
generic's name in x-blocks-type-name. Write the key only for a non-generic
alias.
…by key

- A union the spec names keeps the arm and nested type names its old name
  gave it, so a name that doesn't end in Input renames nothing else.
- Escape $ in the deprecated alias message (Map$, $Action).
- Of distinct unions given one name, the one with the smallest canonical
  key keeps it, so spec order doesn't move the name.
Of union parameters of different shapes given one x-blocks-type-name, the
shape of the one with the smallest <method>#param:<name> key may take the
name, matching the Dart generator.
# Conflicts:
#	scripts/sink-guards/codegen.test.mjs
Fixture 23's spec loses the SignInResult type name, since SignInResult<O>
is a generic alias. Fixture 44's Dart golden picks up main's single Api
suffix for namespace classes.
thisisabhash
thisisabhash previously approved these changes Nov 19, 2026
…n-input-name

# Conflicts:
#	scripts/sink-guards/codegen.test.mjs
Two namespaces' copies of one spec-named union take their arm names from each namespace's old name, so when the param isn't `input` and an arm nests an enum, the copies don't merge and one falls back. The warning now says so instead of naming another type.
…n-input-name

# Conflicts:
#	native/codegen-fixtures/23-cognito-nested-unions/dart/client.dart
#	native/codegen-fixtures/23-cognito-nested-unions/kotlin/Types.kt
#	native/codegen-fixtures/23-cognito-nested-unions/swift/Api.swift
#	native/codegen-fixtures/23-cognito-nested-unions/swift/Models.swift
#	native/dart/packages/blocks_codegen/CHANGELOG.md
#	native/dart/packages/blocks_codegen/lib/src/generator.dart
#	native/swift/Tests/BlocksCodegenTests/SendableModelTests.swift
#	scripts/sink-guards/codegen.test.mjs

This branch had an error being deployed

1 failed and 1 inactive deployments
e2e — b384a069 Deployed Nov 19, 2026 by ekjotmultani via E2E Teardown Verify #7301
agent-bench — b384a069 Deployed Nov 19, 2026 by ekjotmultani via bench / summary #6351
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