Skip to content

Feat/helper paginated list - #530

Merged
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
Unclebaffa:feat/helper-paginated-list
Jun 27, 2026
Merged

Feat/helper paginated list#530
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
Unclebaffa:feat/helper-paginated-list

Conversation

@Unclebaffa

Copy link
Copy Markdown
Contributor

Summary

I've successfully implemented the buildListResponse helper for consistent paginated list response envelopes. Here's what was delivered:

✅ Acceptance Criteria Met

  1. Returns correct envelope shape with all meta fields

    • ✅ Helper returns { data, meta: { total, hasMore, nextCursor } } structure
    • ✅ All meta fields are properly included in the response
  2. nextCursor absent when not provided

    • ✅ When nextCursor is undefined, it's completely omitted from the output (not serialized)
    • ✅ Test: "omits nextCursor from output when undefined" verifies this
    • ✅ Test: "does not serialize nextCursor when not provided" confirms JSON serialization behavior
  3. Empty data array returns correct shape

    • ✅ Empty arrays return { data: [], meta: { total: 0, hasMore: false } }
    • ✅ Multiple tests cover empty array scenarios
    • ✅ Test: "returns correct shape for empty data array" validates the structure

📦 Deliverables

  1. Helper Implementation (src/utils/list-response.utils.ts)

    • Generic buildListResponse<T>() function
    • TypeScript interfaces: ListResponseMeta and ListResponse<T>
    • Comprehensive JSDoc documentation with examples
  2. Comprehensive Unit Tests (src/utils/list-response.utils.test.ts)

    • 20 test cases covering all scenarios:
      • With cursor (cursor pagination)
      • Without cursor (offset pagination)
      • Empty data arrays
      • Type safety
      • Meta field validation
      • Edge cases
  3. Documentation (docs/list-response-helper.md)

    • Usage guide with practical examples
    • Migration guide showing before/after patterns
    • Response shape examples
    • Key behaviors explained

The helper is ready to be used across all paginated list endpoints to ensure consistent response envelope shapes!

Closes #508

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Unclebaffa Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093
Chucks1093 merged commit 13ce27b into accesslayerorg:main Jun 27, 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.

Add helper for building paginated list response envelope with metadata fields

2 participants