Skip to content

Conversation

@pavel-mareev
Copy link

@pavel-mareev pavel-mareev commented Nov 11, 2025

  • Adds TS support for cursor based pagination for assets and entries

@pavel-mareev pavel-mareev self-assigned this Nov 11, 2025
@pavel-mareev pavel-mareev force-pushed the capi-2342 branch 5 times, most recently from 3b7c099 to 032d7d8 Compare November 17, 2025 13:04
@pavel-mareev pavel-mareev changed the title wip: cursor based pagination [CAPI-2342] feat: cursor based pagination for assets and entries [CAPI-2342] Nov 17, 2025
@pavel-mareev pavel-mareev marked this pull request as ready for review November 17, 2025 15:37
@pavel-mareev pavel-mareev requested a review from a team as a code owner November 17, 2025 15:37
Comment on lines 15 to 17
// omit pagePrev and pageNext if the value is falsy
...(pagePrev ? { pagePrev } : null),
...(pageNext ? { pageNext } : null),

Choose a reason for hiding this comment

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

Suggested change
// omit pagePrev and pageNext if the value is falsy
...(pagePrev ? { pagePrev } : null),
...(pageNext ? { pageNext } : null),
...(!!pagePrev && { pagePrev }),
...(!!pageNext && { pageNext }),

*/
export type CursorPaginatedCollection<T = unknown> = CollectionBase<T> & CursorPagination

export type WithCursorPagination = { cursor: true }

Choose a reason for hiding this comment

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

Just wondering does this take into account that you can have just ?pageNext=abc and you will get a cursor based result?

Copy link
Author

Choose a reason for hiding this comment

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

This type is only for internal use in CollectionForQuery generic. Since we use the same makeGetEntries function for both offset and cursor pagination it's needed to type the response for cursor pagination properly here. Actually I think I can remove and inline it to avoid confusion 👍

In the context of getEntriesWithCursor method we return cursor paginated collection anyways, even when pageNext or pagePrev is not provided.

michaelphamcf
michaelphamcf previously approved these changes Dec 4, 2025
Copy link

@michaelphamcf michaelphamcf left a comment

Choose a reason for hiding this comment

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

Itty bitty typo I think. Otherwise, Looks good to me.

FixedPagedOptions

type CursorPaginationOptions = {
type ConcenptsCursorPaginationOptions = {

Choose a reason for hiding this comment

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

Suggested change
type ConcenptsCursorPaginationOptions = {
type ConceptsCursorPaginationOptions = {

Typo?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, thank you! Fixed

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.

5 participants