Skip to content

refactor: narrow nav.tsx API import to remove mock barrel dependency (#387) - #401

Merged
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
MarcusDavidG:fix/387-nav-mock-api-dependency
Aug 24, 2026
Merged

refactor: narrow nav.tsx API import to remove mock barrel dependency (#387)#401
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
MarcusDavidG:fix/387-nav-mock-api-dependency

Conversation

@MarcusDavidG

Copy link
Copy Markdown
Contributor

Summary

Fixes #387.

Problem

components/nav.tsx imported getApi from @/lib/api (the barrel). The barrel (lib/api/index.ts) re-exported resetMockData, applyMockScenario, replayMockEvent, etc. from mock-boundary, which in turn imported from the large lib/api/mock.ts aggregation module. This meant any syntax error in mock.ts could prevent the navigation component from compiling, even though the nav only needs getApi.

Solution

  1. New lib/api/factory.ts — narrow module that exports only getApi (and the version helpers it already re-exported). Imports only what getApi strictly needs: config, LiveAccessApi, and createMockAccessApi from mock-boundary.

  2. Updated components/nav.tsx — imports getApi from @/lib/api/factory instead of the full barrel. The nav's dependency graph no longer includes the mock-utility re-exports.

  3. Updated lib/api/index.ts — the barrel now re-exports getApi from ./factory. All existing consumers of @/lib/api are unaffected — zero callsite changes needed outside nav.

Acceptance criteria checklist

  • Every API import in components/nav.tsx is demonstrably used (getApi is called in the useQuery queryFn)
  • The component does not depend on mock implementation details (resetMockData, applyMockScenario, etc. are no longer in its import graph)
  • Dependency graph avoids unnecessary coupling to the large mock module
  • Navigation behavior remains unchanged (same getApi factory, same runtime logic)
  • No other consumers broken — all other files importing from @/lib/api continue to work via the barrel re-export

…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
@Lakes41
Lakes41 merged commit 56f22d1 into Adamantine-guild:main Aug 24, 2026
1 check passed
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.

Remove unnecessary navigation dependency on the mock API layer

2 participants