parseQuery
parseQuery signature
export const parseQuery = (value: string,format: QueryFormat): IParseQueryResult;
Supported formats
export type QueryFormat =| 'SQL'| 'Mongo'| 'AQL'| 'JSONata'| 'JsonLogic'| 'CEL'| 'Elasticsearch'| 'SpEL'| 'Prisma'| 'OData'| 'RSQL'| 'Dynamo'| 'Django';
Parse result
export interface IParseQueryResult {fields: IBuilderFieldProps[];data: DenormalizedQuery;}
Parameters
valueThe input string to parse.formatThe source syntax. Parsing behavior is selected entirely from this value.
Return value
fieldsField metadata inferred by the parser where possible. Some parsers can infer types and operator sets from the source expression.dataThe denormalized query tree produced from the input string.
Field comparisons
Parsing a field-reference rule
const result = parseQuery('WHERE ORDER_TOTAL >= ORDER_APPROVAL_LIMIT','SQL');console.log(result.data[0]);// {// type: 'GROUP',// value: 'AND',// isNegated: false,// children: [// {// field: 'ORDER_TOTAL',// operator: 'LARGER_EQUAL',// valueSource: 'field',// valueField: 'ORDER_APPROVAL_LIMIT',// },// ],// }
- Rule shape When the source syntax uses a native right-hand-side field reference, the parsed rule uses
valueSource: 'field'plusvalueField. - Supported native parsing
SQL,Mongo,AQL,JSONata,JsonLogic,CEL,SpEL,Prisma,OData,Dynamo, andDjangocan infer field comparisons from builder-compatible expressions. - Guardrails Unsupported or ambiguous shapes fail explicitly rather than being guessed as field references, including the intentionally unsupported
RSQLandElasticsearchcases.
Documentation