Difficulty
Intermediate
Type
type-safety, structure, consistency
Background
The reported parser failure occurs in the analytics-related section of lib/api/mock.ts, including the MOCK_ANALYTICS_SUMMARY.resourceAccess return path. Large inline mock structures are difficult to maintain when their data shape and access functions are not clearly separated.
Problem
Analytics mock data and the functions consuming it are tightly coupled inside the large mock module, increasing the chance that structural or shape changes will introduce failures that are only discovered when Next.js compiles the module.
Expected outcome
Give the analytics mock data an explicit, reusable TypeScript shape and separate its data definition from access logic.
Suggested implementation
Locate MOCK_ANALYTICS_SUMMARY and the functions that return its analytics fields. Define or reuse an appropriate TypeScript type based on the actual object shape. Move the analytics fixture and related access functions into a focused module if consistent with the repository's existing structure. Ensure resourceAccess and its sibling fields remain type-safe.
Acceptance criteria
MOCK_ANALYTICS_SUMMARY has an explicit type or is inferred from a clearly typed fixture.
resourceAccess is type-checked against the analytics summary shape.
- Analytics access functions cannot silently return incompatible structures.
- Existing consumers receive the same data shape.
- The modified modules compile without TypeScript errors.
Likely affected files/directories
lib/api/mock.ts
lib/api/ analytics-related modules
Difficulty
Intermediate
Type
type-safety, structure, consistency
Background
The reported parser failure occurs in the analytics-related section of
lib/api/mock.ts, including theMOCK_ANALYTICS_SUMMARY.resourceAccessreturn path. Large inline mock structures are difficult to maintain when their data shape and access functions are not clearly separated.Problem
Analytics mock data and the functions consuming it are tightly coupled inside the large mock module, increasing the chance that structural or shape changes will introduce failures that are only discovered when Next.js compiles the module.
Expected outcome
Give the analytics mock data an explicit, reusable TypeScript shape and separate its data definition from access logic.
Suggested implementation
Locate
MOCK_ANALYTICS_SUMMARYand the functions that return its analytics fields. Define or reuse an appropriate TypeScript type based on the actual object shape. Move the analytics fixture and related access functions into a focused module if consistent with the repository's existing structure. EnsureresourceAccessand its sibling fields remain type-safe.Acceptance criteria
MOCK_ANALYTICS_SUMMARYhas an explicit type or is inferred from a clearly typed fixture.resourceAccessis type-checked against the analytics summary shape.Likely affected files/directories
lib/api/mock.tslib/api/analytics-related modules