UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

28 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cleanInvalidItemsInContext = void 0; const constants_1 = require("../constants"); const index_1 = require("../index"); function cleanInvalidItemsInContext(context, engine = constants_1.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'; (0, index_1.Transpile)(program, engine, context); return true; } catch (error) { return false; } }); return Object.assign(Object.assign({}, context), { model }); } exports.cleanInvalidItemsInContext = cleanInvalidItemsInContext; //# sourceMappingURL=cleanInvalidItemsInContext.js.map