Skip to content

Add helper for building paginated response objects from a cursor and result set #605

Description

@Chucks1093

Summary

Every paginated endpoint constructs its response envelope (items, next_cursor, has_more) independently. A shared helper should produce a consistent paginated response shape so all endpoints return the same structure.

Scope

  • Add buildPaginatedResponse<T>(items: T[], limit: number, cursorFn: (item: T) => string): PaginatedResponse<T>
  • If items.length > limit, set has_more: true, pop the extra item, and set next_cursor to the cursor of the last kept item
  • If items.length <= limit, set has_more: false and next_cursor: null
  • Add unit tests for: exact limit, over limit, under limit, empty result set

Acceptance Criteria

  • has_more: true and cursor set when results exceed limit
  • has_more: false and cursor null when results at or below limit
  • Empty result set returns has_more: false, empty items, null cursor
  • Extra item not included in returned items array

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions