import { CompareOptions } from '../builder/types.js'; import { WindowOptions } from './types.js'; import { OrderBy, OrderByClause, QueryIR, Select } from '../ir.js'; import { CollectionLike, NamespacedAndKeyedStream, NamespacedRow } from '../../types.js'; import { IStreamBuilder, KeyValue } from '@tanstack/db-ivm'; import { IndexInterface } from '../../indexes/base-index.js'; import { Collection } from '../../collection/index.js'; export type OrderByOptimizationInfo = { alias: string; orderBy: OrderBy; offset: number; limit: number; comparator: (a: Record | null | undefined, b: Record | null | undefined) => number; /** Extracts all orderBy column values from a raw row (array for multi-column) */ valueExtractorForRawRow: (row: Record) => unknown; /** Extracts only the first column value - used for index-based cursor */ firstColumnValueExtractor: (row: Record) => unknown; /** Index on the first orderBy column - used for lazy loading */ index?: IndexInterface; dataNeeded?: () => number; }; /** * Processes the ORDER BY clause * Works with the new structure that has both namespaced row data and $selected * Always uses fractional indexing and adds the index as __ordering_index to the result */ export declare function processOrderBy(rawQuery: QueryIR, pipeline: NamespacedAndKeyedStream, orderByClause: Array, selectClause: Select, collection: Collection, optimizableOrderByCollections: Record, setWindowFn: (windowFn: (options: WindowOptions) => void) => void, limit?: number, offset?: number, groupKeyFn?: (key: unknown, value: unknown) => unknown): IStreamBuilder>; /** * Builds a comparison configuration object that uses the values provided in the orderBy clause. * If no string sort configuration is provided it defaults to the collection's string sort configuration. * Multi-source FROM queries pass their first source collection here as the * documented default. Use explicit orderBy compare options when branches need * different string collation behavior. */ export declare function buildCompareOptions(clause: OrderByClause, collection: CollectionLike): CompareOptions;