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 OnCallDutyPolicy from "./OnCallDutyPolicy";
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 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 TableBillingAccessControl from "../../Types/Database/AccessControl/TableBillingAccessControl";
import { PlanType } from "../../Types/Billing/SubscriptionPlan";
import EnableWorkflow from "../../Types/Database/EnableWorkflow";
let OnCallDutyPolicyTimeLog = class OnCallDutyPolicyTimeLog extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.onCallDutyPolicyId = undefined; // no replationship to OnCallDutyPolicy because this is a log table. We do not want logs to delete when the policy is deleted.
        this.onCallDutyPolicyScheduleId = undefined; // no replationship to OnCallDutyPolicy because this is a log table. We do not want logs to delete when the policy is deleted.
        this.onCallDutyPolicyEscalationRuleId = undefined; // no replationship to OnCallDutyPolicy because this is a log table. We do not want logs to delete when the policy is deleted.
        this.teamId = undefined; // no replationship to OnCallDutyPolicy because this is a log table. We do not want logs to delete when the policy is deleted.
        this.moreInfo = undefined; // no replationship to OnCallDutyPolicy because this is a log table. We do not want logs to delete when the policy is deleted.
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.user = undefined;
        this.userId = undefined;
        this.startsAt = undefined;
        this.endsAt = undefined; // this user is still on-call. Then this will be null.
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        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)
], OnCallDutyPolicyTimeLog.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        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)
], OnCallDutyPolicyTimeLog.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        canReadOnRelationQuery: true,
        title: "On-Call Policy ID",
        description: "ID of your On-Call Policy where this escalation rule belongs.",
        example: "e5f6a7b8-c9d0-1234-ef01-345678901234",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], OnCallDutyPolicyTimeLog.prototype, "onCallDutyPolicyId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        canReadOnRelationQuery: true,
        title: "On-Call Policy Schedule ID",
        description: "ID of your On-Call Policy Schedule where this escalation rule belongs.",
        example: "f6a7b8c9-d0e1-2345-f012-456789012345",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], OnCallDutyPolicyTimeLog.prototype, "onCallDutyPolicyScheduleId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        canReadOnRelationQuery: true,
        title: "On-Call Policy Escalation Rule ID",
        description: "ID of your On-Call Policy Escalation Rule ID where this escalation rule belongs.",
        example: "a7b8c9d0-e1f2-3456-0123-567890123456",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], OnCallDutyPolicyTimeLog.prototype, "onCallDutyPolicyEscalationRuleId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: false,
        canReadOnRelationQuery: true,
        title: "Team ID",
        description: "ID of your On-Call Policy Team ID where this escalation rule belongs.",
        example: "d4e5f6a7-b8c9-0123-def0-234567890123",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], OnCallDutyPolicyTimeLog.prototype, "teamId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.VeryLongText,
        required: false,
        canReadOnRelationQuery: true,
        title: "More Info",
        description: "More information about this log record.",
        example: "User was on-call during incident INC-1234. Successfully handled 3 alerts during this shift.",
    }),
    Column({
        type: ColumnType.VeryLongText,
        nullable: true,
    }),
    __metadata("design:type", String)
], OnCallDutyPolicyTimeLog.prototype, "moreInfo", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        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: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByUserId" }),
    __metadata("design:type", User)
], OnCallDutyPolicyTimeLog.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        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-7890-abcd-ef1234567890",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], OnCallDutyPolicyTimeLog.prototype, "createdByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "userId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "Override User",
        description: "Relation to User who is being overridden by this object (if this object was created by a User)",
        example: "c3d4e5f6-a7b8-9012-cdef-123456789012",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "userId" }),
    __metadata("design:type", User)
], OnCallDutyPolicyTimeLog.prototype, "user", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        title: "User ID",
        description: "User ID for which this log belongs",
        example: "c3d4e5f6-a7b8-9012-cdef-123456789012",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], OnCallDutyPolicyTimeLog.prototype, "userId", void 0);
__decorate([
    Index(),
    TableColumn({
        title: "Start At",
        type: TableColumnType.Date,
        required: true,
        description: "When does this start?",
        example: "2024-01-15T09:00:00.000Z",
    }),
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    Column({
        nullable: false,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], OnCallDutyPolicyTimeLog.prototype, "startsAt", void 0);
__decorate([
    Index(),
    TableColumn({
        title: "Ends At",
        type: TableColumnType.Date,
        required: false,
        description: "When does this end?",
        example: "2024-01-15T18:00:00.000Z",
    }),
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        update: [],
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], OnCallDutyPolicyTimeLog.prototype, "endsAt", 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: "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    }),
    ManyToOne(() => {
        return User;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "deletedByUserId" }),
    __metadata("design:type", User)
], OnCallDutyPolicyTimeLog.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-8901-bcde-f12345678901",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], OnCallDutyPolicyTimeLog.prototype, "deletedByUserId", void 0);
OnCallDutyPolicyTimeLog = __decorate([
    EnableDocumentation(),
    CanAccessIfCanReadOn("onCallDutyPolicy"),
    TableBillingAccessControl({
        create: PlanType.Growth,
        read: PlanType.Growth,
        update: PlanType.Growth,
        delete: PlanType.Growth,
    }),
    TenantColumn("projectId"),
    EnableWorkflow({
        create: true,
        delete: true,
        update: true,
        read: true,
    }),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
            Permission.OnCallViewer,
            Permission.ReadOnCallDutyPolicyTimeLog,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.OnCallAdmin,
            Permission.OnCallMember,
        ],
    }),
    CrudApiEndpoint(new Route("/on-call-duty-policy-time-log")),
    OwnedThrough("onCallDutyPolicyId", OnCallDutyPolicy),
    Entity({
        name: "OnCallDutyPolicyTimeLog",
    }),
    TableMetadata({
        tableName: "OnCallDutyPolicyTimeLog",
        singularName: "On Call Time Log",
        pluralName: "On Call Time Logs",
        icon: IconProp.Call,
        tableDescription: "Manage on-call duty user overrides, for example if the user is on leave you can override the on-call duty policy for that user so all the alerts will be routed to the other user.",
    })
], OnCallDutyPolicyTimeLog);
export default OnCallDutyPolicyTimeLog;
//# sourceMappingURL=OnCallDutyPolicyTimeLog.js.map