"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LightdashPage = exports.getSchedulerUuid = exports.hasSchedulerUuid = exports.isCreateScheduler = exports.isSchedulerGsheetsOptions = exports.isSchedulerImageOptions = exports.isSchedulerCsvOptions = exports.isCreateSchedulerMsTeamsTarget = exports.isCreateSchedulerSlackTarget = exports.isEmailTarget = exports.isMsTeamsTarget = exports.isSlackTarget = exports.isDashboardCreateScheduler = exports.isChartCreateScheduler = exports.isChartScheduler = exports.isUpdateSchedulerEmailTarget = exports.isUpdateSchedulerMsTeamsTarget = exports.isUpdateSchedulerSlackTarget = exports.getSchedulerTargetUuid = exports.isDashboardScheduler = exports.operatorActionValue = exports.NotificationFrequency = exports.ThresholdOperator = exports.JobPriority = exports.SchedulerFormat = exports.SchedulerJobStatus = void 0;
const tslib_1 = require("tslib");
const assertUnreachable_1 = tslib_1.__importDefault(require("../utils/assertUnreachable"));
var SchedulerJobStatus;
(function (SchedulerJobStatus) {
    SchedulerJobStatus["SCHEDULED"] = "scheduled";
    SchedulerJobStatus["STARTED"] = "started";
    SchedulerJobStatus["COMPLETED"] = "completed";
    SchedulerJobStatus["ERROR"] = "error";
})(SchedulerJobStatus || (exports.SchedulerJobStatus = SchedulerJobStatus = {}));
var SchedulerFormat;
(function (SchedulerFormat) {
    SchedulerFormat["CSV"] = "csv";
    SchedulerFormat["XLSX"] = "xlsx";
    SchedulerFormat["IMAGE"] = "image";
    SchedulerFormat["GSHEETS"] = "gsheets";
})(SchedulerFormat || (exports.SchedulerFormat = SchedulerFormat = {}));
var JobPriority;
(function (JobPriority) {
    JobPriority[JobPriority["HIGH"] = 0] = "HIGH";
    JobPriority[JobPriority["MEDIUM"] = 1] = "MEDIUM";
    JobPriority[JobPriority["LOW"] = 2] = "LOW";
})(JobPriority || (exports.JobPriority = JobPriority = {}));
var ThresholdOperator;
(function (ThresholdOperator) {
    ThresholdOperator["GREATER_THAN"] = "greaterThan";
    ThresholdOperator["LESS_THAN"] = "lessThan";
    ThresholdOperator["INCREASED_BY"] = "increasedBy";
    ThresholdOperator["DECREASED_BY"] = "decreasedBy";
    // HAS_CHANGED = '=',
})(ThresholdOperator || (exports.ThresholdOperator = ThresholdOperator = {}));
var NotificationFrequency;
(function (NotificationFrequency) {
    NotificationFrequency["ALWAYS"] = "always";
    NotificationFrequency["ONCE"] = "once";
    // DAILY = 'daily',
})(NotificationFrequency || (exports.NotificationFrequency = NotificationFrequency = {}));
const operatorActionValue = (operator, value, highlight = '*') => {
    switch (operator) {
        case ThresholdOperator.GREATER_THAN:
            return `exceeded ${highlight}${value}${highlight}`;
        case ThresholdOperator.LESS_THAN:
            return `fell below ${highlight}${value}${highlight}`;
        case ThresholdOperator.INCREASED_BY:
            return `increased by ${highlight}${value}%${highlight} or more`;
        case ThresholdOperator.DECREASED_BY:
            return `decreased by ${highlight}${value}%${highlight} or less`;
        default:
            (0, assertUnreachable_1.default)(operator, `Unknown threshold operator: ${operator}`);
    }
    return '';
};
exports.operatorActionValue = operatorActionValue;
const isDashboardScheduler = (scheduler) => scheduler.dashboardUuid !== undefined;
exports.isDashboardScheduler = isDashboardScheduler;
const getSchedulerTargetUuid = (target) => {
    if ('schedulerSlackTargetUuid' in target) {
        return target.schedulerSlackTargetUuid;
    }
    if ('schedulerMsTeamsTargetUuid' in target) {
        return target.schedulerMsTeamsTargetUuid;
    }
    if ('schedulerEmailTargetUuid' in target) {
        return target.schedulerEmailTargetUuid;
    }
    return undefined;
};
exports.getSchedulerTargetUuid = getSchedulerTargetUuid;
const isUpdateSchedulerSlackTarget = (data) => 'schedulerSlackTargetUuid' in data && !!data.schedulerSlackTargetUuid;
exports.isUpdateSchedulerSlackTarget = isUpdateSchedulerSlackTarget;
const isUpdateSchedulerMsTeamsTarget = (data) => 'schedulerMsTeamsTargetUuid' in data && !!data.schedulerMsTeamsTargetUuid;
exports.isUpdateSchedulerMsTeamsTarget = isUpdateSchedulerMsTeamsTarget;
const isUpdateSchedulerEmailTarget = (data) => 'schedulerEmailTargetUuid' in data && !!data.schedulerEmailTargetUuid;
exports.isUpdateSchedulerEmailTarget = isUpdateSchedulerEmailTarget;
const isChartScheduler = (data) => 'savedChartUuid' in data && !!data.savedChartUuid;
exports.isChartScheduler = isChartScheduler;
const isChartCreateScheduler = (data) => 'savedChartUuid' in data && !!data.savedChartUuid;
exports.isChartCreateScheduler = isChartCreateScheduler;
const isDashboardCreateScheduler = (data) => 'dashboardUuid' in data && !!data.dashboardUuid;
exports.isDashboardCreateScheduler = isDashboardCreateScheduler;
const isSlackTarget = (target) => 'channel' in target;
exports.isSlackTarget = isSlackTarget;
const isMsTeamsTarget = (target) => 'webhook' in target;
exports.isMsTeamsTarget = isMsTeamsTarget;
const isEmailTarget = (target) => 'recipient' in target;
exports.isEmailTarget = isEmailTarget;
const isCreateSchedulerSlackTarget = (target) => 'channel' in target;
exports.isCreateSchedulerSlackTarget = isCreateSchedulerSlackTarget;
const isCreateSchedulerMsTeamsTarget = (target) => 'webhook' in target;
exports.isCreateSchedulerMsTeamsTarget = isCreateSchedulerMsTeamsTarget;
const isSchedulerCsvOptions = (options) => options && 'limit' in options;
exports.isSchedulerCsvOptions = isSchedulerCsvOptions;
const isSchedulerImageOptions = (options) => options && 'withPdf' in options;
exports.isSchedulerImageOptions = isSchedulerImageOptions;
const isSchedulerGsheetsOptions = (options) => options && 'gdriveId' in options;
exports.isSchedulerGsheetsOptions = isSchedulerGsheetsOptions;
const isCreateScheduler = (data) => 'targets' in data;
exports.isCreateScheduler = isCreateScheduler;
const hasSchedulerUuid = (data) => 'schedulerUuid' in data;
exports.hasSchedulerUuid = hasSchedulerUuid;
const getSchedulerUuid = (data) => 'schedulerUuid' in data ? data.schedulerUuid : undefined;
exports.getSchedulerUuid = getSchedulerUuid;
var LightdashPage;
(function (LightdashPage) {
    LightdashPage["DASHBOARD"] = "dashboard";
    LightdashPage["CHART"] = "chart";
    LightdashPage["EXPLORE"] = "explore";
})(LightdashPage || (exports.LightdashPage = LightdashPage = {}));
//# sourceMappingURL=scheduler.js.map