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 Project from "./Project";
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 AlertLabelRule = class AlertLabelRule extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.name = undefined;
        this.description = undefined;
        this.isEnabled = undefined;
        this.monitors = undefined;
        this.alertSeverities = undefined;
        this.alertLabels = undefined;
        this.monitorLabels = undefined;
        this.alertTitlePattern = undefined;
        this.alertDescriptionPattern = undefined;
        this.monitorNamePattern = undefined;
        this.monitorDescriptionPattern = undefined;
        // Action: Labels to add
        this.labelsToAdd = undefined;
        this.inheritLabelsFromMonitors = undefined;
        this.inheritLabelsFromHosts = undefined;
        this.inheritLabelsFromKubernetesClusters = undefined;
        this.inheritLabelsFromDockerHosts = undefined;
        this.inheritLabelsFromServices = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        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)
], AlertLabelRule.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        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)
], AlertLabelRule.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Name",
        description: "Name of this alert label rule",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], AlertLabelRule.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Description",
        description: "Description of this alert label rule",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertLabelRule.prototype, "description", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    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)
], AlertLabelRule.prototype, "isEnabled", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Monitor,
        title: "Monitors",
        description: "Only trigger for alerts from these monitors. Leave empty to match alerts from any monitor.",
    }),
    ManyToMany(() => {
        return Monitor;
    }, { eager: false }),
    JoinTable({
        name: "AlertLabelRuleMonitor",
        inverseJoinColumn: {
            name: "monitorId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertLabelRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertLabelRule.prototype, "monitors", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: AlertSeverity,
        title: "Alert Severities",
        description: "Only trigger for alerts with these severities. Leave empty to match alerts of any severity.",
    }),
    ManyToMany(() => {
        return AlertSeverity;
    }, { eager: false }),
    JoinTable({
        name: "AlertLabelRuleAlertSeverity",
        inverseJoinColumn: {
            name: "alertSeverityId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertLabelRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertLabelRule.prototype, "alertSeverities", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Alert Labels",
        description: "Only trigger for alerts that already have at least one of these labels.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "AlertLabelRuleAlertLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertLabelRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertLabelRule.prototype, "alertLabels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Monitor Labels",
        description: "Only trigger for alerts from monitors that have at least one of these labels.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "AlertLabelRuleMonitorLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertLabelRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertLabelRule.prototype, "monitorLabels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Alert Title Pattern",
        description: "Regex (case-insensitive) matched against the alert title.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertLabelRule.prototype, "alertTitlePattern", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Alert Description Pattern",
        description: "Regex (case-insensitive) matched against the alert description.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertLabelRule.prototype, "alertDescriptionPattern", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Monitor Name Pattern",
        description: "Regex (case-insensitive) matched against the alert's monitor name.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertLabelRule.prototype, "monitorNamePattern", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Monitor Description Pattern",
        description: "Regex (case-insensitive) matched against the alert's monitor description.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], AlertLabelRule.prototype, "monitorDescriptionPattern", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Labels to Add",
        description: "Labels to attach to the alert when this rule matches. Already-attached labels are not duplicated.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "AlertLabelRuleLabelToAdd",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertLabelRuleId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], AlertLabelRule.prototype, "labelsToAdd", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Inherit Labels From Monitor",
        description: "When this rule matches, also copy every label of the alert's monitor onto the alert.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertLabelRule.prototype, "inheritLabelsFromMonitors", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Inherit Labels From Hosts",
        description: "When this rule matches, also copy every label of the alert's affected hosts onto the alert.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertLabelRule.prototype, "inheritLabelsFromHosts", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Inherit Labels From Kubernetes Clusters",
        description: "When this rule matches, also copy every label of the alert's affected Kubernetes clusters onto the alert.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertLabelRule.prototype, "inheritLabelsFromKubernetesClusters", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Inherit Labels From Docker Hosts",
        description: "When this rule matches, also copy every label of the alert's affected Docker hosts onto the alert.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertLabelRule.prototype, "inheritLabelsFromDockerHosts", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        title: "Inherit Labels From Services",
        description: "When this rule matches, also copy every label of the alert's affected services onto the alert.",
        defaultValue: false,
        isDefaultValueColumn: true,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], AlertLabelRule.prototype, "inheritLabelsFromServices", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        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)
], AlertLabelRule.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        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)
], AlertLabelRule.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)
], AlertLabelRule.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)
], AlertLabelRule.prototype, "deletedByUserId", void 0);
AlertLabelRule = __decorate([
    EnableDocumentation(),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateAlertLabelRule,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertLabelRule,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.DeleteAlertLabelRule,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditAlertLabelRule,
        ],
    }),
    CrudApiEndpoint(new Route("/alert-label-rule")),
    Entity({
        name: "AlertLabelRule",
    }),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    TableMetadata({
        tableName: "AlertLabelRule",
        singularName: "Alert Label Rule",
        pluralName: "Alert Label Rules",
        icon: IconProp.Tag,
        tableDescription: "Configure rules for automatically attaching labels to alerts — including labels inherited from the alert's monitor — when matching alerts are created",
    })
], AlertLabelRule);
export default AlertLabelRule;
//# sourceMappingURL=AlertLabelRule.js.map