refactor: narrow nav.tsx API import to remove mock barrel dependency (#387) - #401
Merged
Lakes41 merged 1 commit intoAug 24, 2026
Conversation
…ild#387) Introduce lib/api/factory.ts as a dedicated narrow entry-point that exports only getApi (and the version helpers it re-exports). Move the getApi implementation there from lib/api/index.ts. Update components/nav.tsx to import getApi from @/lib/api/factory instead of the full @/lib/api barrel. The barrel previously pulled in every mock-utility re-export (resetMockData, applyMockScenario, etc.) via mock-boundary, meaning a syntax error in mock.ts could prevent the navigation component from compiling. lib/api/index.ts is updated to re-export getApi from ./factory so all existing consumers of @/lib/api are unaffected. Closes Adamantine-guild#387
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
Fixes #387.
Problem
components/nav.tsximportedgetApifrom@/lib/api(the barrel). The barrel (lib/api/index.ts) re-exportedresetMockData,applyMockScenario,replayMockEvent, etc. frommock-boundary, which in turn imported from the largelib/api/mock.tsaggregation module. This meant any syntax error inmock.tscould prevent the navigation component from compiling, even though the nav only needsgetApi.Solution
New
lib/api/factory.ts— narrow module that exports onlygetApi(and the version helpers it already re-exported). Imports only whatgetApistrictly needs:config,LiveAccessApi, andcreateMockAccessApifrommock-boundary.Updated
components/nav.tsx— importsgetApifrom@/lib/api/factoryinstead of the full barrel. The nav's dependency graph no longer includes the mock-utility re-exports.Updated
lib/api/index.ts— the barrel now re-exportsgetApifrom./factory. All existing consumers of@/lib/apiare unaffected — zero callsite changes needed outside nav.Acceptance criteria checklist
components/nav.tsxis demonstrably used (getApiis called in theuseQueryqueryFn)resetMockData,applyMockScenario, etc. are no longer in its import graph)getApifactory, same runtime logic)@/lib/apicontinue to work via the barrel re-export