* Clamps the requested page size to the endpoint's valid range and to the number * of posts still needed under the cap. The user-tweets, mentions, and liked-tweets * endpoints require `max_results` ≥ 5; only bookmarks accepts ≥ 1. We always request * at least the endpoint minimum (over-fetch on t
(mode: SyncMode, remaining: number)
| 335 | * at least the endpoint minimum (over-fetch on the final page is trimmed afterward). |
| 336 | */ |
| 337 | function resolvePageSize(mode: SyncMode, remaining: number): number { |
| 338 | const floor = mode === 'bookmarks' ? 1 : MIN_PAGE_SIZE |
| 339 | if (remaining <= 0) return POSTS_PER_PAGE |
| 340 | return Math.max(floor, Math.min(POSTS_PER_PAGE, remaining)) |
| 341 | } |
| 342 | |
| 343 | export const xConnector: ConnectorConfig = { |
| 344 | ...xConnectorMeta, |