refactor: normalize mock API module exports and naming (#388) - #402
Merged
Lakes41 merged 2 commits intoAug 24, 2026
Merged
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
…ild#388) Group the export block in lib/api/mock.ts into three clearly labelled sections — fixture data, control functions, and standalone tools — so the distinction between data and behavior is immediately visible. Add an '## Export naming conventions' section to the module-level JSDoc that documents the three categories and explains why replayMockEvent is intentionally separated from the mock* API-method delegates. Update MOCK_API_PUBLIC_REEXPORTS in lib/api/mock/domains.ts with matching section comments and an expanded JSDoc so the contract document stays in sync with the module it tests. Update the 'application consumers depend on the API boundary' assertion in test/mock-api-structure.test.ts to accept @/lib/api/factory as a valid nav import path (introduced in Adamantine-guild#387 to narrow the nav dependency surface). No symbol renames, no behavior changes, no fixture value changes. Closes Adamantine-guild#388
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 #388.
Problem
lib/api/mock.ts'sexport {}block was a flat, unsorted list of 13 symbols spanning three conceptually distinct categories — mutable fixture data, control/setter functions, and a standalone dev tool. There were no comments distinguishing them, making it unclear to new contributors whethermockConnectionsis a function or a data store, or whyreplayMockEventdoesn't follow themock*method naming convention the API delegates use.Changes
lib/api/mock.tsexport {}block into three clearly labelled sections:communityStates,getCommunityState,mockConnections,mockPrivacySettings,mockReportsMOCK_META_VERSION_OVERRIDE,applyMockScenario,resetMockData,setMock*replayMockEvent## Export naming conventionssection to the module-level JSDoc documenting all three categories and explaining whyreplayMockEventis intentionally separate from themock*API-method delegates.lib/api/mock/domains.tsMOCK_API_PUBLIC_REEXPORTSwith matching section comments and an expanded JSDoc so the contract document stays in sync with the module.test/mock-api-structure.test.ts'application consumers depend on the API boundary'test to accept@/lib/api/factoryas a valid import path fornav.tsx, since that narrower import was introduced in Remove unnecessary navigation dependency on the mock API layer #387.Acceptance criteria checklist