"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.analyticsRowToClickHouse = analyticsRowToClickHouse;
exports.componentRowToClickHouse = componentRowToClickHouse;
const date_fns_1 = require("date-fns");
function toClickhouseTimestamp(value) {
    return (0, date_fns_1.format)(value, 'yyyy-MM-dd HH:mm:ss');
}
function analyticsRowToClickHouse(row) {
    return {
        eval_result_id: row.evalResultId,
        created_at: toClickhouseTimestamp(row.createdAt),
        project_id: row.projectId ?? '',
        application_id: row.applicationId ?? '',
        workspace_id: row.workspaceId ?? '',
        trace_id: row.traceId ?? '',
        session_id: row.sessionId ?? '',
        trace_ids: row.traceIds ?? [],
        is_redteam: row.isRedteam,
        test_run_id: row.testRunId,
        eval_id: row.evalId ?? '',
        test_idx: row.testIdx ?? 0,
        failure_reason: row.failureReason,
        error: row.error,
        grading_pass: row.gradingPass,
        grading_score: row.gradingScore,
        grading_reason: row.gradingReason ?? '',
        component_pass_count: row.componentPassCount,
        component_fail_count: row.componentFailCount,
        metric_keys: row.metricKeys,
        failed_metric_keys: row.failedMetricKeys,
        plugin_id: row.pluginId ?? '',
        plugin_pass: row.pluginPass ?? 0,
        denorm_version: row.denormVersion,
    };
}
function componentRowToClickHouse(row) {
    return {
        id: row.id,
        eval_result_id: row.evalResultId,
        component_index: row.componentIndex,
        assertion_type: row.assertionType ?? '',
        assertion_display_label: row.assertionDisplayLabel ?? '',
        metric_key: row.metricKey ?? '',
        component_pass: row.componentPass,
        component_score: row.componentScore,
        component_reason: row.componentReason ?? '',
        assertion_expected: row.assertionExpected ?? '',
        assertion_actual: row.assertionActual ?? '',
        project_id: row.projectId ?? '',
        application_id: row.applicationId ?? '',
        workspace_id: row.workspaceId ?? '',
        created_at: toClickhouseTimestamp(row.createdAt),
        trace_id: row.traceId ?? '',
        session_id: row.sessionId ?? '',
        trace_ids: row.traceIds ?? [],
        test_run_id: row.testRunId,
        eval_id: row.evalId ?? '',
        is_redteam: row.isRedteam,
        failure_reason: row.failureReason,
        error: row.error,
        plugin_id: row.pluginId ?? '',
        denorm_version: row.denormVersion,
    };
}
//# sourceMappingURL=mapClickHouseRows.js.map