export type QueryValue = string | number | boolean | null | undefined
export type QueryInput = Record<string, QueryValue | QueryValue[]>
export type JsonRecord = Record<string, unknown>
export type XAuthMode = 'oauth' | 'bearer'
/**
* Multi-account selection for OAuth user-context calls.
* Omit both for the default `x` integration.
* `account: 'work'` resolves to `x-work`.
* Prefer `integration` when you already know the exact saved name.
*/
export type XAccountParams = {
account?: string
integration?: string
}
export type ResolvedXOAuth = {
integrationName: string
/** Null for the default `x` integration. */
account: string | null
accessTokenSecretName: string
refreshTokenSecretName: string | null
clientId: string | null
}
export type XAccountSummary = {
account: string | null
integration: string
default: boolean
accessTokenSecretName: string | null
useWhen: string
}
export type XUser = JsonRecord & {
id?: string
name?: string
username?: string
verified?: boolean
description?: string
created_at?: string
public_metrics?: JsonRecord
url?: string
location?: string
}
export type XTweet = JsonRecord & {
id?: string
text?: string
author_id?: string
created_at?: string
conversation_id?: string
public_metrics?: JsonRecord
referenced_tweets?: unknown[]
entities?: JsonRecord
}
export type XApiResponse<T = unknown> = {
data?: T
includes?: JsonRecord
meta?: JsonRecord
errors?: unknown[]
title?: string
detail?: string
type?: string
status?: number
rateLimit?: XRateLimitInfo
}
export type XRateLimitInfo = {
limit?: string | null
remaining?: string | null
reset?: string | null
}
export type XDryRunResult = {
dryRun: true
action?: string
method?: string
url?: string
authMode?: XAuthMode
body?: unknown
payload?: JsonRecord
requiresConfirm: true
}
export type XRequestParams = XAccountParams & {
path: string
method?: string
query?: QueryInput
body?: JsonRecord | null
authMode?: XAuthMode
dryRun?: boolean
confirm?: boolean
}
export type XRefreshTokenParams = XAccountParams
export type XGetMeParams = XAccountParams & {
userFields?: string
}
export type XGetUserByUsernameParams = XAccountParams & {
username: string
userFields?: string
authMode?: XAuthMode
}
export type XGetTweetParams = XAccountParams & {
id: string
tweetFields?: string
expansions?: string
authMode?: XAuthMode
}
export type XSearchRecentParams = XAccountParams & {
query: string
maxResults?: number
max_results?: number
tweetFields?: string
expansions?: string
userFields?: string
authMode?: XAuthMode
}
export type XGetUserTweetsParams = XAccountParams & {
id: string
maxResults?: number
max_results?: number
paginationToken?: string
pagination_token?: string
tweetFields?: string
expansions?: string
authMode?: XAuthMode
}
export type XCreateTweetParams = XAccountParams & {
text: string
reply?: JsonRecord
quote_tweet_id?: string
quoteTweetId?: string
media?: JsonRecord
poll?: JsonRecord
for_super_followers_only?: boolean
forSuperFollowersOnly?: boolean
dryRun?: boolean
confirm?: boolean
}
export type XDeleteTweetParams = XAccountParams & {
id: string
dryRun?: boolean
confirm?: boolean
}
export type XTweetActionParams = XAccountParams & {
tweetId?: string
id?: string
userId?: string
dryRun?: boolean
confirm?: boolean
}
export type XUserActionParams = XAccountParams & {
username?: string
userId?: string
targetUserId?: string
id?: string
dryRun?: boolean
confirm?: boolean
}
export type XUserSummary = {
id?: string
username?: string
name?: string
}
export type XConnectUrls = {
reconnect: string
firstTime: string
bearerSecret: string
}
export type XSmokeTestResult = {
ok: boolean
integration?: string
account?: string | null
user?: XUserSummary | null
rateLimited?: boolean
note?: string
status?: number
setup?: XConnectUrls
}