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 IncidentEpisode from "./IncidentEpisode";
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 IncidentEpisodeFeedEventType;
(function (IncidentEpisodeFeedEventType) {
    IncidentEpisodeFeedEventType["EpisodeCreated"] = "EpisodeCreated";
    IncidentEpisodeFeedEventType["EpisodeStateChanged"] = "EpisodeStateChanged";
    IncidentEpisodeFeedEventType["EpisodeUpdated"] = "EpisodeUpdated";
    IncidentEpisodeFeedEventType["IncidentAdded"] = "IncidentAdded";
    IncidentEpisodeFeedEventType["IncidentRemoved"] = "IncidentRemoved";
    IncidentEpisodeFeedEventType["OwnerUserAdded"] = "OwnerUserAdded";
    IncidentEpisodeFeedEventType["OwnerTeamAdded"] = "OwnerTeamAdded";
    IncidentEpisodeFeedEventType["OwnerUserRemoved"] = "OwnerUserRemoved";
    IncidentEpisodeFeedEventType["OwnerTeamRemoved"] = "OwnerTeamRemoved";
    IncidentEpisodeFeedEventType["OwnerNotificationSent"] = "OwnerNotificationSent";
    IncidentEpisodeFeedEventType["PrivateNote"] = "PrivateNote";
    IncidentEpisodeFeedEventType["PublicNote"] = "PublicNote";
    IncidentEpisodeFeedEventType["RootCause"] = "RootCause";
    IncidentEpisodeFeedEventType["RemediationNotes"] = "RemediationNotes";
    IncidentEpisodeFeedEventType["PostmortemNote"] = "PostmortemNote";
    IncidentEpisodeFeedEventType["OnCallPolicy"] = "OnCallPolicy";
    IncidentEpisodeFeedEventType["OnCallNotification"] = "OnCallNotification";
    IncidentEpisodeFeedEventType["SeverityChanged"] = "SeverityChanged";
    IncidentEpisodeFeedEventType["SubscriberNotificationSent"] = "SubscriberNotificationSent";
    IncidentEpisodeFeedEventType["LabelRuleExecuted"] = "LabelRuleExecuted";
    IncidentEpisodeFeedEventType["OwnerRuleExecuted"] = "OwnerRuleExecuted";
    IncidentEpisodeFeedEventType["PrivacyRuleExecuted"] = "PrivacyRuleExecuted";
    IncidentEpisodeFeedEventType["OnCallRuleExecuted"] = "OnCallRuleExecuted";
})(IncidentEpisodeFeedEventType || (IncidentEpisodeFeedEventType = {}));
let IncidentEpisodeFeed = class IncidentEpisodeFeed extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.incidentEpisode = undefined;
        this.incidentEpisodeId = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.feedInfoInMarkdown = undefined;
        this.moreInformationInMarkdown = undefined;
        this.incidentEpisodeFeedEventType = undefined;
        this.displayColor = undefined;
        this.user = undefined;
        this.userId = undefined;
        this.postedAt = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        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)
], IncidentEpisodeFeed.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        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)
], IncidentEpisodeFeed.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "incidentEpisodeId",
        type: TableColumnType.Entity,
        modelType: IncidentEpisode,
        title: "Incident Episode",
        description: "Relation to Incident Episode in which this resource belongs",
    }),
    ManyToOne(() => {
        return IncidentEpisode;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "incidentEpisodeId" }),
    __metadata("design:type", IncidentEpisode)
], IncidentEpisodeFeed.prototype, "incidentEpisode", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        title: "Incident Episode ID",
        description: "Relation to Incident Episode ID in which this resource belongs",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncidentEpisodeFeed.prototype, "incidentEpisodeId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        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)
], IncidentEpisodeFeed.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        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)
], IncidentEpisodeFeed.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)
], IncidentEpisodeFeed.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)
], IncidentEpisodeFeed.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Markdown,
        required: true,
        title: "Log (in Markdown)",
        description: "Log of the entire incident episode activity in Markdown",
    }),
    Column({
        type: ColumnType.Markdown,
        nullable: false,
        unique: false,
    }),
    __metadata("design:type", String)
], IncidentEpisodeFeed.prototype, "feedInfoInMarkdown", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        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)
], IncidentEpisodeFeed.prototype, "moreInformationInMarkdown", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        required: true,
        title: "Incident Episode Feed Event",
        description: "Incident Episode Feed Event Type",
    }),
    Column({
        type: ColumnType.ShortText,
        nullable: false,
        unique: false,
    }),
    __metadata("design:type", String)
], IncidentEpisodeFeed.prototype, "incidentEpisodeFeedEventType", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        update: [],
    }),
    ColorField(),
    TableColumn({
        type: TableColumnType.Color,
        required: true,
        title: "Color",
        description: "Display color for the incident episode log",
    }),
    Column({
        type: ColumnType.Color,
        length: ColumnLength.Color,
        nullable: false,
        unique: false,
        transformer: Color.getDatabaseTransformer(),
    }),
    __metadata("design:type", Color)
], IncidentEpisodeFeed.prototype, "displayColor", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        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)
], IncidentEpisodeFeed.prototype, "user", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        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)
], IncidentEpisodeFeed.prototype, "userId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        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)
], IncidentEpisodeFeed.prototype, "postedAt", void 0);
IncidentEpisodeFeed = __decorate([
    EnableDocumentation(),
    CanAccessIfCanReadOn("incidentEpisode"),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.CreateIncidentEpisodeFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.IncidentAdmin,
            Permission.IncidentMember,
            Permission.IncidentViewer,
            Permission.ReadIncidentEpisodeFeed,
        ],
        delete: [],
        update: [],
    }),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    CrudApiEndpoint(new Route("/incident-episode-feed")),
    Entity({
        name: "IncidentEpisodeFeed",
    }),
    TableMetadata({
        tableName: "IncidentEpisodeFeed",
        singularName: "Incident Episode Feed",
        pluralName: "Incident Episode Feeds",
        icon: IconProp.List,
        tableDescription: "Log of the entire incident episode activity. This is a log of all the episode state changes, incidents added/removed, notes, etc.",
    })
], IncidentEpisodeFeed);
export default IncidentEpisodeFeed;
//# sourceMappingURL=IncidentEpisodeFeed.js.map