diff --git a/src/lib/index.ts b/src/lib/index.ts index f455f2c..ea39a50 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -8,7 +8,6 @@ export { type TwitterCookies, } from './cookies.js'; export { runtimeQueryIds } from './runtime-query-ids.js'; -export type { TweetResult, UploadMediaResult } from './twitter-client-types.js'; export { type CurrentUserResult, type FollowingResult, @@ -19,3 +18,4 @@ export { type TwitterClientOptions, type TwitterUser, } from './twitter-client.js'; +export type { TweetResult, UploadMediaResult } from './twitter-client-types.js'; diff --git a/src/lib/twitter-client-base.ts b/src/lib/twitter-client-base.ts index adc877d..fed9250 100644 --- a/src/lib/twitter-client-base.ts +++ b/src/lib/twitter-client-base.ts @@ -1,11 +1,11 @@ import { randomBytes, randomUUID } from 'node:crypto'; -import { QUERY_IDS, TARGET_QUERY_ID_OPERATIONS, type OperationName } from './twitter-client-constants.js'; import { runtimeQueryIds } from './runtime-query-ids.js'; -import { normalizeQuoteDepth } from './twitter-client-utils.js'; +import { type OperationName, QUERY_IDS, TARGET_QUERY_ID_OPERATIONS } from './twitter-client-constants.js'; import type { CurrentUserResult, TwitterClientOptions } from './twitter-client-types.js'; +import { normalizeQuoteDepth } from './twitter-client-utils.js'; -export type Constructor = new (...args: any[]) => T; -export type AbstractConstructor = abstract new (...args: any[]) => T; +export type Constructor = new (...args: unknown[]) => T; +export type AbstractConstructor = abstract new (...args: unknown[]) => T; export abstract class TwitterClientBase { protected authToken: string; @@ -59,9 +59,7 @@ export abstract class TwitterClientBase { protected async getSearchTimelineQueryIds(): Promise { const primary = await this.getQueryId('SearchTimeline'); - return Array.from( - new Set([primary, 'M1jEez78PEfVfbQLvlWMvQ', '5h0kNbk3ii97rmfY6CdgAA', 'Tp1sewRU1AsZpBWhqCZicQ']), - ); + return Array.from(new Set([primary, 'M1jEez78PEfVfbQLvlWMvQ', '5h0kNbk3ii97rmfY6CdgAA', 'Tp1sewRU1AsZpBWhqCZicQ'])); } protected async fetchWithTimeout(url: string, init: RequestInit): Promise { diff --git a/src/lib/twitter-client-media.ts b/src/lib/twitter-client-media.ts index a0f83a7..ef3e0e4 100644 --- a/src/lib/twitter-client-media.ts +++ b/src/lib/twitter-client-media.ts @@ -1,5 +1,5 @@ +import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js'; import { TWITTER_MEDIA_METADATA_URL, TWITTER_UPLOAD_URL } from './twitter-client-constants.js'; -import { type AbstractConstructor, type TwitterClientBase } from './twitter-client-base.js'; import type { UploadMediaResult } from './twitter-client-types.js'; export function withMedia>(Base: TBase) { diff --git a/src/lib/twitter-client-posting.ts b/src/lib/twitter-client-posting.ts index 4d5ad00..c64d8d9 100644 --- a/src/lib/twitter-client-posting.ts +++ b/src/lib/twitter-client-posting.ts @@ -1,10 +1,6 @@ -import { - TWITTER_API_BASE, - TWITTER_GRAPHQL_POST_URL, - TWITTER_STATUS_UPDATE_URL, -} from './twitter-client-constants.js'; +import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js'; +import { TWITTER_API_BASE, TWITTER_GRAPHQL_POST_URL, TWITTER_STATUS_UPDATE_URL } from './twitter-client-constants.js'; import { buildTweetCreateFeatures } from './twitter-client-features.js'; -import { type AbstractConstructor, type TwitterClientBase } from './twitter-client-base.js'; import type { CreateTweetResponse, TweetResult } from './twitter-client-types.js'; export function withPosting>(Base: TBase) { diff --git a/src/lib/twitter-client-search.ts b/src/lib/twitter-client-search.ts index 2e8f4cd..df122c3 100644 --- a/src/lib/twitter-client-search.ts +++ b/src/lib/twitter-client-search.ts @@ -1,6 +1,6 @@ +import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js'; import { TWITTER_API_BASE } from './twitter-client-constants.js'; import { buildSearchFeatures } from './twitter-client-features.js'; -import { type AbstractConstructor, type TwitterClientBase } from './twitter-client-base.js'; import type { SearchResult, TweetData } from './twitter-client-types.js'; import { extractCursorFromInstructions, parseTweetsFromInstructions } from './twitter-client-utils.js'; diff --git a/src/lib/twitter-client-timelines.ts b/src/lib/twitter-client-timelines.ts index 4319042..a29ad51 100644 --- a/src/lib/twitter-client-timelines.ts +++ b/src/lib/twitter-client-timelines.ts @@ -1,6 +1,6 @@ +import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js'; import { TWITTER_API_BASE } from './twitter-client-constants.js'; import { buildBookmarksFeatures, buildLikesFeatures } from './twitter-client-features.js'; -import { type AbstractConstructor, type TwitterClientBase } from './twitter-client-base.js'; import type { SearchResult } from './twitter-client-types.js'; import { parseTweetsFromInstructions } from './twitter-client-utils.js'; diff --git a/src/lib/twitter-client-tweet-detail.ts b/src/lib/twitter-client-tweet-detail.ts index bb45e74..366e806 100644 --- a/src/lib/twitter-client-tweet-detail.ts +++ b/src/lib/twitter-client-tweet-detail.ts @@ -1,6 +1,6 @@ +import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js'; import { TWITTER_API_BASE } from './twitter-client-constants.js'; import { buildArticleFeatures, buildArticleFieldToggles, buildTweetDetailFeatures } from './twitter-client-features.js'; -import { type AbstractConstructor, type TwitterClientBase } from './twitter-client-base.js'; import type { GetTweetResult, GraphqlTweetResult, SearchResult } from './twitter-client-types.js'; import { extractArticleText, diff --git a/src/lib/twitter-client-users.ts b/src/lib/twitter-client-users.ts index c0568ab..2cc6d54 100644 --- a/src/lib/twitter-client-users.ts +++ b/src/lib/twitter-client-users.ts @@ -1,3 +1,4 @@ +import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js'; import { SETTINGS_NAME_REGEX, SETTINGS_SCREEN_NAME_REGEX, @@ -5,7 +6,6 @@ import { TWITTER_API_BASE, } from './twitter-client-constants.js'; import { buildFollowingFeatures } from './twitter-client-features.js'; -import { type AbstractConstructor, type TwitterClientBase } from './twitter-client-base.js'; import type { CurrentUserResult, FollowingResult } from './twitter-client-types.js'; import { parseUsersFromInstructions } from './twitter-client-utils.js'; diff --git a/src/lib/twitter-client.ts b/src/lib/twitter-client.ts index b38edca..8acea24 100644 --- a/src/lib/twitter-client.ts +++ b/src/lib/twitter-client.ts @@ -6,7 +6,9 @@ import { withTimelines } from './twitter-client-timelines.js'; import { withTweetDetails } from './twitter-client-tweet-detail.js'; import { withUsers } from './twitter-client-users.js'; -const MixedTwitterClient = withUsers(withTimelines(withSearch(withTweetDetails(withPosting(withMedia(TwitterClientBase)))))); +const MixedTwitterClient = withUsers( + withTimelines(withSearch(withTweetDetails(withPosting(withMedia(TwitterClientBase))))), +); export class TwitterClient extends MixedTwitterClient {} @@ -16,8 +18,8 @@ export type { GetTweetResult, SearchResult, TweetData, - TwitterClientOptions, TweetResult, + TwitterClientOptions, TwitterUser, UploadMediaResult, } from './twitter-client-types.js'; diff --git a/tests/twitter-client-fixtures.ts b/tests/twitter-client-fixtures.ts index a70dd3c..e46225e 100644 --- a/tests/twitter-client-fixtures.ts +++ b/tests/twitter-client-fixtures.ts @@ -1,4 +1,4 @@ -import { TwitterClient } from '../src/lib/twitter-client.js'; +import type { TwitterClient } from '../src/lib/twitter-client.js'; export const validCookies = { authToken: 'test_auth_token', diff --git a/tests/twitter-client.get-tweet.test.ts b/tests/twitter-client.get-tweet.test.ts index 2765875..5babe2f 100644 --- a/tests/twitter-client.get-tweet.test.ts +++ b/tests/twitter-client.get-tweet.test.ts @@ -172,9 +172,7 @@ describe('TwitterClient getTweet', () => { const result = await client.getTweet('article123'); expect(result.success).toBe(true); - expect(result.tweet?.text).toBe( - '2025 LLM Year in Review\n\nIntro paragraph of the article.\n\nSecond paragraph.', - ); + expect(result.tweet?.text).toBe('2025 LLM Year in Review\n\nIntro paragraph of the article.\n\nSecond paragraph.'); }); it('should fall back to user article timeline for plain text', async () => { diff --git a/tests/twitter-client.search-bookmarks.test.ts b/tests/twitter-client.search-bookmarks.test.ts index cd42ca4..a2d1e27 100644 --- a/tests/twitter-client.search-bookmarks.test.ts +++ b/tests/twitter-client.search-bookmarks.test.ts @@ -551,9 +551,7 @@ describe('TwitterClient bookmark folders', () => { expect(result.success).toBe(true); expect(mockFetch).toHaveBeenCalledTimes(2); - const firstVars = JSON.parse( - new URL(mockFetch.mock.calls[0][0] as string).searchParams.get('variables') as string, - ); + const firstVars = JSON.parse(new URL(mockFetch.mock.calls[0][0] as string).searchParams.get('variables') as string); const secondVars = JSON.parse( new URL(mockFetch.mock.calls[1][0] as string).searchParams.get('variables') as string, );