/** * Source Router for Federated Search * * Maps queries and content types to relevant sources. * Handles parameter translation between common search args and source-specific APIs. * Integrates query builders for sources that support advanced syntax (Trove, PROV, ALA). */ import type { ParsedQuery } from './query/types.js'; import type { IntentAnalysis } from './search/intent.js'; export interface SourceRoute { /** Source identifier (e.g., 'prov') */ source: string; /** Tool name for search (e.g., 'prov_search') */ tool: string; /** Keywords that trigger this source in auto-select */ keywords: string[]; /** Content types this source handles */ types: ContentType[]; } export type ContentType = 'image' | 'newspaper' | 'document' | 'species' | 'heritage' | 'film'; export interface CommonSearchArgs { query: string; dateFrom?: string; dateTo?: string; state?: string; limit?: number; lat?: number; lon?: number; radiusKm?: number; [key: string]: unknown; } /** Relevance level for source prioritisation */ export type RelevanceLevel = 'high' | 'medium' | 'low'; /** Individual prioritised source with reasoning */ export interface PrioritisedSource { /** Source identifier */ source: string; /** Tool name for search */ tool: string; /** Relevance level based on intent analysis */ relevance: RelevanceLevel; /** Human-readable reason for this relevance */ reason: string; /** Additional tools available for this source */ suggestedTools: string[]; /** Suggested filters based on intent */ suggestedFilters: Record; /** Relevance score (0-100) */ score: number; } /** Excluded source with reason */ export interface ExcludedSource { /** Source identifier */ source: string; /** Reason for exclusion */ reason: string; } /** Complete source prioritisation result */ export interface SourcePrioritisation { /** Sources ordered by relevance */ prioritised: PrioritisedSource[]; /** Sources excluded from search */ excluded: ExcludedSource[]; /** Recommended execution order (source names) */ searchOrder: string[]; } /** Source relevance score with reasoning */ interface RelevanceScore { score: number; reason: string; } export declare const SOURCE_DISPLAY: Record; /** * Routes for all searchable sources. * PM Transcripts and IIIF excluded (no search capability). */ export declare const SOURCE_ROUTES: SourceRoute[]; /** * Select sources based on explicit list, content type, or query keyword matching. * * Priority: * 1. Explicit sources (if provided) * 2. Content type filter * 3. Query keyword matching * 4. Default to all image/document sources */ export declare function selectSources(query: string, type?: ContentType, explicitSources?: string[]): SourceRoute[]; /** * Map common search arguments to source-specific parameters. * * Each source has different parameter names: * - dateFrom/dateTo: PROV, Trove use as-is; GA HAP uses yearFrom/yearTo; ALA uses startYear/endYear * - state: Trove, GA HAP, GHAP support; VHD is Victoria-only * - limit: Most use limit; ACMI uses page (1-based) * * When `parsed` is provided, uses query builders for sources that support them. */ export declare function mapArgsToSource(source: string, args: CommonSearchArgs, parsed?: ParsedQuery): Record; /** * Get all valid source names. */ export declare function getValidSources(): string[]; /** * Check if a source name is valid. */ export declare function isValidSource(source: string): boolean; /** * Score a source's relevance to an intent analysis. * * @param source - Source identifier * @param intent - Intent analysis from query * @returns Score (0-100) and reason */ export declare function scoreSourceRelevance(source: string, intent: IntentAnalysis): RelevanceScore; /** * Suggest filters for a source based on intent analysis. * * @param source - Source identifier * @param intent - Intent analysis from query * @returns Suggested filter parameters */ export declare function suggestFilters(source: string, intent: IntentAnalysis): Record; /** * Determine optimal search order based on prioritised sources. * * @param prioritised - Prioritised sources with scores * @returns Ordered list of source names */ export declare function determineSearchOrder(prioritised: PrioritisedSource[]): string[]; /** * Route sources based on intent analysis with relevance scoring. * * @param intent - Intent analysis from query * @param contentTypes - Optional content type filter * @returns Complete source prioritisation with reasoning */ export declare function routeSources(intent: IntentAnalysis, contentTypes?: ContentType[]): SourcePrioritisation; export {}; //# sourceMappingURL=source-router.d.ts.map