MCPcopy Index your code
hub / github.com/simstudioai/sim / buildListParams

Function buildListParams

apps/sim/connectors/x/x.ts:298–329  ·  view source on GitHub ↗

* 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
)

Source from the content-addressed store, hash-verified

296 * the modes whose endpoint supports them.
297 */
298function 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

Callers 1

x.tsFile · 0.85

Calls 4

readBooleanOptionFunction · 0.85
readTrimmedFunction · 0.85
joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected