import { $t as DefaultRuleGroupType, Pt as DefaultRuleGroupTypeIC, jn as Except, nn as RuleGroupType, on as ExpressionNode, rn as RuleType } from "./index-DOIE2pwx.mjs"; import { t as ParserCommonOptions } from "./import-BdKPtLzo.mjs"; //#region src/utils/parseMongoDB/types.d.ts type MongoDbSupportedOperators = "$and" | "$or" | "$not" | "$eq" | "$gt" | "$gte" | "$in" | "$lt" | "$lte" | "$ne" | "$nin" | "$regex" | "$expr"; /** * A MongoDB aggregation-expression operand that {@link parseMongoDB!ParseMongoDbOptions.getExpression} * may receive — an aggregation-operator object (`{ $add: [...] }`, `{ $abs: x }`, etc.), a * `"$field"` path reference, or a literal. */ type MongoDBExpressionOperand = unknown; /** Context passed to {@link parseMongoDB!ParseMongoDbOptions.getExpression}. */ interface ParseMongoDBExpressionContext { /** Returns `true` if the field is configured (or if no `fields` were supplied). */ fieldExists: (fieldName: string) => boolean; } //#endregion //#region src/utils/parseMongoDB/parseMongoDB.d.ts /** * Options object for {@link parseMongoDB}. */ interface ParseMongoDbOptions extends ParserCommonOptions { /** * When `true`, MongoDB rules in the form of `{ fieldName: { $not: { <...rule> } } }` * will be parsed into a rule group with the `not` attribute set to `true`. By default * (i.e., when this attribute is `false`), such "`$not`" rules will be parsed into a * rule with a negated operator. * * For example, with `preventOperatorNegation` set to `true`, a MongoDB rule like this... * * ```ts * { fieldName: { $not: { $eq: 1 } } } * ``` * * ...would yield a rule group like this: * * ```ts * { * combinator: 'and', * not: true, * rules: [{ field: 'fieldName', operator: '=', value: 1 }] * } * ``` * * By default, the same MongoDB rule would yield a rule like this: * * ```ts * { field: 'fieldName', operator: '!=', value: 1 } * // negated operator ^ * ``` * * @default false */ preventOperatorNegation?: boolean; /** * Map of additional operators to their respective processing functions. Operators * must begin with `"$"`. Processing functions should return either a {@link index!RuleType RuleType} * or {@link index!RuleGroupType RuleGroupType}. * * (The functions should _not_ return {@link index!RuleGroupTypeIC RuleGroupTypeIC}, even if using independent * combinators. If the `independentCombinators` option is `true`, `parseMongoDB` * will convert the final query to {@link index!RuleGroupTypeIC RuleGroupTypeIC} before returning it.) * * @default {} */ additionalOperators?: Record<`$${string}`, (field: string, operator: string, value: any, options: ParserCommonOptions) => RuleType | RuleGroupType>; /** * Handler that converts a MongoDB aggregation-expression operand (within `$expr`) into an * {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by * `@react-querybuilder/expr` (`expressionParserMongoDB`). When omitted, expression * operands are ignored (rule dropped). */ getExpression?: (node: MongoDBExpressionOperand, ctx: ParseMongoDBExpressionContext) => ExpressionNode | null; } /** * Converts a MongoDB query object or parseable string into a query suitable * for the {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}). */ declare function parseMongoDB(mongoDbRules: string | Record): DefaultRuleGroupType; /** * Converts a MongoDB query object or parseable string into a query suitable * for the {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}). */ declare function parseMongoDB(mongoDbRules: string | Record, options: Except & { independentCombinators?: false; }): DefaultRuleGroupType; /** * Converts a MongoDB query object or parseable string into a query suitable * for the {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props * ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}). */ declare function parseMongoDB(mongoDbRules: string | Record, options: Except & { independentCombinators: true; }): DefaultRuleGroupTypeIC; //#endregion //#region src/utils/parseMongoDB/utils.d.ts /** * A MongoDB `$expr` comparison operand that is a candidate expression subtree: an * aggregation-operator object (e.g. `{ $multiply: [...] }`). Bare `"$field"` strings and * literals are not expression operands. The expr-supplied `getExpression` handler decides * whether it maps to a known function. */ declare const isMongoDBExpressionOperand: (operand: unknown) => boolean; /** Reads a MongoDB field-path operand (`"$field"`), returning the field name or `null`. */ declare const mongoDbFieldRef: (operand: unknown) => string | null; //#endregion export { MongoDBExpressionOperand, MongoDbSupportedOperators, ParseMongoDBExpressionContext, ParseMongoDbOptions, isMongoDBExpressionOperand, mongoDbFieldRef, parseMongoDB }; //# sourceMappingURL=parseMongoDB.d.mts.map