* Builds the query string for the active listing endpoint. `pageSize` is the * per-request `max_results`, already clamped to the endpoint's valid range and * to any remaining cap. `exclude` and date-range params are only attached for * the modes whose endpoint supports them.
( sourceConfig: Record<string, unknown>, mode: SyncMode, pageSize: number, cursor?: string )
| 296 | * the modes whose endpoint supports them. |
| 297 | */ |
| 298 | function buildListParams( |
| 299 | sourceConfig: Record<string, unknown>, |
| 300 | mode: SyncMode, |
| 301 | pageSize: number, |
| 302 | cursor?: string |
| 303 | ): Record<string, string> { |
| 304 | const params: Record<string, string> = { |
| 305 | max_results: String(pageSize), |
| 306 | 'tweet.fields': TWEET_FIELDS, |
| 307 | expansions: 'author_id', |
| 308 | 'user.fields': 'name,username', |
| 309 | } |
| 310 | |
| 311 | if (EXCLUDE_CAPABLE_MODES.has(mode)) { |
| 312 | const includeReplies = readBooleanOption(sourceConfig.includeReplies, false) |
| 313 | const includeRetweets = readBooleanOption(sourceConfig.includeRetweets, false) |
| 314 | const exclude: string[] = [] |
| 315 | if (!includeRetweets) exclude.push('retweets') |
| 316 | if (!includeReplies) exclude.push('replies') |
| 317 | if (exclude.length > 0) params.exclude = exclude.join(',') |
| 318 | } |
| 319 | |
| 320 | if (DATE_RANGE_CAPABLE_MODES.has(mode)) { |
| 321 | const startTime = readTrimmed(sourceConfig.startTime) |
| 322 | const endTime = readTrimmed(sourceConfig.endTime) |
| 323 | if (startTime) params.start_time = startTime |
| 324 | if (endTime) params.end_time = endTime |
| 325 | } |
| 326 | |
| 327 | if (cursor) params.pagination_token = cursor |
| 328 | return params |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Clamps the requested page size to the endpoint's valid range and to the number |
no test coverage detected