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 AlertEpisode from "./AlertEpisode";
import AlertSeverity from "./AlertSeverity";
import AlertState from "./AlertState";
import DockerHost from "./DockerHost";
import DockerResource from "./DockerResource";
import Host from "./Host";
import KubernetesCluster from "./KubernetesCluster";
import KubernetesContainer from "./KubernetesContainer";
import KubernetesResource from "./KubernetesResource";
import Label from "./Label";
import Monitor from "./Monitor";
import MonitorStatus from "./MonitorStatus";
import OnCallDutyPolicy from "./OnCallDutyPolicy";
import Probe from "./Probe";
import Project from "./Project";
import Service from "./Service";
import User from "./User";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
import OperationalResource from "../../Types/Database/AccessControl/OperationalResource";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import AccessControlColumn from "../../Types/Database/AccessControlColumn";
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 EnableMCP from "../../Types/Database/EnableMCP";
import EnableAuditLog from "../../Types/Database/EnableAuditLog";
import EnableWorkflow from "../../Types/Database/EnableWorkflow";
import MultiTenentQueryAllowed from "../../Types/Database/MultiTenentQueryAllowed";
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 Alert = class Alert extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.title = undefined;
        this.description = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        // monitor this alert was created for.
        this.monitor = undefined;
        this.monitorId = undefined;
        this.onCallDutyPolicies = undefined; // on-call duty policies affected by this alert.
        this.hosts = undefined; // hosts affected by this alert.
        this.kubernetesClusters = undefined;
        this.kubernetesResources = undefined;
        this.kubernetesContainers = undefined;
        this.dockerHosts = undefined;
        this.dockerResources = undefined;
        this.services = undefined;
        this.labels = undefined;
        this.currentAlertState = undefined;
        this.currentAlertStateId = undefined;
        this.alertSeverity = undefined;
        this.alertSeverityId = undefined;
        this.monitorStatusWhenThisAlertWasCreated = undefined;
        this.monitorStatusWhenThisAlertWasCreatedId = undefined;
        this.customFields = undefined;
        this.isOwnerNotifiedOfAlertCreation = undefined;
        this.rootCause = undefined;
        this.createdStateLog = undefined;
        this.createdCriteriaId = undefined;
        this.seriesFingerprint = undefined;
        this.seriesLabels = undefined;
        this.createdByProbe = undefined;
        this.createdByProbeId = undefined;
        this.isCreatedAutomatically = undefined;
        this.remediationNotes = undefined;
        this.telemetryQuery = undefined;
        this.alertNumber = undefined;
        this.alertNumberWithPrefix = undefined;
        this.postUpdatesToWorkspaceChannels = undefined;
        this.alertEpisode = undefined;
        this.alertEpisodeId = undefined;
        this.isPrivate = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        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)
], Alert.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Project ID",
        description: "ID of your OneUptime Project in which this object belongs",
        example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Alert.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.LongText,
        canReadOnRelationQuery: true,
        title: "Title",
        description: "Title of this alert",
        example: "High CPU usage detected on production server",
    }),
    Column({
        nullable: false,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], Alert.prototype, "title", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Markdown,
        title: "Description",
        description: "Short description of this alert. This will be visible on the status page. This is in markdown.",
        example: "CPU usage has exceeded 90% threshold for the past 5 minutes. Immediate investigation required.",
    }),
    Column({
        nullable: true,
        type: ColumnType.Markdown,
    }),
    __metadata("design:type", String)
], Alert.prototype, "description", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        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)
], Alert.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        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)
], Alert.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)
], Alert.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)
], Alert.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        manyToOneRelationColumn: "monitorId",
        type: TableColumnType.Entity,
        modelType: Monitor,
        title: "Monitor",
        description: "Relation to monitor this alert belongs to",
    }),
    ManyToOne(() => {
        return Monitor;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "monitorId" }),
    __metadata("design:type", Monitor)
], Alert.prototype, "monitor", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Monitor ID",
        description: "ID of the monitor this alert belongs to",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Alert.prototype, "monitorId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: OnCallDutyPolicy,
        title: "On-Call Duty Policies",
        description: "List of on-call duty policies affected by this alert.",
    }),
    ManyToMany(() => {
        return OnCallDutyPolicy;
    }, { eager: false }),
    JoinTable({
        name: "AlertOnCallDutyPolicy",
        inverseJoinColumn: {
            name: "onCallDutyPolicyId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "onCallDutyPolicies", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Host,
        title: "Hosts",
        description: "List of hosts affected by this alert.",
    }),
    ManyToMany(() => {
        return Host;
    }, { eager: false }),
    JoinTable({
        name: "AlertHost",
        inverseJoinColumn: {
            name: "hostId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "hosts", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: KubernetesCluster,
        title: "Kubernetes Clusters",
        description: "List of Kubernetes clusters affected by this alert.",
    }),
    ManyToMany(() => {
        return KubernetesCluster;
    }, { eager: false }),
    JoinTable({
        name: "AlertKubernetesCluster",
        inverseJoinColumn: {
            name: "kubernetesClusterId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "kubernetesClusters", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: KubernetesResource,
        title: "Kubernetes Resources",
        description: "List of Kubernetes resources (pods, deployments, nodes, etc.) affected by this alert.",
    }),
    ManyToMany(() => {
        return KubernetesResource;
    }, { eager: false }),
    JoinTable({
        name: "AlertKubernetesResource",
        inverseJoinColumn: {
            name: "kubernetesResourceId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "kubernetesResources", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: KubernetesContainer,
        title: "Kubernetes Containers",
        description: "List of Kubernetes containers affected by this alert.",
    }),
    ManyToMany(() => {
        return KubernetesContainer;
    }, { eager: false }),
    JoinTable({
        name: "AlertKubernetesContainer",
        inverseJoinColumn: {
            name: "kubernetesContainerId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "kubernetesContainers", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: DockerHost,
        title: "Docker Hosts",
        description: "List of Docker hosts affected by this alert.",
    }),
    ManyToMany(() => {
        return DockerHost;
    }, { eager: false }),
    JoinTable({
        name: "AlertDockerHost",
        inverseJoinColumn: {
            name: "dockerHostId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "dockerHosts", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: DockerResource,
        title: "Docker Resources",
        description: "List of Docker resources (containers, images, networks, volumes) affected by this alert.",
    }),
    ManyToMany(() => {
        return DockerResource;
    }, { eager: false }),
    JoinTable({
        name: "AlertDockerResource",
        inverseJoinColumn: {
            name: "dockerResourceId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "dockerResources", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Service,
        title: "Services",
        description: "List of services affected by this alert.",
    }),
    ManyToMany(() => {
        return Service;
    }, { eager: false }),
    JoinTable({
        name: "AlertService",
        inverseJoinColumn: {
            name: "serviceId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "services", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Label,
        title: "Labels",
        description: "Relation to Labels Array where this object is categorized in.",
    }),
    ManyToMany(() => {
        return Label;
    }, { eager: false }),
    JoinTable({
        name: "AlertLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "alertId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], Alert.prototype, "labels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        manyToOneRelationColumn: "currentAlertStateId",
        type: TableColumnType.Entity,
        modelType: AlertState,
        title: "Current Alert State",
        description: "Current state of this alert. Is the alert acknowledged? or resolved?. This is related to Alert State",
    }),
    ManyToOne(() => {
        return AlertState;
    }, {
        eager: false,
        nullable: true,
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "currentAlertStateId" }),
    __metadata("design:type", AlertState)
], Alert.prototype, "currentAlertState", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        isDefaultValueColumn: true,
        canReadOnRelationQuery: true,
        title: "Current Alert State ID",
        description: "Current Alert State ID",
        example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Alert.prototype, "currentAlertStateId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        manyToOneRelationColumn: "alertSeverityId",
        type: TableColumnType.Entity,
        modelType: AlertSeverity,
        title: "Alert Severity",
        description: "How severe is this alert. Is it critical? or a minor alert?. This is related to Alert Severity.",
    }),
    ManyToOne(() => {
        return AlertSeverity;
    }, {
        eager: false,
        nullable: true,
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "alertSeverityId" }),
    __metadata("design:type", AlertSeverity)
], Alert.prototype, "alertSeverity", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        title: "Alert Severity ID",
        description: "Alert Severity ID",
        example: "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Alert.prototype, "alertSeverityId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "monitorStatusWhenThisAlertWasCreatedId",
        type: TableColumnType.Entity,
        modelType: MonitorStatus,
        title: "Monitor status when this alert was created",
        description: "Monitor status when this alert was created",
    }),
    ManyToOne(() => {
        return MonitorStatus;
    }, {
        eager: false,
        nullable: true,
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "monitorStatusWhenThisAlertWasCreatedId" }),
    __metadata("design:type", MonitorStatus)
], Alert.prototype, "monitorStatusWhenThisAlertWasCreated", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        title: "Monitor Status ID when this alert was created",
        description: "Monitor Status ID when this alert was created",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Alert.prototype, "monitorStatusWhenThisAlertWasCreatedId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.JSON,
        title: "Custom Fields",
        description: "Custom Fields on this resource.",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], Alert.prototype, "customFields", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.Boolean,
        computed: true,
        hideColumnInDocumentation: true,
        required: true,
        isDefaultValueColumn: true,
        title: "Are Owners Notified Of Alert Creation?",
        description: "Are owners notified of when this alert is created?",
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], Alert.prototype, "isOwnerNotifiedOfAlertCreation", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Markdown,
        required: false,
        isDefaultValueColumn: false,
        title: "Root Cause",
        description: "What is the root cause of this alert?",
        example: "Memory leak in the application caused by improper resource cleanup in the connection pool.",
    }),
    Column({
        type: ColumnType.Markdown,
        nullable: true,
    }),
    __metadata("design:type", String)
], Alert.prototype, "rootCause", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.JSON,
        computed: true,
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Object)
], Alert.prototype, "createdStateLog", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.LongText,
        required: false,
        isDefaultValueColumn: false,
        title: "Created Criteria ID",
        description: "If this alert was created by a Probe, this is the ID of the criteria that created it.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
    }),
    __metadata("design:type", String)
], Alert.prototype, "createdCriteriaId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.LongText,
        required: false,
        isDefaultValueColumn: false,
        title: "Series Fingerprint",
        description: "For metric monitors with per-series alerting (e.g. grouped by host.name), this is a stable hash of the series label values so one alert is created per affected series.",
    }),
    Column({
        type: ColumnType.LongText,
        nullable: true,
    }),
    __metadata("design:type", String)
], Alert.prototype, "seriesFingerprint", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.JSON,
        required: false,
        isDefaultValueColumn: false,
        title: "Series Labels",
        description: "Attribute key/value pairs that identify the affected series (e.g. {host.name: prod-db-01}) when this alert was created from a per-series metric breach.",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], Alert.prototype, "seriesLabels", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "createdByProbeId",
        type: TableColumnType.Entity,
        modelType: Probe,
        title: "Created By Probe",
        description: "If this alert was created by a Probe, this is the probe that created it.",
    }),
    ManyToOne(() => {
        return Probe;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByProbeId" }),
    __metadata("design:type", Probe)
], Alert.prototype, "createdByProbe", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        canReadOnRelationQuery: true,
        title: "Created By Probe ID",
        description: "If this alert was created by a Probe, this is the ID of the probe that created it.",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Alert.prototype, "createdByProbeId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    TableColumn({
        isDefaultValueColumn: true,
        type: TableColumnType.Boolean,
        title: "Is created automatically?",
        description: "Is this alert created by OneUptime Probe or Workers automatically (and not created manually by a user)?",
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        default: false,
    }),
    __metadata("design:type", Boolean)
], Alert.prototype, "isCreatedAutomatically", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Markdown,
        title: "Remediation Notes",
        description: "Notes on how to remediate this alert. This is in markdown.",
        example: "1. Restart the affected service\\n2. Clear the connection pool\\n3. Monitor memory usage for the next 30 minutes",
    }),
    Column({
        nullable: true,
        type: ColumnType.Markdown,
    }),
    __metadata("design:type", String)
], Alert.prototype, "remediationNotes", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.JSON,
        title: "Telemetry Query",
        description: "Telemetry query for this alert",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], Alert.prototype, "telemetryQuery", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.Number,
        computed: true,
        canReadOnRelationQuery: true,
        title: "Alert Number",
        description: "Alert Number",
        example: 42,
    }),
    Column({
        type: ColumnType.Number,
        nullable: true,
    }),
    __metadata("design:type", Number)
], Alert.prototype, "alertNumber", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [],
    }),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.ShortText,
        title: "Alert Number With Prefix",
        description: "Alert number with prefix (e.g., 'ALT-42' or '#42')",
        computed: true,
        canReadOnRelationQuery: true,
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
    }),
    __metadata("design:type", String)
], Alert.prototype, "alertNumberWithPrefix", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.JSON,
        title: "Post Updates To Workspace Channel Name",
        description: "Post Updates To Workspace Channel Name",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Array)
], Alert.prototype, "postUpdatesToWorkspaceChannels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    TableColumn({
        manyToOneRelationColumn: "alertEpisodeId",
        type: TableColumnType.Entity,
        modelType: AlertEpisode,
        title: "Alert Episode",
        description: "The episode this alert belongs to (if grouped)",
    }),
    ManyToOne(() => {
        return AlertEpisode;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "alertEpisodeId" }),
    __metadata("design:type", AlertEpisode)
], Alert.prototype, "alertEpisode", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        title: "Alert Episode ID",
        description: "The ID of the episode this alert belongs to (if grouped)",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], Alert.prototype, "alertEpisodeId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    Index(),
    TableColumn({
        isDefaultValueColumn: true,
        type: TableColumnType.Boolean,
        title: "Is Private?",
        description: "If true, this alert is only visible to its owners (users in 'owner users' and members of 'owner teams'), project admins, and project owners.",
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        default: false,
        nullable: true,
    }),
    __metadata("design:type", Boolean)
], Alert.prototype, "isPrivate", void 0);
Alert = __decorate([
    OperationalResource(),
    EnableDocumentation(),
    EnableMCP(),
    AccessControlColumn("labels"),
    MultiTenentQueryAllowed(true),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlert,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlert,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.DeleteAlert,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.EditAlert,
        ],
    }),
    CrudApiEndpoint(new Route("/alert")),
    Entity({
        name: "Alert",
    }),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    EnableAuditLog(),
    TableMetadata({
        tableName: "Alert",
        singularName: "Alert",
        pluralName: "Alerts",
        icon: IconProp.Alert,
        tableDescription: "Manage alerts for your project",
        enableRealtimeEventsOn: {
            create: true,
            update: true,
            delete: true,
        },
    }),
    Index(["projectId", "currentAlertStateId"]) // Active-alert counters on dashboard
], Alert);
export default Alert;
//# sourceMappingURL=Alert.js.map