feat: add cursor-based pagination to bookmarks command

- Add --cursor option to resume pagination from a specific point
- Change --max-pages to enable pagination independently
- Return nextCursor in JSON output for subsequent requests

feat: add cursor param and nextCursor to pagination methods

not modifying max-pages
This commit is contained in:
Leon Ho
2026-01-04 23:42:34 +00:00
committed by Peter Steinberger
parent c4fa04e0b2
commit 3442ba84c6
4 changed files with 91 additions and 19 deletions
+67 -10
View File
@@ -297,21 +297,78 @@ export function findTweetInInstructions(
result?: GraphqlTweetResult;
};
};
item?: {
itemContent?: {
tweet_results?: {
result?: GraphqlTweetResult;
};
};
};
items?: Array<{
item?: {
itemContent?: {
tweet_results?: {
result?: GraphqlTweetResult;
};
};
};
itemContent?: {
tweet_results?: {
result?: GraphqlTweetResult;
};
};
content?: {
itemContent?: {
tweet_results?: {
result?: GraphqlTweetResult;
};
};
};
}>;
};
}>;
}>
| undefined,
tweetId: string,
) {
if (!instructions) {
return undefined;
}
id: string,
options: MapTweetResultOptions,
): TweetData | undefined {
for (const instruction of instructions ?? []) {
for (const entry of instruction.entries ?? []) {
const content = entry.content;
if (!content) {
continue;
}
for (const instruction of instructions) {
for (const entry of instruction.entries || []) {
const result = entry.content?.itemContent?.tweet_results?.result;
if (result?.rest_id === tweetId) {
return result;
const itemTweet = content.itemContent?.tweet_results?.result;
const itemResult = itemTweet ? unwrapTweetResult(itemTweet) : undefined;
if (itemResult?.rest_id === id) {
return mapTweetResult(itemResult, options);
}
const innerItemTweet = content.item?.itemContent?.tweet_results?.result;
const innerItemResult = innerItemTweet ? unwrapTweetResult(innerItemTweet) : undefined;
if (innerItemResult?.rest_id === id) {
return mapTweetResult(innerItemResult, options);
}
for (const item of content.items ?? []) {
const itemTweetResult = item.item?.itemContent?.tweet_results?.result;
const itemResult = itemTweetResult ? unwrapTweetResult(itemTweetResult) : undefined;
if (itemResult?.rest_id === id) {
return mapTweetResult(itemResult, options);
}
const itemContentResult = item.itemContent?.tweet_results?.result;
const itemContentTweet = itemContentResult ? unwrapTweetResult(itemContentResult) : undefined;
if (itemContentTweet?.rest_id === id) {
return mapTweetResult(itemContentTweet, options);
}
const itemEntryResult = item.content?.itemContent?.tweet_results?.result;
const itemEntryTweet = itemEntryResult ? unwrapTweetResult(itemEntryResult) : undefined;
if (itemEntryTweet?.rest_id === id) {
return mapTweetResult(itemEntryTweet, options);
}
}
}
}