import type { Language, TokenizerConfig } from "../tokenizer/index.js"; import type { Hooks } from "../methods/hooks.js"; import type { RadixNode } from "../trees/radix/node.js"; import type { AVLNode } from "../trees/avl/node.js"; export * from "./filters.js"; export * from "./facets.js"; export type TokenScore = [string, number]; export type Nullable = T | null; export type IIntersectTokenScores = (arrays: TokenScore[][]) => TokenScore[]; export type ResolveSchema = { [P in keyof T]: ResolveTypes; }; export type SearchProperties = TKey extends string ? TSchema[TKey] extends PropertiesSchema ? `${TKey}.${SearchProperties}` : TKey : never; export type PropertyType = "string" | "number" | "boolean"; export type PropertiesSchema = { [key: string]: PropertyType | PropertiesSchema; }; export type AlgorithmsConfig = { intersectTokenScores: IIntersectTokenScores; }; export type PropertiesBoost = { [P in keyof S]?: number; }; export type ElaspedConfig = { format?: "human" | "raw"; }; export type Configuration = { /** * The structure of the document to be inserted into the database. */ schema: S; /** * The default language analyzer to use. */ defaultLanguage?: Language; edge?: boolean; hooks?: Hooks; components?: Components; }; export type Data = { docs: Record | undefined>; defaultLanguage: Language; index: Index; schema: S; frequencies: FrequencyMap; tokenOccurrencies: TokenOccurrency; avgFieldLength: Record; fieldLengths: Record>; }; export type Components = { elapsed?: ElaspedConfig; tokenizer?: TokenizerConfig; algorithms?: AlgorithmsConfig; }; export interface Lyra extends Data { defaultLanguage: Language; schema: S; edge: boolean; hooks: Hooks; components?: Components; frequencies: FrequencyMap; docsCount: number; avgFieldLength: Record; fieldLengths: Record>; } export type BM25OptionalParams = { k?: number; b?: number; d?: number; }; export type BM25Params = { k: number; b: number; d: number; }; export type TokenMap = Record; export type BooleanIndex = { 'true': string[]; 'false': string[]; }; type ResolveTypes = TType extends "string" ? string : TType extends "boolean" ? boolean : TType extends "number" ? number : TType extends PropertiesSchema ? { [P in keyof TType]: ResolveTypes; } : never; type Index = Record | BooleanIndex>; type FrequencyMap = { [property: string]: { [documentID: string]: { [token: string]: number; }; }; }; type TokenOccurrency = { [property: string]: { [token: string]: number; }; };