feat: support ranked tweet search
CI / test (push) Successful in 10m17s

This commit is contained in:
2026-07-13 09:18:42 +09:00
parent 0caf2677e4
commit 81921226f0
8 changed files with 78 additions and 14 deletions
+6 -2
View File
@@ -6,10 +6,14 @@ import { extractCursorFromInstructions, parseTweetsFromInstructions } from './tw
const RAW_QUERY_MISSING_REGEX = /must be defined/i;
export type SearchProduct = 'Top' | 'Latest';
/** Options for search methods */
export interface SearchFetchOptions {
/** Include raw GraphQL response in `_raw` field */
includeRaw?: boolean;
/** Search result ranking (default: Latest) */
product?: SearchProduct;
}
/** Options for paged search methods */
@@ -80,7 +84,7 @@ export function withSearch<TBase extends AbstractConstructor<TwitterClientBase>>
let cursor: string | undefined = options.cursor;
let nextCursor: string | undefined;
let pagesFetched = 0;
const { includeRaw = false, maxPages } = options;
const { includeRaw = false, maxPages, product = 'Latest' } = options;
const fetchPage = async (pageCount: number, pageCursor?: string) => {
let lastError: string | undefined;
@@ -92,7 +96,7 @@ export function withSearch<TBase extends AbstractConstructor<TwitterClientBase>>
rawQuery: query,
count: pageCount,
querySource: 'typed_query',
product: 'Latest',
product,
...(pageCursor ? { cursor: pageCursor } : {}),
};