UNPKG

react-querybuilder

Version:

React Query Builder component for constructing queries and filters, with utilities for executing them in various database and evaluation contexts

174 lines (173 loc) 5.95 kB
import type { ConstituentWordOrder, FormatQueryOptions, GroupVariantCondition, NLTranslationKey, NLTranslations, RuleGroupTypeAny, RuleType, SetRequired, ValueProcessorByRule, ValueProcessorLegacy, ValueProcessorOptions } from "../../types/index.noReact.mjs"; /** * Maps a {@link DefaultOperatorName} to a SQL operator. * * @group Export */ export declare const mapSQLOperator: (rqbOperator: string) => string; /** * Maps a (lowercase) {@link DefaultOperatorName} to a MongoDB operator. * * @group Export */ export declare const mongoOperators: { "=": string; "!=": string; "<": string; "<=": string; ">": string; ">=": string; in: string; notin: string; notIn: string; }; /** * Maps a (lowercase) {@link DefaultOperatorName} to a Prisma ORM operator. * * @group Export */ export declare const prismaOperators: { "=": string; "!=": string; "<": string; "<=": string; ">": string; ">=": string; in: string; notin: string; }; /** * Maps a {@link DefaultCombinatorName} to a CEL combinator. * * @group Export */ export declare const celCombinatorMap: { and: "&&"; or: "||"; }; /** * Register these operators with `jsonLogic` before applying the result * of `formatQuery(query, 'jsonlogic')`. * * @example * ``` * for (const [op, func] of Object.entries(jsonLogicAdditionalOperators)) { * jsonLogic.add_operation(op, func); * } * jsonLogic.apply({ "startsWith": [{ "var": "firstName" }, "Stev"] }, data); * ``` * * @group Export */ export declare const jsonLogicAdditionalOperators: Record<"startsWith" | "endsWith", (a: string, b: string) => boolean>; /** * Converts all `string`-type `value` properties of a query object into `number` where appropriate. * * Used by {@link formatQuery} for the `json*` formats when `parseNumbers` is `true`. * * @group Export */ export declare const numerifyValues: (rg: RuleGroupTypeAny, options: SetRequired<FormatQueryOptions, "fields">) => RuleGroupTypeAny; /** * Determines whether a value is _anything_ except an empty `string` or `NaN`. * * @group Export */ export declare const isValidValue: (value: any) => boolean; /** * Determines whether {@link formatQuery} should render the given value as a number. * As long as `parseNumbers` is `true`, `number` and `bigint` values will return `true` and * `string` values will return `true` if they test positive against {@link numericRegex}. * * @group Export */ export declare const shouldRenderAsNumber: (value: any, parseNumbers?: boolean | undefined) => boolean; /** * Used by {@link formatQuery} to determine whether the given value processor is a * "legacy" value processor by counting the number of arguments. Legacy value * processors take 3 arguments (not counting any arguments with default values), while * rule-based value processors take no more than 2 arguments. * * @group Export */ export declare const isValueProcessorLegacy: (valueProcessor: ValueProcessorLegacy | ValueProcessorByRule) => valueProcessor is ValueProcessorLegacy; /** * Converts the `quoteFieldNamesWith` option into an array of two strings. * If the option is a string, the array elements are both that string. * * @default * ['', ''] * * @group Export */ export declare const getQuoteFieldNamesWithArray: (quoteFieldNamesWith?: null | string | [string, string]) => [string, string]; /** * Given a field name and relevant {@link ValueProcessorOptions}, returns the field name * wrapped in the configured quote character(s). * * @group Export */ export declare const getQuotedFieldName: (fieldName: string, { quoteFieldNamesWith, fieldIdentifierSeparator }: ValueProcessorOptions) => string; /** * Given a [Constituent word order](https://en.wikipedia.org/wiki/Word_order#Constituent_word_orders) * like "svo" or "sov", returns a permutation of `["S", "V", "O"]` based on the first occurrence of * each letter in the input string (case insensitive). This widens the valid input from abbreviations * like "svo" to more expressive strings like "subject-verb-object" or "sub ver obj". Any missing * letters are appended in the default order "SVO" (e.g., "object" would yield `["O", "S", "V"]`). * * @group Export */ export declare const normalizeConstituentWordOrder: (input: string) => ConstituentWordOrder; /** * Default translations used by {@link formatQuery} for "natural_language" format. * * @group Export */ export declare const defaultNLTranslations: NLTranslations; /** * Used by {@link formatQuery} to get a translation based on certain conditions * for the "natural_language" format. * * @group Export */ export declare const getNLTranslataion: (key: NLTranslationKey, translations: NLTranslations, conditions?: GroupVariantCondition[]) => string; type ProcessedMatchMode = { mode: "all"; threshold?: number | null | undefined; } | { mode: "none"; threshold?: number | null | undefined; } | { mode: "some"; threshold?: number | null | undefined; } | { mode: "atleast"; threshold: number; } | { mode: "atmost"; threshold: number; } | { mode: "exactly"; threshold: number; }; export declare const processMatchMode: (rule: RuleType) => void | false | ProcessedMatchMode; /** * "Replacer" method for JSON.stringify's second argument. Converts `bigint` values to * objects with a `$bigint` property having a value of a string representation of * the actual `bigint`-type value. * * Inverse of {@link bigIntJsonParseReviver}. * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json */ export declare const bigIntJsonStringifyReplacer: (_key: string, value: unknown) => unknown; /** * "Reviver" method for JSON.parse's second argument. Converts objects having a single * `$bigint: string` property to an actual `bigint` value. * * Inverse of {@link bigIntJsonStringifyReplacer}. * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json */ export declare const bigIntJsonParseReviver: (_key: string, value: unknown) => unknown; export {};