Skip to content

feat: add auto-pagination iterators for list endpoints#7

Open
harley-poly wants to merge 2 commits into
mainfrom
harley/sdk-pagination
Open

feat: add auto-pagination iterators for list endpoints#7
harley-poly wants to merge 2 commits into
mainfrom
harley/sdk-pagination

Conversation

@harley-poly

@harley-poly harley-poly commented Jun 2, 2026

Copy link
Copy Markdown
Member

summary

adds iterate() async generators that transparently walk all pages so callers no longer hand-roll cursor/offset logic:

  • offset-paginated resources: events.iterate(), markets.iterate(), series.iterate() (page until a short page is returned).
  • cursor-paginated feed: portfolio.iterateActivities() (follow nextCursor until eof or an empty cursor).
  • shared helpers live in src/pagination.ts (paginateOffset / paginateCursor).

positions are intentionally not iterated (the endpoint returns the full set in one response).

test plan

  • pnpm lint (biome)
  • pnpm typecheck / pnpm build
  • pnpm test (135 passed; new tests/pagination.test.ts covers offset paging until short/empty page and cursor paging until eof/no-next-cursor)

Note

Low Risk
Additive client-side helpers and new optional APIs; existing list/activities calls are unchanged, with tests covering termination edge cases.

Overview
Adds lazy auto-pagination so callers can stream full list results without manual offset / cursor loops.

New shared helpers in src/pagination.ts: paginateOffset (stops on a short or empty page; clamps non-positive page size) and paginateCursor (follows nextCursor until eof or missing cursor). events, markets, and series gain iterate(params?, pageSize?); portfolio gains authenticated iterateActivities(params?). README documents for await usage. tests/pagination.test.ts covers multi-page offset iteration, empty-page stop, and cursor/eof behavior.

Reviewed by Cursor Bugbot for commit fa162c6. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 44a5ccd. Configure here.

Comment thread src/pagination.ts Outdated
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.

2 participants