chore: fix lint issues
This commit is contained in:
+1
-1
@@ -8,7 +8,6 @@ export {
|
|||||||
type TwitterCookies,
|
type TwitterCookies,
|
||||||
} from './cookies.js';
|
} from './cookies.js';
|
||||||
export { runtimeQueryIds } from './runtime-query-ids.js';
|
export { runtimeQueryIds } from './runtime-query-ids.js';
|
||||||
export type { TweetResult, UploadMediaResult } from './twitter-client-types.js';
|
|
||||||
export {
|
export {
|
||||||
type CurrentUserResult,
|
type CurrentUserResult,
|
||||||
type FollowingResult,
|
type FollowingResult,
|
||||||
@@ -19,3 +18,4 @@ export {
|
|||||||
type TwitterClientOptions,
|
type TwitterClientOptions,
|
||||||
type TwitterUser,
|
type TwitterUser,
|
||||||
} from './twitter-client.js';
|
} from './twitter-client.js';
|
||||||
|
export type { TweetResult, UploadMediaResult } from './twitter-client-types.js';
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { randomBytes, randomUUID } from 'node:crypto';
|
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 { 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 type { CurrentUserResult, TwitterClientOptions } from './twitter-client-types.js';
|
||||||
|
import { normalizeQuoteDepth } from './twitter-client-utils.js';
|
||||||
|
|
||||||
export type Constructor<T = {}> = new (...args: any[]) => T;
|
export type Constructor<T = object> = new (...args: unknown[]) => T;
|
||||||
export type AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;
|
export type AbstractConstructor<T = object> = abstract new (...args: unknown[]) => T;
|
||||||
|
|
||||||
export abstract class TwitterClientBase {
|
export abstract class TwitterClientBase {
|
||||||
protected authToken: string;
|
protected authToken: string;
|
||||||
@@ -59,9 +59,7 @@ export abstract class TwitterClientBase {
|
|||||||
|
|
||||||
protected async getSearchTimelineQueryIds(): Promise<string[]> {
|
protected async getSearchTimelineQueryIds(): Promise<string[]> {
|
||||||
const primary = await this.getQueryId('SearchTimeline');
|
const primary = await this.getQueryId('SearchTimeline');
|
||||||
return Array.from(
|
return Array.from(new Set([primary, 'M1jEez78PEfVfbQLvlWMvQ', '5h0kNbk3ii97rmfY6CdgAA', 'Tp1sewRU1AsZpBWhqCZicQ']));
|
||||||
new Set([primary, 'M1jEez78PEfVfbQLvlWMvQ', '5h0kNbk3ii97rmfY6CdgAA', 'Tp1sewRU1AsZpBWhqCZicQ']),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async fetchWithTimeout(url: string, init: RequestInit): Promise<Response> {
|
protected async fetchWithTimeout(url: string, init: RequestInit): Promise<Response> {
|
||||||
|
|||||||
@@ -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 { 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';
|
import type { UploadMediaResult } from './twitter-client-types.js';
|
||||||
|
|
||||||
export function withMedia<TBase extends AbstractConstructor<TwitterClientBase>>(Base: TBase) {
|
export function withMedia<TBase extends AbstractConstructor<TwitterClientBase>>(Base: TBase) {
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import {
|
import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js';
|
||||||
TWITTER_API_BASE,
|
import { TWITTER_API_BASE, TWITTER_GRAPHQL_POST_URL, TWITTER_STATUS_UPDATE_URL } from './twitter-client-constants.js';
|
||||||
TWITTER_GRAPHQL_POST_URL,
|
|
||||||
TWITTER_STATUS_UPDATE_URL,
|
|
||||||
} from './twitter-client-constants.js';
|
|
||||||
import { buildTweetCreateFeatures } from './twitter-client-features.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';
|
import type { CreateTweetResponse, TweetResult } from './twitter-client-types.js';
|
||||||
|
|
||||||
export function withPosting<TBase extends AbstractConstructor<TwitterClientBase>>(Base: TBase) {
|
export function withPosting<TBase extends AbstractConstructor<TwitterClientBase>>(Base: TBase) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js';
|
||||||
import { TWITTER_API_BASE } from './twitter-client-constants.js';
|
import { TWITTER_API_BASE } from './twitter-client-constants.js';
|
||||||
import { buildSearchFeatures } from './twitter-client-features.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 type { SearchResult, TweetData } from './twitter-client-types.js';
|
||||||
import { extractCursorFromInstructions, parseTweetsFromInstructions } from './twitter-client-utils.js';
|
import { extractCursorFromInstructions, parseTweetsFromInstructions } from './twitter-client-utils.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js';
|
||||||
import { TWITTER_API_BASE } from './twitter-client-constants.js';
|
import { TWITTER_API_BASE } from './twitter-client-constants.js';
|
||||||
import { buildBookmarksFeatures, buildLikesFeatures } from './twitter-client-features.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 type { SearchResult } from './twitter-client-types.js';
|
||||||
import { parseTweetsFromInstructions } from './twitter-client-utils.js';
|
import { parseTweetsFromInstructions } from './twitter-client-utils.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js';
|
||||||
import { TWITTER_API_BASE } from './twitter-client-constants.js';
|
import { TWITTER_API_BASE } from './twitter-client-constants.js';
|
||||||
import { buildArticleFeatures, buildArticleFieldToggles, buildTweetDetailFeatures } from './twitter-client-features.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 type { GetTweetResult, GraphqlTweetResult, SearchResult } from './twitter-client-types.js';
|
||||||
import {
|
import {
|
||||||
extractArticleText,
|
extractArticleText,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { AbstractConstructor, TwitterClientBase } from './twitter-client-base.js';
|
||||||
import {
|
import {
|
||||||
SETTINGS_NAME_REGEX,
|
SETTINGS_NAME_REGEX,
|
||||||
SETTINGS_SCREEN_NAME_REGEX,
|
SETTINGS_SCREEN_NAME_REGEX,
|
||||||
@@ -5,7 +6,6 @@ import {
|
|||||||
TWITTER_API_BASE,
|
TWITTER_API_BASE,
|
||||||
} from './twitter-client-constants.js';
|
} from './twitter-client-constants.js';
|
||||||
import { buildFollowingFeatures } from './twitter-client-features.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 type { CurrentUserResult, FollowingResult } from './twitter-client-types.js';
|
||||||
import { parseUsersFromInstructions } from './twitter-client-utils.js';
|
import { parseUsersFromInstructions } from './twitter-client-utils.js';
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import { withTimelines } from './twitter-client-timelines.js';
|
|||||||
import { withTweetDetails } from './twitter-client-tweet-detail.js';
|
import { withTweetDetails } from './twitter-client-tweet-detail.js';
|
||||||
import { withUsers } from './twitter-client-users.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 {}
|
export class TwitterClient extends MixedTwitterClient {}
|
||||||
|
|
||||||
@@ -16,8 +18,8 @@ export type {
|
|||||||
GetTweetResult,
|
GetTweetResult,
|
||||||
SearchResult,
|
SearchResult,
|
||||||
TweetData,
|
TweetData,
|
||||||
TwitterClientOptions,
|
|
||||||
TweetResult,
|
TweetResult,
|
||||||
|
TwitterClientOptions,
|
||||||
TwitterUser,
|
TwitterUser,
|
||||||
UploadMediaResult,
|
UploadMediaResult,
|
||||||
} from './twitter-client-types.js';
|
} from './twitter-client-types.js';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { TwitterClient } from '../src/lib/twitter-client.js';
|
import type { TwitterClient } from '../src/lib/twitter-client.js';
|
||||||
|
|
||||||
export const validCookies = {
|
export const validCookies = {
|
||||||
authToken: 'test_auth_token',
|
authToken: 'test_auth_token',
|
||||||
|
|||||||
@@ -172,9 +172,7 @@ describe('TwitterClient getTweet', () => {
|
|||||||
const result = await client.getTweet('article123');
|
const result = await client.getTweet('article123');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
expect(result.tweet?.text).toBe(
|
expect(result.tweet?.text).toBe('2025 LLM Year in Review\n\nIntro paragraph of the article.\n\nSecond paragraph.');
|
||||||
'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 () => {
|
it('should fall back to user article timeline for plain text', async () => {
|
||||||
|
|||||||
@@ -551,9 +551,7 @@ describe('TwitterClient bookmark folders', () => {
|
|||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
expect(mockFetch).toHaveBeenCalledTimes(2);
|
expect(mockFetch).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
const firstVars = JSON.parse(
|
const firstVars = JSON.parse(new URL(mockFetch.mock.calls[0][0] as string).searchParams.get('variables') as string);
|
||||||
new URL(mockFetch.mock.calls[0][0] as string).searchParams.get('variables') as string,
|
|
||||||
);
|
|
||||||
const secondVars = JSON.parse(
|
const secondVars = JSON.parse(
|
||||||
new URL(mockFetch.mock.calls[1][0] as string).searchParams.get('variables') as string,
|
new URL(mockFetch.mock.calls[1][0] as string).searchParams.get('variables') as string,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user