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 DockerHost from "./DockerHost";
import Host from "./Host";
import IncidentSeverity from "./IncidentSeverity";
import IncidentState from "./IncidentState";
import KubernetesCluster from "./KubernetesCluster";
import Label from "./Label";
import Monitor from "./Monitor";
import MonitorStatus from "./MonitorStatus";
import OnCallDutyPolicy from "./OnCallDutyPolicy";
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 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 EnableWorkflow from "../../Types/Database/EnableWorkflow";
import SlugifyColumn from "../../Types/Database/SlugifyColumn";
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";
import TableBillingAccessControl from "../../Types/Database/AccessControl/TableBillingAccessControl";
import { PlanType } from "../../Types/Billing/SubscriptionPlan";
let IncidentTemplate = class IncidentTemplate extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.title = undefined;
        this.templateName = undefined;
        this.templateDescription = undefined;
        this.description = undefined;
        this.slug = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.monitors = undefined; // monitors affected by this incident.
        this.hosts = undefined;
        this.kubernetesClusters = undefined;
        this.dockerHosts = undefined;
        this.services = undefined;
        this.onCallDutyPolicies = undefined; // on-call duty policies affected by this incident template.
        this.labels = undefined;
        this.incidentSeverity = undefined;
        this.incidentSeverityId = undefined;
        this.changeMonitorStatusTo = undefined;
        this.changeMonitorStatusToId = undefined;
        this.initialIncidentState = undefined;
        this.initialIncidentStateId = undefined;
        this.customFields = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        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)
], IncidentTemplate.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        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)
], IncidentTemplate.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.LongText,
        canReadOnRelationQuery: true,
        title: "Title",
        description: "Title of this incident",
        example: "Production Server Outage - Database Connection Issue",
    }),
    Column({
        nullable: false,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], IncidentTemplate.prototype, "title", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Name",
        description: "Name of the Incident Template",
        example: "Server Outage Template",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], IncidentTemplate.prototype, "templateName", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.LongText,
        canReadOnRelationQuery: true,
        title: "Template Description",
        description: "Description of the Incident Template",
        example: "Use this template when experiencing server outages due to database connectivity issues. Includes automated notifications to on-call engineers and status page updates.",
    }),
    Column({
        nullable: false,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], IncidentTemplate.prototype, "templateDescription", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Markdown,
        title: "Description",
        description: "Short description of this incident. This is in markdown and will be visible on the status page.",
        example: "## Issue Description\n\nWe are currently experiencing connectivity issues with our primary database server. Our engineering team is actively investigating and working to resolve the issue.\n\n**Impact:** Users may experience slow response times or intermittent errors.",
    }),
    Column({
        nullable: true,
        type: ColumnType.Markdown,
    }),
    __metadata("design:type", String)
], IncidentTemplate.prototype, "description", void 0);
__decorate([
    Index(),
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [],
    }),
    TableColumn({
        required: true,
        unique: true,
        type: TableColumnType.Slug,
        computed: true,
        title: "Slug",
        description: "Friendly globally unique name for your object",
        example: "server-outage-template",
    }),
    Column({
        nullable: false,
        type: ColumnType.Slug,
        length: ColumnLength.Slug,
        unique: true,
    }),
    __metadata("design:type", String)
], IncidentTemplate.prototype, "slug", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        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)
], IncidentTemplate.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        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)",
        example: "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncidentTemplate.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)
], IncidentTemplate.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)",
        example: "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncidentTemplate.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Monitor,
        title: "Monitors",
        description: "List of monitors affected by this incident",
    }),
    ManyToMany(() => {
        return Monitor;
    }, { eager: false }),
    JoinTable({
        name: "IncidentTemplateMonitor",
        inverseJoinColumn: {
            name: "monitorId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "incidentTemplateId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], IncidentTemplate.prototype, "monitors", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Host,
        title: "Hosts",
        description: "List of hosts to pre-populate on incidents created from this template.",
    }),
    ManyToMany(() => {
        return Host;
    }, { eager: false }),
    JoinTable({
        name: "IncidentTemplateHost",
        inverseJoinColumn: {
            name: "hostId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "incidentTemplateId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], IncidentTemplate.prototype, "hosts", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: KubernetesCluster,
        title: "Kubernetes Clusters",
        description: "List of Kubernetes clusters to pre-populate on incidents created from this template.",
    }),
    ManyToMany(() => {
        return KubernetesCluster;
    }, { eager: false }),
    JoinTable({
        name: "IncidentTemplateKubernetesCluster",
        inverseJoinColumn: {
            name: "kubernetesClusterId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "incidentTemplateId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], IncidentTemplate.prototype, "kubernetesClusters", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: DockerHost,
        title: "Docker Hosts",
        description: "List of Docker hosts to pre-populate on incidents created from this template.",
    }),
    ManyToMany(() => {
        return DockerHost;
    }, { eager: false }),
    JoinTable({
        name: "IncidentTemplateDockerHost",
        inverseJoinColumn: {
            name: "dockerHostId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "incidentTemplateId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], IncidentTemplate.prototype, "dockerHosts", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: Service,
        title: "Services",
        description: "List of services to pre-populate on incidents created from this template.",
    }),
    ManyToMany(() => {
        return Service;
    }, { eager: false }),
    JoinTable({
        name: "IncidentTemplateService",
        inverseJoinColumn: {
            name: "serviceId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "incidentTemplateId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], IncidentTemplate.prototype, "services", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.EntityArray,
        modelType: OnCallDutyPolicy,
        title: "On-Call Duty Policies",
        description: "List of on-call duty policies affected by this incident template.",
    }),
    ManyToMany(() => {
        return OnCallDutyPolicy;
    }, { eager: false }),
    JoinTable({
        name: "IncidentTemplateOnCallDutyPolicy",
        inverseJoinColumn: {
            name: "onCallDutyPolicyId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "incidentTemplateId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], IncidentTemplate.prototype, "onCallDutyPolicies", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    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: "IncidentTemplateLabel",
        inverseJoinColumn: {
            name: "labelId",
            referencedColumnName: "_id",
        },
        joinColumn: {
            name: "incidentTemplateId",
            referencedColumnName: "_id",
        },
    }),
    __metadata("design:type", Array)
], IncidentTemplate.prototype, "labels", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        manyToOneRelationColumn: "incidentSeverityId",
        type: TableColumnType.Entity,
        modelType: IncidentSeverity,
        title: "Incident Severity",
        description: "How severe is this incident. Is it critical? or a minor incident?. This is related to Incident Severity.",
    }),
    ManyToOne(() => {
        return IncidentSeverity;
    }, {
        eager: false,
        nullable: true,
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "incidentSeverityId" }),
    __metadata("design:type", IncidentSeverity)
], IncidentTemplate.prototype, "incidentSeverity", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        title: "Incident Severity ID",
        description: "Incident Severity ID",
        example: "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncidentTemplate.prototype, "incidentSeverityId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "changeMonitorStatusToId",
        type: TableColumnType.Entity,
        modelType: IncidentState,
        title: "Change Monitor Status To",
        description: "Relation to Monitor Status Object. All monitors connected to this incident will be changed to this status when the incident is created.",
    }),
    ManyToOne(() => {
        return MonitorStatus;
    }, {
        eager: false,
        nullable: true,
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "changeMonitorStatusToId" }),
    __metadata("design:type", MonitorStatus)
], IncidentTemplate.prototype, "changeMonitorStatusTo", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        title: "Change Monitor Status To ID",
        description: "Relation to Monitor Status Object ID. All monitors connected to this incident will be changed to this status when the incident is created.",
        example: "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncidentTemplate.prototype, "changeMonitorStatusToId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "initialIncidentStateId",
        type: TableColumnType.Entity,
        modelType: IncidentState,
        title: "Initial Incident State",
        description: "Relation to Incident State Object. Incidents created from this template will start in this state.",
    }),
    ManyToOne(() => {
        return IncidentState;
    }, {
        eager: false,
        nullable: true,
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "initialIncidentStateId" }),
    __metadata("design:type", IncidentState)
], IncidentTemplate.prototype, "initialIncidentState", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        title: "Initial Incident State ID",
        description: "Relation to Incident State Object ID. Incidents created from this template will start in this state.",
        example: "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncidentTemplate.prototype, "initialIncidentStateId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    TableColumn({
        isDefaultValueColumn: false,
        required: false,
        type: TableColumnType.JSON,
        title: "Custom Fields",
        description: "Custom Fields on this resource.",
        example: {
            priority: "high",
            category: "infrastructure",
            escalationLevel: 2,
        },
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], IncidentTemplate.prototype, "customFields", void 0);
IncidentTemplate = __decorate([
    TableBillingAccessControl({
        create: PlanType.Growth,
        read: PlanType.Growth,
        update: PlanType.Growth,
        delete: PlanType.Growth,
    }),
    EnableDocumentation(),
    AccessControlColumn("labels"),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentTemplate,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentTemplate,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.DeleteIncidentTemplate,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.EditIncidentTemplate,
        ],
    }),
    CrudApiEndpoint(new Route("/incident-templates")),
    SlugifyColumn("name", "slug"),
    Entity({
        name: "IncidentTemplate",
    }),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    TableMetadata({
        tableName: "IncidentTemplate",
        singularName: "Incident Template",
        pluralName: "Incident Templates",
        icon: IconProp.Alert,
        tableDescription: "Manage incident templates for your project",
    })
], IncidentTemplate);
export default IncidentTemplate;
//# sourceMappingURL=IncidentTemplate.js.map