react-querybuilder
Version:
React Query Builder component for constructing queries and filters, with utilities for executing them in various database and evaluation contexts
108 lines (107 loc) • 4.1 kB
text/typescript
import type { ConstituentWordOrder, FormatQueryOptions, GroupVariantCondition, NLTranslationKey, NLTranslations, RuleGroupTypeAny, 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 {@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 {@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;
export declare const defaultNLTranslations: NLTranslations;
export declare const getNLTranslataion: (key: NLTranslationKey, translations: NLTranslations, conditions?: GroupVariantCondition[]) => string;