UNPKG

koncorde

Version:

Supersonic reverse matching engine

77 lines (76 loc) 2.44 kB
import { JSONObject } from '../types/JSONObject'; /** * Converts filters in canonical form * * @constructor * @param {Object} config */ export declare class Canonical { config: JSONObject; constructor(config: any); /** * Entry point of the normalizer: takes a filter in, and reduces it * into a simplified version * * Result format: * [ * [{condition: {...}, not: <boolean>}, {condition: {...}, not: <boolean>}, ...], * [{condition: {...}, not: <boolean>}, {condition: {...}, not: <boolean>}, ...], * ... * ] * * Explanation: * Each array entry contains an array of conditions. Each one of these conditions are linked * using a AND operand. * Array entries are linked together with OR operands. * * @param filters * @return {Array} resolving to a simplified filters array * @throws if espresso is unable to normalize the provided filters */ convert(filters: JSONObject): JSONObject[][]; /** * Transforms an array of conditions into the format expected by the store * @param {Object[]} conds * @private */ _andOr(conds: JSONObject[]): JSONObject[]; /** * Custom _.cloneDeep equivalent, which keeps the _isLeaf non-enumerable * property of the filters * @param {Array|Object} filters * @returns {Array|Object} * @private */ _cloneFilters(filters: any): JSONObject[] | JSONObject; /** * Extracts the conditions from a filter set * * @param {Object} filters * @param {Array} [conditions] * @return {Array} */ _extractConditions(filters: JSONObject, conditions?: JSONObject[]): JSONObject[]; /** * Returns the number of conditions as reworked by _extractConditions * * @param {Array} conditions * @return {Number */ _countConditions(conditions: JSONObject[]): number; /** * Given some standardized filters, returns the DNF form in espresso format * @param filters * @param conditions * @returns {String[]} * @private */ _normalize(filters: JSONObject, conditions: JSONObject[]): string[]; /** * Negates an array of filters in the format expected by the storage * @param conds * @private */ _notAndOr(conds: JSONObject[]): JSONObject[]; _removeImpossiblePredicates(ors: JSONObject[][]): JSONObject[][]; }