haixunMaster/lib/search/types.ts

52 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export type SearchType = "threads_keyword" | "web_search" | "crawler";
export type KeywordPriority = "high" | "medium" | "low";
export type SearchProviderName = "threads" | "brave" | "crawler";
export interface SearchRequest {
keyword: string;
limit: number;
since?: Date;
source: SearchProviderName;
searchType: SearchType;
priority?: KeywordPriority;
/** 直接指定 Brave 查詢(略過 keyword query builder */
query?: string;
/** 巡邏模式:檢查 high priority + 每日額度(預設 true */
patrolMode?: boolean;
/** 僅保留 threads.com 結果(預設 true */
threadsOnly?: boolean;
}
export interface SearchResult {
title: string;
url: string;
snippet: string;
author: string;
publishedAt?: Date;
source: SearchProviderName;
threadId?: string;
raw?: Record<string, unknown>;
}
export interface SearchResponse {
provider: SearchProviderName;
results: SearchResult[];
status: "success" | "unavailable" | "skipped";
skipReason?: string;
quotaUsed?: number;
quotaLimit?: number;
}
export interface KeywordInput {
value: string;
limit: number;
priority: KeywordPriority;
}
export interface SearchProvider {
name(): SearchProviderName;
enabled(): boolean;
search(req: SearchRequest): Promise<SearchResponse>;
}