in src/server/queryUtils.ts [124:173]
function _addRuleSet(
config: QueryRuleSet,
resultQs: any,
currentIndex: number = 1
) {
const isTopLevel = currentIndex === 1;
// Special case for the first group
if (isTopLevel && !Array.isArray(config) && config.rules && config.operator) {
_checkGroupOperator(config.operator);
resultQs.j_top = config.operator;
return _addRuleSet(config.rules, resultQs, currentIndex);
}
// group definition
let rules: Array<QueryConfig> | Array<QueryProperties> | void;
if (Array.isArray(config)) rules = config;
else if (Array.isArray(config.rules)) rules = config.rules;
if (rules) {
// OPENING
if (!isTopLevel) {
resultQs[`f${currentIndex}`] = GROUP_OPEN_VALUE;
if (!Array.isArray(config) && config.operator) {
_checkGroupOperator(config.operator);
resultQs[`j${currentIndex}`] = config.operator;
}
currentIndex++;
}
for (const rule of rules) {
currentIndex = _addRuleSet(rule, resultQs, currentIndex);
}
// ENDING
if (!isTopLevel) {
resultQs[`f${currentIndex}`] = GROUP_CLOSE_VALUE;
}
return currentIndex + 1;
}
// rule definition
else if (!Array.isArray(config)) {
resultQs[`f${currentIndex}`] = config.key;
resultQs[`o${currentIndex}`] = config.operator || "equals";
resultQs[`v${currentIndex}`] = config.value;
return currentIndex + 1;
}
return currentIndex;
}