This topic was automatically generated from Slack. You can find the original thread here.
I’m migrating to SDK v2 and running into an issue with pagination.
In the previous version, I fetched a paginated list of Pipedream apps using pipedream.listApps, stored the endCursor, and reused it when users requested the next page.
In the new TypeScript SDK, the pipedream.apps.list method returns a Page<App> object. This includes a getNextPage method, but no longer provides the cursor value directly in the response. This is problematic for my use case since I need to handle multiple asynchronous requests and rely on passing explicit cursors.
What’s confusing is that the method still accepts a cursor (after) parameter—but the response itself doesn’t expose the cursor anymore.
export interface AppsListRequest {
/**** The cursor to start from for pagination */
after?: string;
Could you clarify how I should handle this situation in SDK v2? Is there a recommended way to access or persist cursors when managing pagination across asynchronous requests?
I tried getting it from the rawResponse object included in the response object, but it does not contain the actual response body for some reason, only headers and useless data:
Just so you know, since the pageInfo attribute is not public (although the PageInfo type is exposed), and also the PageT type is not exposed, I had to do this to both infer the PageT type and obtain the pageInfo attribute:
import type { PageInfo } from '@pipedream/sdk'
// the Page type is returned from several methods in the SDK but its type is not exposed for some reason, so I have to define it myself
export type PageT = {
data: T[]
getNextPage: () => PromisePage<T>
hasNextPage: () => boolean
[Symbol.asyncIterator]: () => AsyncIteratorT, void, any
}
export function getPageInfoT(page: PageT): PageInfo {
// @ts-expect-error - the pageInfo is included in the response but not public for some reason
return page.response.pageInfo
}