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 Project from "./Project";
import User from "./User";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import CanAccessIfCanReadOn from "../../Types/Database/CanAccessIfCanReadOn";
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 ColorField from "../../Types/Database/ColorField";
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 Color from "../../Types/Color";
import IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
export var AlertEpisodeFeedEventType;
(function (AlertEpisodeFeedEventType) {
    AlertEpisodeFeedEventType["EpisodeCreated"] = "EpisodeCreated";
    AlertEpisodeFeedEventType["EpisodeStateChanged"] = "EpisodeStateChanged";
    AlertEpisodeFeedEventType["EpisodeUpdated"] = "EpisodeUpdated";
    AlertEpisodeFeedEventType["AlertAdded"] = "AlertAdded";
    AlertEpisodeFeedEventType["AlertRemoved"] = "AlertRemoved";
    AlertEpisodeFeedEventType["OwnerUserAdded"] = "OwnerUserAdded";
    AlertEpisodeFeedEventType["OwnerTeamAdded"] = "OwnerTeamAdded";
    AlertEpisodeFeedEventType["OwnerUserRemoved"] = "OwnerUserRemoved";
    AlertEpisodeFeedEventType["OwnerTeamRemoved"] = "OwnerTeamRemoved";
    AlertEpisodeFeedEventType["OwnerNotificationSent"] = "OwnerNotificationSent";
    AlertEpisodeFeedEventType["PrivateNote"] = "PrivateNote";
    AlertEpisodeFeedEventType["RootCause"] = "RootCause";
    AlertEpisodeFeedEventType["OnCallPolicy"] = "OnCallPolicy";
    AlertEpisodeFeedEventType["OnCallNotification"] = "OnCallNotification";
    AlertEpisodeFeedEventType["SeverityChanged"] = "SeverityChanged";
    AlertEpisodeFeedEventType["LabelRuleExecuted"] = "LabelRuleExecuted";
    AlertEpisodeFeedEventType["OwnerRuleExecuted"] = "OwnerRuleExecuted";
    AlertEpisodeFeedEventType["PrivacyRuleExecuted"] = "PrivacyRuleExecuted";
    AlertEpisodeFeedEventType["OnCallRuleExecuted"] = "OnCallRuleExecuted";
})(AlertEpisodeFeedEventType || (AlertEpisodeFeedEventType = {}));
let AlertEpisodeFeed = class AlertEpisodeFeed extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.alertEpisode = undefined;
        this.alertEpisodeId = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.feedInfoInMarkdown = undefined;
        this.moreInformationInMarkdown = undefined;
        this.alertEpisodeFeedEventType = undefined;
        this.displayColor = undefined;
        this.user = undefined;
        this.userId = undefined;
        this.postedAt = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        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)
], AlertEpisodeFeed.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Project ID",
        description: "ID of your OneUptime Project in which this object belongs",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AlertEpisodeFeed.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "alertEpisodeId",
        type: TableColumnType.Entity,
        modelType: AlertEpisode,
        title: "Alert Episode",
        description: "Relation to Alert Episode in which this resource belongs",
    }),
    ManyToOne(() => {
        return AlertEpisode;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "alertEpisodeId" }),
    __metadata("design:type", AlertEpisode)
], AlertEpisodeFeed.prototype, "alertEpisode", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        title: "Alert Episode ID",
        description: "Relation to Alert Episode ID in which this resource belongs",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AlertEpisodeFeed.prototype, "alertEpisodeId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        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)
], AlertEpisodeFeed.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        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)
], AlertEpisodeFeed.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)
], AlertEpisodeFeed.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)
], AlertEpisodeFeed.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Markdown,
        required: true,
        title: "Log (in Markdown)",
        description: "Log of the entire alert episode activity in Markdown",
    }),
    Column({
        type: ColumnType.Markdown,
        nullable: false,
        unique: false,
    }),
    __metadata("design:type", String)
], AlertEpisodeFeed.prototype, "feedInfoInMarkdown", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Markdown,
        required: false,
        title: "More Information (in Markdown)",
        description: "More information in Markdown",
    }),
    Column({
        type: ColumnType.Markdown,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], AlertEpisodeFeed.prototype, "moreInformationInMarkdown", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        required: true,
        title: "Alert Episode Feed Event",
        description: "Alert Episode Feed Event Type",
    }),
    Column({
        type: ColumnType.ShortText,
        nullable: false,
        unique: false,
    }),
    __metadata("design:type", String)
], AlertEpisodeFeed.prototype, "alertEpisodeFeedEventType", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    ColorField(),
    TableColumn({
        type: TableColumnType.Color,
        required: true,
        title: "Color",
        description: "Display color for the alert episode log",
    }),
    Column({
        type: ColumnType.Color,
        length: ColumnLength.Color,
        nullable: false,
        unique: false,
        transformer: Color.getDatabaseTransformer(),
    }),
    __metadata("design:type", Color)
], AlertEpisodeFeed.prototype, "displayColor", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "userId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "User",
        description: "Relation to User who this feed belongs to (if this feed belongs to a User)",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "userId" }),
    __metadata("design:type", User)
], AlertEpisodeFeed.prototype, "user", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "User ID",
        description: "User who this feed belongs to (if this feed belongs to a User)",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], AlertEpisodeFeed.prototype, "userId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        title: "Feed Posted At",
        description: "Date and time when the feed was posted",
        type: TableColumnType.Date,
    }),
    Column({
        type: ColumnType.Date,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Date)
], AlertEpisodeFeed.prototype, "postedAt", void 0);
AlertEpisodeFeed = __decorate([
    EnableDocumentation(),
    CanAccessIfCanReadOn("alertEpisode"),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.CreateAlertEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.AlertAdmin,
            Permission.AlertMember,
            Permission.AlertViewer,
            Permission.ReadAlertEpisodeFeed,
        ],
        delete: [],
        update: [],
    }),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    CrudApiEndpoint(new Route("/alert-episode-feed")),
    Entity({
        name: "AlertEpisodeFeed",
    }),
    TableMetadata({
        tableName: "AlertEpisodeFeed",
        singularName: "Alert Episode Feed",
        pluralName: "Alert Episode Feeds",
        icon: IconProp.List,
        tableDescription: "Log of the entire alert episode activity. This is a log of all the episode state changes, alerts added/removed, notes, etc.",
    })
], AlertEpisodeFeed);
export default AlertEpisodeFeed;
//# sourceMappingURL=AlertEpisodeFeed.js.map