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 ScheduledMaintenance from "./ScheduledMaintenance";
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 OwnedThrough from "../../Types/Database/AccessControl/OwnedThrough";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import CanAccessIfCanReadOn from "../../Types/Database/CanAccessIfCanReadOn";
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 IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
import ColumnLength from "../../Types/Database/ColumnLength";
import Color from "../../Types/Color";
export var ScheduledMaintenanceFeedEventType;
(function (ScheduledMaintenanceFeedEventType) {
    ScheduledMaintenanceFeedEventType["PublicNote"] = "PublicNote";
    ScheduledMaintenanceFeedEventType["SubscriberNotificationSent"] = "SubscriberNotificationSent";
    ScheduledMaintenanceFeedEventType["OwnerNotificationSent"] = "OwnerNotificationSent";
    ScheduledMaintenanceFeedEventType["OwnerUserAdded"] = "OwnerUserAdded";
    ScheduledMaintenanceFeedEventType["OwnerTeamAdded"] = "OwnerTeamAdded";
    ScheduledMaintenanceFeedEventType["ScheduledMaintenanceCreated"] = "ScheduledMaintenanceCreated";
    ScheduledMaintenanceFeedEventType["ScheduledMaintenanceStateChanged"] = "ScheduledMaintenanceStateChanged";
    ScheduledMaintenanceFeedEventType["PrivateNote"] = "PrivateNote";
    ScheduledMaintenanceFeedEventType["ScheduledMaintenanceUpdated"] = "ScheduledMaintenanceUpdated";
    ScheduledMaintenanceFeedEventType["RootCause"] = "RootCause";
    ScheduledMaintenanceFeedEventType["RemediationNotes"] = "RemediationNotes";
    ScheduledMaintenanceFeedEventType["OwnerUserRemoved"] = "OwnerUserRemoved";
    ScheduledMaintenanceFeedEventType["OwnerTeamRemoved"] = "OwnerTeamRemoved";
    ScheduledMaintenanceFeedEventType["OnCallPolicy"] = "OnCallPolicy";
    ScheduledMaintenanceFeedEventType["OnCallNotification"] = "OnCallNotification";
    ScheduledMaintenanceFeedEventType["OwnerRuleExecuted"] = "OwnerRuleExecuted";
    ScheduledMaintenanceFeedEventType["LabelRuleExecuted"] = "LabelRuleExecuted";
})(ScheduledMaintenanceFeedEventType || (ScheduledMaintenanceFeedEventType = {}));
let ScheduledMaintenanceFeed = class ScheduledMaintenanceFeed extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.scheduledMaintenance = undefined;
        this.scheduledMaintenanceId = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.feedInfoInMarkdown = undefined;
        this.moreInformationInMarkdown = undefined;
        this.scheduledMaintenanceFeedEventType = undefined;
        this.displayColor = undefined;
        this.user = undefined;
        this.userId = undefined;
        this.postedAt = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "projectId",
        type: TableColumnType.Entity,
        modelType: Project,
        title: "Project",
        description: "Relation to Project Resource in which this object belongs",
        example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
    }),
    ManyToOne(() => {
        return Project;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "projectId" }),
    __metadata("design:type", Project)
], ScheduledMaintenanceFeed.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        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)
], ScheduledMaintenanceFeed.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "scheduledMaintenanceId",
        type: TableColumnType.Entity,
        modelType: ScheduledMaintenance,
        title: "ScheduledMaintenance",
        description: "Relation to ScheduledMaintenance in which this resource belongs",
        example: "7a2b8c9d-f3e4-5c6d-9e7f-8a9b0c1d2e3f",
    }),
    ManyToOne(() => {
        return ScheduledMaintenance;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "scheduledMaintenanceId" }),
    __metadata("design:type", ScheduledMaintenance)
], ScheduledMaintenanceFeed.prototype, "scheduledMaintenance", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        title: "ScheduledMaintenance ID",
        description: "Relation to ScheduledMaintenance ID in which this resource belongs",
        example: "7a2b8c9d-f3e4-5c6d-9e7f-8a9b0c1d2e3f",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], ScheduledMaintenanceFeed.prototype, "scheduledMaintenanceId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        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)",
        example: "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByUserId" }),
    __metadata("design:type", User)
], ScheduledMaintenanceFeed.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        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: "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], ScheduledMaintenanceFeed.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)",
        example: "2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e",
    }),
    ManyToOne(() => {
        return User;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "deletedByUserId" }),
    __metadata("design:type", User)
], ScheduledMaintenanceFeed.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: "2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], ScheduledMaintenanceFeed.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Markdown,
        required: true,
        title: "Log (in Markdown)",
        description: "Log of the entire scheduled maintenance state change in Markdown",
        example: "## Scheduled Maintenance Created\n\nA new scheduled maintenance window has been created for database upgrade. Expected downtime: 2 hours.",
    }),
    Column({
        type: ColumnType.Markdown,
        nullable: false,
        unique: false,
    }),
    __metadata("design:type", String)
], ScheduledMaintenanceFeed.prototype, "feedInfoInMarkdown", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Markdown,
        required: false,
        title: "More Information (in Markdown)",
        description: "More information in Markdown",
        example: "### Additional Details\n\n- All services will be temporarily unavailable\n- Email notifications sent to all subscribers\n- Backup completed successfully",
    }),
    Column({
        type: ColumnType.Markdown,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], ScheduledMaintenanceFeed.prototype, "moreInformationInMarkdown", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        required: true,
        title: "ScheduledMaintenance Log Event",
        description: "ScheduledMaintenance Log Event",
        example: "ScheduledMaintenanceCreated",
    }),
    Column({
        type: ColumnType.ShortText,
        nullable: false,
        unique: false,
    }),
    __metadata("design:type", String)
], ScheduledMaintenanceFeed.prototype, "scheduledMaintenanceFeedEventType", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    ColorField(),
    TableColumn({
        type: TableColumnType.Color,
        required: true,
        title: "Color",
        description: "Display color for this log",
        example: "#3498db",
    }),
    Column({
        type: ColumnType.Color,
        length: ColumnLength.Color,
        nullable: false,
        unique: false,
        transformer: Color.getDatabaseTransformer(),
    }),
    __metadata("design:type", Color)
], ScheduledMaintenanceFeed.prototype, "displayColor", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        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)",
        example: "3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "userId" }),
    __metadata("design:type", User)
], ScheduledMaintenanceFeed.prototype, "user", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "User ID",
        description: "User who this feed belongs to (if this feed belongs to a User)",
        example: "3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], ScheduledMaintenanceFeed.prototype, "userId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        update: [],
    }),
    TableColumn({
        title: "Feed Posted At",
        description: "Date and time when the feed was posted",
        type: TableColumnType.Date,
        example: "2024-01-15T10:30:00.000Z",
    }),
    Column({
        type: ColumnType.Date,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Date)
], ScheduledMaintenanceFeed.prototype, "postedAt", void 0);
ScheduledMaintenanceFeed = __decorate([
    EnableDocumentation(),
    CanAccessIfCanReadOn("scheduledMaintenance"),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.CreateScheduledMaintenanceFeed,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ScheduledMaintenanceAdmin,
            Permission.ScheduledMaintenanceMember,
            Permission.ScheduledMaintenanceViewer,
            Permission.ReadScheduledMaintenanceFeed,
        ],
        delete: [],
        update: [],
    }),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    CrudApiEndpoint(new Route("/scheduled-maintenance-feed")),
    OwnedThrough("scheduledMaintenanceId", ScheduledMaintenance),
    Entity({
        name: "ScheduledMaintenanceFeed",
    }),
    TableMetadata({
        tableName: "ScheduledMaintenanceFeed",
        singularName: "Scheduled Maintenance Feed",
        pluralName: "Scheduled Maintenance Feed",
        icon: IconProp.List,
        tableDescription: "Log of the entire scheduled maintenance state change. This is a log of all the scheduled maintenance state changes, public notes, more etc.",
    })
], ScheduledMaintenanceFeed);
export default ScheduledMaintenanceFeed;
//# sourceMappingURL=ScheduledMaintenanceFeed.js.map