"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLabels = getLabels;
exports.getKpi = getKpi;
async function getLabels(question, expressions, entityManager, sqlExpressionResolver) {
    const sql = question.labelSql;
    if (!sql) {
        return [];
    }
    const sqlReplacementResult = sqlExpressionResolver.resolveSqlWithExpressions(sql, expressions || []);
    const labelResults = await entityManager.query(sqlReplacementResult.rawSql, sqlReplacementResult.parameters);
    const labels = labelResults.map((result) => result['label']);
    return labels;
}
async function getKpi(question, expressions, entityManager, sqlExpressionResolver) {
    const sql = question.kpiSql;
    if (!sql) {
        return "";
    }
    const sqlReplacementResult = sqlExpressionResolver.resolveSqlWithExpressions(sql, expressions || []);
    const result = await entityManager.query(sqlReplacementResult.rawSql, sqlReplacementResult.parameters);
    const kpiResult = result.pop();
    return kpiResult?.kpi || "";
}
//# sourceMappingURL=helpers.js.map