import { Stream } from "effect"; import { SEARCH_SCORE_KEY, type SearchConfig } from "../../types/search-types.js"; /** * A sort configuration mapping field names to sort direction. */ type SortConfig = Partial>; /** * Extract SearchConfig from a where clause if present at top level. * Returns undefined if no top-level $search is found. */ export declare function extractSearchConfig(where: Record | undefined): SearchConfig | undefined; /** * Compute and attach search relevance scores as metadata to each item in the stream. * This is called after filtering to pre-compute scores for the sort stage. * * Attaches the score as `_searchScore` on each item. Items that don't match * the search (already filtered out) won't be processed. * * @param searchConfig - The search configuration containing query and optional fields * @returns A stream combinator that attaches _searchScore metadata to each item */ export declare const attachSearchScores: >(searchConfig: SearchConfig | undefined) => (stream: Stream.Stream) => Stream.Stream; /** * Apply relevance-based sorting for search results. * Sorts items by their search relevance score in descending order. * * This function expects items to have a pre-computed `_searchScore` attached * by `attachSearchScores`. If the score is not present, it falls back to * computing the score on-the-fly. * * @param searchConfig - The search configuration containing query and optional fields * @returns A stream combinator that sorts by relevance score */ export declare const applyRelevanceSort: >(searchConfig: SearchConfig) => (stream: Stream.Stream) => Stream.Stream; /** * Apply a sort configuration as a Stream combinator. * Collects the stream, sorts in memory, and re-emits as a new stream. * * Supports multi-field sorting with asc/desc order, nested field paths (dot notation), * and handles undefined/null values (sorted to the end regardless of direction). */ export declare const applySort: >(sort: SortConfig | undefined) => (stream: Stream.Stream) => Stream.Stream; export {}; //# sourceMappingURL=sort-stream.d.ts.map