var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import AlertSeverity from "./AlertSeverity";
import Label from "./Label";
import Monitor from "./Monitor";
import OnCallDutyPolicy from "./OnCallDutyPolicy";
import Project from "./Project";
import Team from "./Team";
import User from "./User";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import ColumnLength from "../../Types/Database/ColumnLength";
import ColumnType from "../../Types/Database/ColumnType";
import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
import EnableDocumentation from "../../Types/Database/EnableDocumentation";
import EnableWorkflow from "../../Types/Database/EnableWorkflow";
import TableColumn from "../../Types/Database/TableColumn";
import TableColumnType from "../../Types/Database/TableColumnType";
import TableMetadata from "../../Types/Database/TableMetadata";
import TenantColumn from "../../Types/Database/TenantColumn";
import IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, } from "typeorm";
let AlertGroupingRule = class AlertGroupingRule extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.name = undefined;
        this.description = undefined;
        this.priority = undefined;
        this.isEnabled = undefined;
        this.matchCriteria = undefined;
        // Match Criteria Fields (individual columns for form support)
        this.monitors = undefined;
        this.alertSeverities = undefined;
        this.alertLabels = undefined;
        this.monitorLabels = undefined;
        this.alertTitlePattern = undefined;
        this.alertDescriptionPattern = undefined;
        this.monitorNamePattern = undefined;
        this.monitorDescriptionPattern = undefined;
        // Group By Fields (how to group matching alerts)
        this.groupByMonitor = undefined;
        this.groupBySeverity = undefined;
        this.groupByAlertTitle = undefined;
        this.groupByAlertLabels = undefined;
        this.groupByMonitorLabels = undefined;
        this.enableTimeWindow = undefined;
        this.timeWindowMinutes = undefined;
        this.groupByFields = undefined;
        this.episodeTitleTemplate = undefined;
        this.episodeDescriptionTemplate = undefined;
        this.enableResolveDelay = undefined;
        this.resolveDelayMinutes = undefined;
        this.enableReopenWindow = undefined;
        this.reopenWindowMinutes = undefined;
        this.enableInactivityTimeout = undefined;
        this.inactivityTimeoutMinutes = undefined;
        this.onCallDutyPolicies = undefined;
        this.defaultAssignToUser = undefined;
        this.defaultAssignToUserId = undefined;
        this.defaultAssignToTeam = undefined;
        this.defaultAssignToTeamId = undefined;
        // Episode Configuration Fields
        this.episodeLabels = undefined;
        this.episodeOwnerUsers = undefined;
        this.episodeOwnerTeams = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "projectId",
        type: TableColumnType.Entity,
        modelType: Project,
        title: "Project",
        description: "Relation to Project Resource in which this object belongs",
    }),
    ManyToOne(() => {
        return Project;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "projectId" }),
    __metadata("design:type", Project)
], AlertGroupingRule.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Project ID",
        description: "ID of your OneUptime Project in which this object belongs",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AlertGroupingRule.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Name",
        description: "Name of this alert grouping rule",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], AlertGroupingRule.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Description",
        description: "Description of this alert grouping rule",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertGroupingRule.prototype, "description", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.Number,
        title: "Priority",
        description: "Priority of this rule. Lower number = higher priority. Rules are evaluated in priority order.",
        defaultValue: 1,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Number,
        nullable: false,
        default: 1,
    }),
    __metadata("design:type", Number)
], AlertGroupingRule.prototype, "priority", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.Boolean,
        title: "Is Enabled",
        description: "Whether this rule is enabled",
        defaultValue: true,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: true,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "isEnabled", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.JSON,
        title: "Match Criteria",
        description: "JSON object defining the criteria for matching alerts to this rule",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], AlertGroupingRule.prototype, "matchCriteria", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Monitor,
        title: "Monitors",
        description: "Only group alerts from these monitors. Leave empty to match alerts from any monitor.",
    }),
    ManyToMany(() => {
        return Monitor;
    }, { eager: false }),
    JoinTable({
        name: "AlertGroupingRuleMonitor",
        inverseJoinColumn: {
            name: "monitorId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertGroupingRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertGroupingRule.prototype, "monitors", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: AlertSeverity,
        title: "Alert Severities",
        description: "Only group alerts with these severities. Leave empty to match alerts of any severity.",
    }),
    ManyToMany(() => {
        return AlertSeverity;
    }, { eager: false }),
    JoinTable({
        name: "AlertGroupingRuleAlertSeverity",
        inverseJoinColumn: {
            name: "alertSeverityId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertGroupingRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertGroupingRule.prototype, "alertSeverities", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Alert Labels",
        description: "Only group alerts that have at least one of these labels. Leave empty to match alerts regardless of alert labels.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "AlertGroupingRuleAlertLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertGroupingRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertGroupingRule.prototype, "alertLabels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Monitor Labels",
        description: "Only group alerts from monitors that have at least one of these labels. Leave empty to match alerts regardless of monitor labels.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "AlertGroupingRuleMonitorLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertGroupingRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertGroupingRule.prototype, "monitorLabels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Alert Title Pattern",
        description: "Regular expression pattern to match alert titles. Leave empty to match any title. Example: 'CPU.*high' matches titles containing 'CPU' followed by 'high'.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertGroupingRule.prototype, "alertTitlePattern", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Alert Description Pattern",
        description: "Regular expression pattern to match alert descriptions. Leave empty to match any description.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertGroupingRule.prototype, "alertDescriptionPattern", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Monitor Name Pattern",
        description: "Regular expression pattern to match monitor names. Leave empty to match any monitor name. Example: 'prod-.*' matches monitors starting with 'prod-'.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertGroupingRule.prototype, "monitorNamePattern", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Monitor Description Pattern",
        description: "Regular expression pattern to match monitor descriptions. Leave empty to match any monitor description.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertGroupingRule.prototype, "monitorDescriptionPattern", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Group By Monitor",
        description: "When enabled, alerts from different monitors will be grouped into separate episodes. When disabled, alerts from any monitor can be grouped together.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "groupByMonitor", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Group By Alert Severity",
        description: "When enabled, alerts with different severities will be grouped into separate episodes. When disabled, alerts of any severity can be grouped together.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "groupBySeverity", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Group By Alert Title",
        description: "When enabled, alerts with different titles will be grouped into separate episodes. When disabled, alerts with any title can be grouped together.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "groupByAlertTitle", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Group By Alert Labels",
        description: "When enabled, alerts with different sets of labels will be grouped into separate episodes (exact set match). When disabled, alert labels are ignored for grouping.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "groupByAlertLabels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Group By Monitor Labels",
        description: "When enabled, alerts whose monitors have different sets of labels will be grouped into separate episodes (exact set match). When disabled, monitor labels are ignored for grouping.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "groupByMonitorLabels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Enable Time Window",
        description: "Enable time-based grouping. When enabled, alerts are grouped within the specified time window. When disabled, all matching alerts are grouped into a single ongoing episode regardless of time.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "enableTimeWindow", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Time Window (Minutes)",
        description: "Rolling time window in minutes. Alerts are grouped if they arrive within this gap from the last alert.",
        defaultValue: 60,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Number,
        nullable: false,
        default: 60,
    }),
    __metadata("design:type", Number)
], AlertGroupingRule.prototype, "timeWindowMinutes", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.JSON,
        title: "Group By Fields",
        description: "JSON object defining the fields to group alerts by (e.g., monitorId, severity)",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], AlertGroupingRule.prototype, "groupByFields", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Episode Title Template",
        description: "Template for generating episode titles. Supports placeholders like {{alertSeverity}}, {{monitorName}}, {{alertTitle}}, {{alertDescription}}",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
    }),
    __metadata("design:type", String)
], AlertGroupingRule.prototype, "episodeTitleTemplate", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Episode Description Template",
        description: "Template for generating episode descriptions. Supports placeholders like {{alertSeverity}}, {{monitorName}}, {{alertTitle}}, {{alertDescription}}",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
    }),
    __metadata("design:type", String)
], AlertGroupingRule.prototype, "episodeDescriptionTemplate", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Enable Resolve Delay",
        description: "Enable grace period before auto-resolving episode after all alerts resolve. Helps prevent rapid state changes during alert flapping.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "enableResolveDelay", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Resolve Delay (Minutes)",
        description: "Grace period in minutes before auto-resolving an episode after all alerts are resolved",
        defaultValue: 0,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Number,
        nullable: false,
        default: 0,
    }),
    __metadata("design:type", Number)
], AlertGroupingRule.prototype, "resolveDelayMinutes", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Enable Reopen Window",
        description: "Enable reopening recently resolved episodes instead of creating new ones. Useful when related issues recur shortly after resolution.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "enableReopenWindow", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Reopen Window (Minutes)",
        description: "Time window in minutes to reopen a recently resolved episode instead of creating a new one",
        defaultValue: 0,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Number,
        nullable: false,
        default: 0,
    }),
    __metadata("design:type", Number)
], AlertGroupingRule.prototype, "reopenWindowMinutes", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Enable Inactivity Timeout",
        description: "Enable auto-resolving episodes after a period of inactivity. Helps automatically close episodes when no new alerts arrive.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertGroupingRule.prototype, "enableInactivityTimeout", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Inactivity Timeout (Minutes)",
        description: "Time in minutes after which an inactive episode will be auto-resolved",
        defaultValue: 60,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Number,
        nullable: false,
        default: 60,
    }),
    __metadata("design:type", Number)
], AlertGroupingRule.prototype, "inactivityTimeoutMinutes", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: OnCallDutyPolicy,
        title: "On-Call Duty Policies",
        description: "List of on-call duty policies to execute for episodes created by this rule.",
    }),
    ManyToMany(() => {
        return OnCallDutyPolicy;
    }, { eager: false }),
    JoinTable({
        name: "AlertGroupingRuleOnCallDutyPolicy",
        inverseJoinColumn: {
            name: "onCallDutyPolicyId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertGroupingRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertGroupingRule.prototype, "onCallDutyPolicies", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        manyToOneRelationColumn: "defaultAssignToUserId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "Default Assign To User",
        description: "Default user to assign episodes created by this rule",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "defaultAssignToUserId" }),
    __metadata("design:type", User)
], AlertGroupingRule.prototype, "defaultAssignToUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        title: "Default Assign To User ID",
        description: "Default User ID to assign episodes created by this rule",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AlertGroupingRule.prototype, "defaultAssignToUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        manyToOneRelationColumn: "defaultAssignToTeamId",
        type: TableColumnType.Entity,
        modelType: Team,
        title: "Default Assign To Team",
        description: "Default team to assign episodes created by this rule",
    }),
    ManyToOne(() => {
        return Team;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "defaultAssignToTeamId" }),
    __metadata("design:type", Team)
], AlertGroupingRule.prototype, "defaultAssignToTeam", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        title: "Default Assign To Team ID",
        description: "Default Team ID to assign episodes created by this rule",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AlertGroupingRule.prototype, "defaultAssignToTeamId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Episode Labels",
        description: "Labels to automatically apply to episodes created by this rule.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "AlertGroupingRuleEpisodeLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertGroupingRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertGroupingRule.prototype, "episodeLabels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: User,
        title: "Episode Owner Users",
        description: "Users to automatically add as owners to episodes created by this rule.",
    }),
    ManyToMany(() => {
        return User;
    }, { eager: false }),
    JoinTable({
        name: "AlertGroupingRuleEpisodeOwnerUser",
        inverseJoinColumn: {
            name: "userId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertGroupingRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertGroupingRule.prototype, "episodeOwnerUsers", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Team,
        title: "Episode Owner Teams",
        description: "Teams to automatically add as owners to episodes created by this rule.",
    }),
    ManyToMany(() => {
        return Team;
    }, { eager: false }),
    JoinTable({
        name: "AlertGroupingRuleEpisodeOwnerTeam",
        inverseJoinColumn: {
            name: "teamId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertGroupingRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertGroupingRule.prototype, "episodeOwnerTeams", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "createdByUserId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "Created by User",
        description: "Relation to User who created this object (if this object was created by a User)",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByUserId" }),
    __metadata("design:type", User)
], AlertGroupingRule.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Created by User ID",
        description: "User ID who created this object (if this object was created by a User)",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AlertGroupingRule.prototype, "createdByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "deletedByUserId",
        type: TableColumnType.Entity,
        title: "Deleted by User",
        modelType: User,
        description: "Relation to User who deleted this object (if this object was deleted by a User)",
    }),
    ManyToOne(() => {
        return User;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "deletedByUserId" }),
    __metadata("design:type", User)
], AlertGroupingRule.prototype, "deletedByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Deleted by User ID",
        description: "User ID who deleted this object (if this object was deleted by a User)",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AlertGroupingRule.prototype, "deletedByUserId", void 0);
AlertGroupingRule = __decorate([
    EnableDocumentation(),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertGroupingRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertGroupingRule,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.DeleteAlertGroupingRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertGroupingRule,
        ],
    }),
    CrudApiEndpoint(new Route("/alert-grouping-rule")),
    Entity({
        name: "AlertGroupingRule",
    }),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    TableMetadata({
        tableName: "AlertGroupingRule",
        singularName: "Alert Grouping Rule",
        pluralName: "Alert Grouping Rules",
        icon: IconProp.Layers,
        tableDescription: "Configure rules for automatically grouping related alerts into episodes",
    })
], AlertGroupingRule);
export default AlertGroupingRule;
//# sourceMappingURL=AlertGroupingRule.js.map