import { DirectorySearch, SearchQueryDTO, SearchQueryTypes } from './entities/SearchQueryDTO'; export declare const SearchQueryUtils: { negate: (query: SearchQueryDTO) => SearchQueryDTO; sortQuery(queryIN: SearchQueryDTO): SearchQueryDTO; stringifyForComparison(queryIN: SearchQueryDTO): string; isQueryEmpty(query: SearchQueryDTO | null | undefined): boolean; stripDefault: (val: T) => T; /** * False if a part of the query has a type that this version does not know, e.g. a hand-edited or outdated search link. */ isKnownQuery: (query: SearchQueryDTO) => boolean; validateSearchQuery: (query: SearchQueryDTO, what?: string) => void; /** * Validates a directory allow / block list. * Every entry has to be a directory TextSearch (type: SearchQueryTypes.directory). */ validateDirectoryList: (list: DirectorySearch[] | null | undefined, what?: string) => void; /** * Validates that the query is a single directory TextSearch (type: SearchQueryTypes.directory). */ validateDirectorySearch: (d: DirectorySearch, what?: string) => void; /** * Normalizes a relative directory path for matching: * '/' separators, no leading './' or '/', no trailing '/'. Root is ''. */ normalizeDirectoryPath: (dirPath: string) => string; /** * The directory path as the directory searches compare it: normalized, lower case and with runs of spaces collapsed * (the SQL search collapses them too, see SearchManager; a double space in a name is usually a typo #1309). * @param foldAccents also removes the accents, where the SQL search ignores them (see sqlIgnoresAccents of the backend) */ comparableDirectoryPath: (dirPath: string, foldAccents?: boolean) => string; /** * Matches a relative directory path against a directory search, without any DB access. * It follows the semantic of the SQL directory search (see SearchManager): * - exact_match: the path equals to the value * - like (default): the path contains the value * - globMatch: the whole path matches the glob (* matches any characters, including '/', ? matches one character) * A trailing '/*' means the directory itself and everything below it (e.g.: 'a/*' matches 'a', 'a/b', 'a/b/c'). * Use '/?*' to match only below a directory. * Matching is case-insensitive, and ignores the accents with foldAccents. */ matchDirectorySearch: (dirPath: string, search: DirectorySearch, foldAccents?: boolean) => boolean; /** * Returns the fixed path segments at the beginning of a directory search, that every match starts with. * E.g.: exact 'a/b' -> ['a', 'b'], glob 'a/b/*' -> ['a', 'b'], glob 'a/b*' -> ['a']. * Returns null if the matches can be anywhere (like and negated searches). */ getDirectorySearchAnchor: (search: DirectorySearch, foldAccents?: boolean) => string[] | null; /** * True if all matches of the search can be found from its path alone: exact match, or a glob that has no wildcard * other than a trailing '/*'. For other searches, the parents of the matching directories can only be found in the DB. */ isDirectorySearchAnchored: (search: DirectorySearch) => boolean; /** * Returns true if the directory is a parent of the fixed part of any entry of the list. * These parents are known from the path alone, without DB access. * For globs it can be true for a directory that also matches the entry itself (e.g.: 'a' for 'a/*'), * so check if the directory is allowed first. */ isDirectoryAnchoredParent: (dirPath: string, list: DirectorySearch[], foldAccents?: boolean) => boolean; /** * Returns true if the directory matches any entry of the list. */ matchDirectoryList: (dirPath: string, list: DirectorySearch[], foldAccents?: boolean) => boolean; /** * Converts a directory allow / block list to a single search query. * A directory matches the list if it matches any of its entries. * Returns null for an empty list. */ directoryListToQuery: (list: DirectorySearch[]) => SearchQueryDTO | null; URLMap: Record; /** * Make the SearchQuery URL friendly and shorter * @param query */ urlify: (query: SearchQueryDTO) => string; /** * The urlified exact match text search (e.g. for a keyword, a person or a place link) */ urlifyExactMatch: (type: SearchQueryTypes, value: string) => string; /** * Pareses the shortened urls and returns with the original SearchQueryDTO * @param urlQuery */ parseURLifiedQuery: (urlQuery: string) => SearchQueryDTO | null; };