import { JSONObject } from "./types/JSONObject"; /** * Describes a search filter normalized by Koncorde. * Returned by Koncorde.normalize(), and usable with Koncorde.store(). */ export declare class NormalizedFilter { /** * Normalized filter. * * @type {JSONObject[][]} */ filter: JSONObject[][]; /** * Filter unique identifier. * * @type {string} */ id: string; /** * Target index name. * * @type {string} */ index: string; constructor(normalized: any, id: string, index: string | null); } /** * Koncorde configuration */ export interface KoncordeOptions { /** * The maximum number of conditions a filter can hold. * It is advised to test performances and memory consumption * impacts before increasing this value. If set to 0, no limit is applied. * * NOTE: this check is performed after filters are decomposed, meaning that * the limit can kick in even though the provided filter is seemingly * simpler. * * (default: 50) * * @type {number} */ maxConditions: number; /** * Set the regex engine to either re2 or js. * The former is not fully compatible with PCREs, while the latter is * vulnerable to catastrophic backtracking, making it unsafe if regular * expressions are provided by end-users. * * (default: re2) * * @type {string} */ regExpEngine: string; /** * 32 bytes buffer containing a fixed random seed, to make filter * unique identifiers predictable. * * @type {ArrayBuffer} */ seed: ArrayBuffer; } export declare class Koncorde { private engines; private config; private transformer; /** * @param {Object} config */ constructor(config?: KoncordeOptions); /** * Checks if the provided filter is valid * * @param {Object} filter * @throws {KoncordeParseError} */ validate(filter: JSONObject): void; /** * Subscribes an unoptimized filter to the real-time engine. * Identical to a call to normalize() + store() * * Returns the filter unique identifier * * @param {Object} filter * @param {String} [index] - Index name * @return {String} * @throws {KoncordeParseError} */ register(filter: JSONObject, index?: string): string; /** * Returns an optimized version of the provided filter, with * its associated filter unique ID. * Does not store anything in the filters structures. * The returned object can either be used with store(), or discarded. * * @param {Object} filter * @param {String} [index] name * @return {NormalizedFilter} * @throws {KoncordeParseError} */ normalize(filter: JSONObject, index?: string): NormalizedFilter; /** * Stores a normalized filter. * A normalized filter is obtained using a call to normalize() * * Returns the filter unique identifer * * @param {NormalizedFilter} normalized - Obtained with a call to normalize() * @return {String} */ store(normalized: NormalizedFilter): string; /** * Returns all indexed filter IDs * * @param {String} [index] name * @returns {Array.} Array of matching filter IDs */ getFilterIds(index?: string): string[]; /** * Returns the list of named indexes * * @return {Array.} */ getIndexes(): string[]; /** * Check if a filter identifier is known by Koncorde * * @param {String} filterId * @param {String} [index] name * @returns {Boolean} */ hasFilterId(filterId: string, index?: string): boolean; /** * Test data against filters in the filters tree to get the matching * filters ID, if any * * @param {Object} data to test filters on * @param {String} [index] name * @return {Array} list of matching filters */ test(data: JSONObject, index?: string): string[]; /** * Removes all references to a given filter from the real-time engine * * @param {String} filterId - ID of the filter to remove * @param {String} [index] name */ remove(filterId: string, index?: string): void; /** * Converts a distance string value to a number of meters * @param {string} distance - client-provided distance * @returns {number} converted distance */ static convertDistance(distance: string): number; /** * Converts one of the accepted geopoint format into * a standardized version * * @param {Object} obj - object containing a geopoint * @returns {Coordinate} or null if no accepted format is found */ static convertGeopoint(point: string | JSONObject): { lat: number; lon: number; }; }