feat(types): consume the response envelopes and role matching from types 0.4.0 - #118
Merged
Conversation
Five response bodies were declared by hand because the package shipped schemas for them without exported type aliases. Types 0.4.0 exports an alias for every schema, and guards it with a test upstream, so OAuthProvidersResult, CredentialUpdateResult, and the three organization envelope results become aliases like the rest of the wire contract. The shapes are identical, so nothing changes for adopters, and the dependency stays types-only with no runtime import. Refs fells-code/seamless-auth-types#10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #117, closing both gaps it left open. fells-code/seamless-auth-types#10 shipped in types 0.4.0, and 0.3.0 added a Zod-free entry point for role matching.
1. Response envelopes (types 0.4.0)
Five response bodies stayed hand-written in #117 because the package shipped schemas for them without exported type aliases. 0.4.0 exports a
z.inferalias for every schema (all 43 that lacked one) and guards it with a test upstream, so these become aliases like the rest of the wire contract:OAuthProvidersResultCredentialUpdateResultOrganizationResultOrganizationMembersResultOrganizationMembershipResultI checked each upstream shape against the local declaration before swapping; they match, so this part is a no-op for adopters.
src/client/createSeamlessAuthClient.tsno longer imports the local domain types at all.2. Role matching (types 0.3.0)
hasScopedRole()androleGrantsAccess()were implemented here and again upstream, so the SDK could drift from the rules the API enforces.src/scopedRoles.tsnow re-exports the package'srole/matchingsubpath and stays the SDK's export boundary, so adopters keep importing both from@seamless-auth/react.Behavior was compared, not assumed. A temporary differential test ran both implementations across 476,100 granted/required role pairs from a generated corpus (including whitespace, casing,
:*suffixes, and empty segments), plus non-array and mixed-type inputs tohasScopedRole. Zero disagreements. The existing scoped-role tests now cover the shared implementation.The runtime import, and keeping it honest
This is the package's only runtime import, so the bundle purity that made this dependency safe in #117 is now enforced rather than documented:
@seamless-auth/typesbarrel and allows type imports. I verified it fires by flipping oneimport typeback to a value import.@seamless-auth/types/role/matchingis declared external in the rollup config, so it resolves at the consumer rather than being inlined.ESM-only is not a new constraint for adopters: this package already publishes ESM with an
importcondition and norequire, exactly like the dependency.Jest is the one place that needed work, because its CommonJS resolver will not follow the package's ESM subpath exports.
jest.config.tsmaps the subpath directly and exempts the package fromtransformIgnorePatterns. WideningcustomExportConditionswas the obvious fix and the wrong one: it pushes unrelated dependencies onto ESM builds the test runtime cannot parse, which is recorded in the config comment and in AGENTS.md so it does not get retried.Validation
npm run lint,npm run typecheck,npm run format:check,npm test -- --runInBand(269 passing across 31 suites),npm run build, andnpm run check-npm-buildall pass.