Skip to content

Extract shared pagination type and refactor response types#127

Merged
enko merged 1 commit intomainfrom
claude/implement-issue-126-Nq2i8
Mar 9, 2026
Merged

Extract shared pagination type and refactor response types#127
enko merged 1 commit intomainfrom
claude/implement-issue-126-Nq2i8

Conversation

@enko
Copy link
Copy Markdown
Member

@enko enko commented Mar 9, 2026

Summary

This PR extracts pagination metadata into a shared type and refactors response types across the codebase for better type reusability and consistency. The changes improve type safety and reduce duplication in API response definitions.

Key Changes

  • New shared pagination type: Created PaginationInfo interface in packages/shared/src/pagination.ts to standardize pagination metadata across paginated API responses
  • Extracted response types in auth: Added dedicated response types (UserWithPreferencesResponse, PreferencesResponse, ForgotPasswordResponse, HealthCheckResponse) in packages/shared/src/auth.ts for better API documentation and type safety
  • Refactored collective types: Extracted CollectiveTypeSummary and RelationshipTypeSummary interfaces to reduce inline type definitions and improve reusability
  • Refactored friend types: Extracted FriendPreview interface for use in dashboard and summary views
  • Refactored circle types: Extracted CircleReorderItemSchema to avoid inline schema duplication in circle reorder requests
  • Updated backend routes: Applied new response types in auth.ts and health.ts routes
  • Updated frontend stores: Replaced local PaginationState interfaces with shared PaginationInfo type in collectives and encounters stores
  • Updated frontend API: Extracted UpcomingDatesOptions interface for better API function documentation

Implementation Details

  • All pagination-related responses now use the centralized PaginationInfo type from the shared package
  • Response types are now explicitly defined and exported, making API contracts clearer
  • Type summaries (e.g., CollectiveTypeSummary, RelationshipTypeSummary) follow a consistent naming pattern
  • Frontend stores now import pagination type from shared package instead of defining locally, reducing duplication

https://claude.ai/code/session_01Ggmu9YzZBUq3ETBuiyXcXV

Extract inline object types into properly named, reusable types across the
codebase to improve readability and enable safer refactoring.

Shared package:
- PaginationInfo: consolidates pagination fields from EncounterListResponse
  and CollectiveListResponse into packages/shared/src/pagination.ts
- CollectiveTypeSummary: type summary in collective list items
- RelationshipTypeSummary: relationship type metadata in preview items
- FriendPreview: friend object within upcoming dates
- CircleReorderItem: extracted from inline CircleReorderSchema

Auth types:
- UserWithPreferencesResponse: GET /api/auth/me response
- PreferencesResponse: PATCH /api/auth/preferences response
- ForgotPasswordResponse: POST /api/auth/forgot-password response
- HealthCheckResponse: GET /api/health response

Frontend:
- UpcomingDatesOptions: parameters for upcoming dates queries
- Replace duplicate PaginationState interfaces in encounters and
  collectives stores with shared PaginationInfo

Backend:
- Update auth routes to use shared response types
- Update health route to use HealthCheckResponse

Closes #126

https://claude.ai/code/session_01Ggmu9YzZBUq3ETBuiyXcXV
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 9, 2026

🔍 Automated Code Review

Commit 26bdaee
Reviewed 2026-03-09T00:00:00Z
Status ✅ Approved

Findings

Severity Count
🚨 Critical 0
⚠️ Important 0
💡 Suggestion 1

AGENTS.md Compliance

  • ✅ No any types — all new types use explicit interfaces
  • ✅ All new exports wired through src/index.ts (pagination.ts added to barrel)
  • ✅ Descriptive naming conventions followed (PaginationInfo, CollectiveTypeSummary, FriendPreview, etc.)
  • ✅ Interfaces used for object shapes as required by shared package guidelines
  • ✅ TypeScript strict mode compatible

Summary

Clean, well-scoped refactoring that eliminates duplicated inline type definitions. Extracting PaginationInfo into packages/shared/src/pagination.ts correctly centralises pagination metadata, and the frontend stores now properly import from the shared package instead of redefining locally. The extraction of CollectiveTypeSummary, RelationshipTypeSummary, FriendPreview, and CircleReorderItemSchema all follow the project's naming conventions and reduce duplication without changing runtime behaviour.

One minor suggestion: HealthCheckResponse was added to packages/shared/src/auth.ts (line ~111), but it describes the /api/health endpoint rather than anything auth-related. If the shared package grows, consider moving it to a dedicated health.ts file (or a general api.ts) to keep auth.ts focused on authentication concerns. Not a blocker.


🤖 Automated review by Claude Code • View CI Run

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Code review passed. No critical or important issues found. See summary comment for details.

@enko enko merged commit a3f88eb into main Mar 9, 2026
5 checks passed
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 9, 2026

🎉 This PR is included in version 2.65.9 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants