import { isExploreError } from '../types/explore';
import { getDimensions, getMetrics } from '../utils/fields';
export const calculateCompilationReport = (args) => {
    const exploresWithErrors = [];
    const baseTableNames = [];
    let successfulExploresCount = 0;
    let metricsCount = 0;
    let dimensionsCount = 0;
    args.explores.forEach((explore) => {
        if (isExploreError(explore)) {
            exploresWithErrors.push(explore);
        }
        else {
            successfulExploresCount += 1;
            baseTableNames.push(explore.baseTable);
            const metrics = getMetrics(explore);
            const dimensions = getDimensions(explore);
            metricsCount += metrics.length;
            dimensionsCount += dimensions.length;
        }
    });
    return {
        totalExploresCount: args.explores.length,
        successfulExploresCount,
        errorExploresCount: exploresWithErrors.length,
        metricsCount,
        dimensionsCount,
        exploresWithErrors,
        baseTableNames,
    };
};
export const calculateExploreWarningReport = (args) => {
    const exploresWithWarnings = args.explores.flatMap((explore) => {
        if (isExploreError(explore) || !explore.warnings?.length) {
            return [];
        }
        return [
            {
                name: explore.name,
                warnings: explore.warnings,
            },
        ];
    });
    return {
        warningCount: exploresWithWarnings.reduce((count, explore) => count + explore.warnings.length, 0),
        warningExploreCount: exploresWithWarnings.length,
        exploresWithWarnings,
    };
};
//# sourceMappingURL=compilationReport.js.map