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 IncomingCallLog from "./IncomingCallLog";
import IncomingCallPolicyEscalationRule from "./IncomingCallPolicyEscalationRule";
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 ColumnLength from "../../Types/Database/ColumnLength";
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 IncomingCallStatus from "../../Types/IncomingCall/IncomingCallStatus";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import Phone from "../../Types/Phone";
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
let IncomingCallLogItem = class IncomingCallLogItem extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.incomingCallLog = undefined;
        this.incomingCallLogId = undefined;
        this.incomingCallPolicyEscalationRule = undefined;
        this.incomingCallPolicyEscalationRuleId = undefined;
        this.user = undefined;
        this.userId = undefined;
        this.userPhoneNumber = undefined;
        this.status = undefined;
        this.statusMessage = undefined;
        this.dialDurationInSeconds = undefined;
        this.callCostInUSDCents = undefined;
        this.startedAt = undefined;
        this.endedAt = undefined;
        this.isAnswered = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        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)
], IncomingCallLogItem.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        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)
], IncomingCallLogItem.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "incomingCallLogId",
        type: TableColumnType.Entity,
        modelType: IncomingCallLog,
        title: "Incoming Call Log",
        description: "Relation to the parent Incoming Call Log",
    }),
    ManyToOne(() => {
        return IncomingCallLog;
    }, {
        eager: false,
        nullable: false,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "incomingCallLogId" }),
    __metadata("design:type", IncomingCallLog)
], IncomingCallLogItem.prototype, "incomingCallLog", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Incoming Call Log ID",
        description: "ID of the parent Incoming Call Log",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncomingCallLogItem.prototype, "incomingCallLogId", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "incomingCallPolicyEscalationRuleId",
        type: TableColumnType.Entity,
        modelType: IncomingCallPolicyEscalationRule,
        title: "Escalation Rule",
        description: "Which escalation rule was used",
    }),
    ManyToOne(() => {
        return IncomingCallPolicyEscalationRule;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "incomingCallPolicyEscalationRuleId" }),
    __metadata("design:type", IncomingCallPolicyEscalationRule)
], IncomingCallLogItem.prototype, "incomingCallPolicyEscalationRule", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Escalation Rule ID",
        description: "ID of the escalation rule used",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncomingCallLogItem.prototype, "incomingCallPolicyEscalationRuleId", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "userId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "User",
        description: "User who was called",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "userId" }),
    __metadata("design:type", User)
], IncomingCallLogItem.prototype, "user", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "User ID",
        description: "User ID who was called",
        canReadOnRelationQuery: true,
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncomingCallLogItem.prototype, "userId", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Phone,
        title: "User Phone Number",
        description: "Phone number that was dialed",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: true,
        type: ColumnType.Phone,
        length: ColumnLength.Phone,
        transformer: Phone.getDatabaseTransformer(),
    }),
    __metadata("design:type", Phone)
], IncomingCallLogItem.prototype, "userPhoneNumber", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [Permission.ProjectOwner, Permission.ProjectAdmin],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        title: "Status",
        description: "Status of this dial attempt",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        default: IncomingCallStatus.Ringing,
    }),
    __metadata("design:type", String)
], IncomingCallLogItem.prototype, "status", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [Permission.ProjectOwner, Permission.ProjectAdmin],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Status Message",
        description: "Additional status information",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], IncomingCallLogItem.prototype, "statusMessage", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [Permission.ProjectOwner, Permission.ProjectAdmin],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Dial Duration (Seconds)",
        description: "How long this dial lasted in seconds",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: true,
        type: ColumnType.Number,
        default: 0,
    }),
    __metadata("design:type", Number)
], IncomingCallLogItem.prototype, "dialDurationInSeconds", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [Permission.ProjectOwner, Permission.ProjectAdmin],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Call Cost (USD Cents)",
        description: "Cost for this dial attempt in USD cents",
    }),
    Column({
        nullable: true,
        type: ColumnType.Number,
        default: 0,
    }),
    __metadata("design:type", Number)
], IncomingCallLogItem.prototype, "callCostInUSDCents", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [Permission.ProjectOwner, Permission.ProjectAdmin],
    }),
    Index(),
    TableColumn({
        required: false,
        type: TableColumnType.Date,
        title: "Started At",
        description: "When dial started",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], IncomingCallLogItem.prototype, "startedAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [Permission.ProjectOwner, Permission.ProjectAdmin],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Date,
        title: "Ended At",
        description: "When dial ended",
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], IncomingCallLogItem.prototype, "endedAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        update: [Permission.ProjectOwner, Permission.ProjectAdmin],
    }),
    TableColumn({
        required: true,
        isDefaultValueColumn: true,
        type: TableColumnType.Boolean,
        title: "Is Answered",
        description: "Whether this user answered the call",
        defaultValue: false,
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: false,
        default: false,
        type: ColumnType.Boolean,
    }),
    __metadata("design:type", Boolean)
], IncomingCallLogItem.prototype, "isAnswered", void 0);
IncomingCallLogItem = __decorate([
    EnableDocumentation(),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [Permission.ProjectOwner, Permission.ProjectAdmin],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLogItem,
        ],
        delete: [Permission.ProjectOwner, Permission.ProjectAdmin],
        update: [Permission.ProjectOwner, Permission.ProjectAdmin],
    }),
    CrudApiEndpoint(new Route("/incoming-call-log-item")),
    Entity({
        name: "IncomingCallLogItem",
    }),
    TableMetadata({
        tableName: "IncomingCallLogItem",
        singularName: "Incoming Call Log Item",
        pluralName: "Incoming Call Log Items",
        icon: IconProp.Call,
        tableDescription: "Child log for each escalation attempt / user ring within a call.",
    })
], IncomingCallLogItem);
export default IncomingCallLogItem;
//# sourceMappingURL=IncomingCallLogItem.js.map