"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidationTarget = exports.isFixableDashboardValidationError = exports.isDashboardValidationError = exports.isChartValidationError = exports.isTableValidationError = exports.ValidationSourceType = exports.DashboardFilterValidationErrorType = exports.ValidationErrorType = void 0;
exports.isValidationTargetValid = isValidationTargetValid;
var ValidationErrorType;
(function (ValidationErrorType) {
    ValidationErrorType["Chart"] = "chart";
    ValidationErrorType["Sorting"] = "sorting";
    ValidationErrorType["Filter"] = "filter";
    ValidationErrorType["Metric"] = "metric";
    ValidationErrorType["Model"] = "model";
    ValidationErrorType["Dimension"] = "dimension";
    ValidationErrorType["CustomMetric"] = "custom metric";
    ValidationErrorType["ChartConfiguration"] = "chart configuration";
})(ValidationErrorType || (exports.ValidationErrorType = ValidationErrorType = {}));
var DashboardFilterValidationErrorType;
(function (DashboardFilterValidationErrorType) {
    DashboardFilterValidationErrorType["FieldDoesNotExist"] = "field_does_not_exist";
    DashboardFilterValidationErrorType["FieldTableMismatch"] = "field_table_mismatch";
    DashboardFilterValidationErrorType["TableNotUsedByAnyChart"] = "table_not_used_by_any_chart";
    DashboardFilterValidationErrorType["TableDoesNotExist"] = "table_does_not_exist";
})(DashboardFilterValidationErrorType || (exports.DashboardFilterValidationErrorType = DashboardFilterValidationErrorType = {}));
var ValidationSourceType;
(function (ValidationSourceType) {
    ValidationSourceType["Chart"] = "chart";
    ValidationSourceType["Dashboard"] = "dashboard";
    ValidationSourceType["Table"] = "table";
})(ValidationSourceType || (exports.ValidationSourceType = ValidationSourceType = {}));
const isTableValidationError = (error) => error.source === ValidationSourceType.Table;
exports.isTableValidationError = isTableValidationError;
const isChartValidationError = (error) => error.source === ValidationSourceType.Chart;
exports.isChartValidationError = isChartValidationError;
const isDashboardValidationError = (error) => error.source === ValidationSourceType.Dashboard;
exports.isDashboardValidationError = isDashboardValidationError;
/**
 * Checks if a dashboard validation error is fixable via rename.
 * Fixable: FieldDoesNotExist (field renamed), TableDoesNotExist (model renamed),
 * FieldTableMismatch (field doesn't match table after model rename).
 */
const isFixableDashboardValidationError = (error) => (0, exports.isDashboardValidationError)(error) &&
    !!error.dashboardUuid &&
    !!error.dashboardFilterErrorType &&
    (error.dashboardFilterErrorType ===
        DashboardFilterValidationErrorType.FieldDoesNotExist ||
        error.dashboardFilterErrorType ===
            DashboardFilterValidationErrorType.TableDoesNotExist ||
        error.dashboardFilterErrorType ===
            DashboardFilterValidationErrorType.FieldTableMismatch);
exports.isFixableDashboardValidationError = isFixableDashboardValidationError;
var ValidationTarget;
(function (ValidationTarget) {
    ValidationTarget["CHARTS"] = "charts";
    ValidationTarget["DASHBOARDS"] = "dashboards";
    ValidationTarget["TABLES"] = "tables";
})(ValidationTarget || (exports.ValidationTarget = ValidationTarget = {}));
function isValidationTargetValid(validationTarget) {
    return Object.values(ValidationTarget).includes(validationTarget);
}
//# sourceMappingURL=validation.js.map