refactor(auth): consolidate attacher context types onto a shared base#48
Merged
Merged
Conversation
The seven exported auth attacher context types plus several inline callback ctxs each re-typed the same `view: Required<ViewOptions>` + `flags: Record<string, unknown>` pair, copy-pasting the identical `view` JSDoc ~11 times. Introduce internal `AttachContextBase` and `WithAccount<TAccount>` aliases in `types.ts` (not re-exported) and derive the named + view-bearing inline ctxs from them. Pure type-alias refactor: structural shapes are byte-for-byte identical, so the public API surface, README, and runtime behaviour are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
doistbot
reviewed
May 23, 2026
Member
doistbot
left a comment
There was a problem hiding this comment.
This PR nicely addresses the roadmap item by consolidating the auth attacher context types onto a shared base, reducing duplication across the module. The structural refactor effectively streamlines the codebase while preserving the public API surface and runtime behavior. A few minor details could be smoothed out, specifically restoring some context-specific JSDoc comments that were dropped during the consolidation, applying the newly added WithAccount helper more consistently, and removing a comment that merely restates the code.
Restore the login flags-stripping invariant and the remove-ctx account doc that the base-type rebase had dropped, reuse WithAccount in the status fetchLive ctx, and drop the WithAccount alias comment that restated the code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 0.24.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
Several auth attacher context types re-typed the same
view: Required<ViewOptions>+flags: Record<string, unknown>pair, copy-pasting the identicalviewJSDoc ~11 times. Theaccountattachers shipped in #45/#46 each added another bespoke ctx repeating it.AttachContextBase(theview+flagspair, with the previously copy-pastedviewJSDoc in one place) andWithAccount<TAccount>tosrc/auth/types.ts. Not re-exported fromsrc/auth/index.ts— they have no consumer-facing use, so the named ctx types stay the only public API.AttachLoginContext,AttachLogoutContext,AttachLogoutRevokeContext,AttachStatusContext,AttachAccountList/Current/RemoveContext) and the 4 inline callback ctxs that carryview+flags(statusfetchLive/onNotAuthenticated, accountonDefaultSet/currentonNotAuthenticated) from the base. Flags-only ctxs (renderJson, loginresolveScopes) left as-is.Pure type-alias refactor: structural shapes are byte-for-byte identical, so the public API surface, README, and runtime behaviour are unchanged (net −20 LOC).
Test plan
npm run type-check— clean (the real proof shapes are preserved: attach-fn bodies + re-export chain still typecheck)npm test— 498 passednpm run check— oxlint + oxfmt clean onsrc/