@qrvey/formula-lang
Version:
QFormula support for qrvey projects
24 lines • 900 B
JavaScript
import { ENGINES } from '../constants';
import { Transpile } from '../index';
export function cleanInvalidItemsInContext(context, engine = ENGINES.ELASTICSEARCH) {
var _a;
if (!context.currentFormulaId)
return context;
const model = (_a = context.model) === null || _a === void 0 ? void 0 : _a.filter((currentModel) => {
var _a;
if (!currentModel.isExternalFormula)
return true;
if (currentModel.id === context.currentFormulaId)
return false;
try {
const program = (_a = currentModel.replacement) !== null && _a !== void 0 ? _a : 'WRONG';
Transpile(program, engine, context);
return true;
}
catch (error) {
return false;
}
});
return Object.assign(Object.assign({}, context), { model });
}
//# sourceMappingURL=cleanInvalidItemsInContext.js.map