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 IncomingCallPolicy from "./IncomingCallPolicy";
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 IncomingCallLog = class IncomingCallLog extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.incomingCallPolicy = undefined;
        this.incomingCallPolicyId = undefined;
        this.callerPhoneNumber = undefined;
        this.routingPhoneNumber = undefined;
        this.callProviderCallId = undefined;
        this.status = undefined;
        this.statusMessage = undefined;
        this.callDurationInSeconds = undefined;
        this.callCostInUSDCents = undefined;
        this.incomingCallCostInUSDCents = undefined;
        this.outgoingCallCostInUSDCents = undefined;
        this.startedAt = undefined;
        this.endedAt = undefined;
        this.answeredByUser = undefined;
        this.answeredByUserId = undefined;
        this.currentEscalationRuleOrder = undefined;
        this.repeatCount = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        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)
], IncomingCallLog.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        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)
], IncomingCallLog.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "incomingCallPolicyId",
        type: TableColumnType.Entity,
        modelType: IncomingCallPolicy,
        title: "Incoming Call Policy",
        description: "Relation to the Incoming Call Policy",
    }),
    ManyToOne(() => {
        return IncomingCallPolicy;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "incomingCallPolicyId" }),
    __metadata("design:type", IncomingCallPolicy)
], IncomingCallLog.prototype, "incomingCallPolicy", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        required: true,
        canReadOnRelationQuery: true,
        title: "Incoming Call Policy ID",
        description: "ID of the Incoming Call Policy",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncomingCallLog.prototype, "incomingCallPolicyId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Phone,
        title: "Caller Phone Number",
        description: "Incoming caller's phone number",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: true,
        type: ColumnType.Phone,
        length: ColumnLength.Phone,
        transformer: Phone.getDatabaseTransformer(),
    }),
    __metadata("design:type", Phone)
], IncomingCallLog.prototype, "callerPhoneNumber", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Phone,
        title: "Routing Phone Number",
        description: "The routing number that was called",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: true,
        type: ColumnType.Phone,
        length: ColumnLength.Phone,
        transformer: Phone.getDatabaseTransformer(),
    }),
    __metadata("design:type", Phone)
], IncomingCallLog.prototype, "routingPhoneNumber", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        required: false,
        type: TableColumnType.ShortText,
        title: "Call Provider Call ID",
        description: "Call provider's call identifier",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], IncomingCallLog.prototype, "callProviderCallId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        title: "Status",
        description: "Current status of the incoming call",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        default: IncomingCallStatus.Initiated,
    }),
    __metadata("design:type", String)
], IncomingCallLog.prototype, "status", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    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)
], IncomingCallLog.prototype, "statusMessage", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Call Duration (Seconds)",
        description: "Total call duration in seconds",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: true,
        type: ColumnType.Number,
        default: 0,
    }),
    __metadata("design:type", Number)
], IncomingCallLog.prototype, "callDurationInSeconds", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Call Cost (USD Cents)",
        description: "Total cost for this call in USD cents",
    }),
    Column({
        nullable: true,
        type: ColumnType.Number,
        default: 0,
    }),
    __metadata("design:type", Number)
], IncomingCallLog.prototype, "callCostInUSDCents", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Incoming Call Cost (USD Cents)",
        description: "Cost for incoming leg in USD cents",
    }),
    Column({
        nullable: true,
        type: ColumnType.Number,
        default: 0,
    }),
    __metadata("design:type", Number)
], IncomingCallLog.prototype, "incomingCallCostInUSDCents", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Outgoing Call Cost (USD Cents)",
        description: "Cost for all forwarding attempts in USD cents",
    }),
    Column({
        nullable: true,
        type: ColumnType.Number,
        default: 0,
    }),
    __metadata("design:type", Number)
], IncomingCallLog.prototype, "outgoingCallCostInUSDCents", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    Index(),
    TableColumn({
        required: false,
        type: TableColumnType.Date,
        title: "Started At",
        description: "When the call started",
        canReadOnRelationQuery: true,
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], IncomingCallLog.prototype, "startedAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Date,
        title: "Ended At",
        description: "When the call ended",
    }),
    Column({
        nullable: true,
        type: ColumnType.Date,
    }),
    __metadata("design:type", Date)
], IncomingCallLog.prototype, "endedAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "answeredByUserId",
        type: TableColumnType.Entity,
        modelType: User,
        title: "Answered By User",
        description: "User who answered the call",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "answeredByUserId" }),
    __metadata("design:type", User)
], IncomingCallLog.prototype, "answeredByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Answered By User ID",
        description: "User ID who answered the call",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], IncomingCallLog.prototype, "answeredByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Current Escalation Rule Order",
        description: "The current escalation rule order being processed",
    }),
    Column({
        nullable: true,
        type: ColumnType.Number,
        default: 1,
    }),
    __metadata("design:type", Number)
], IncomingCallLog.prototype, "currentEscalationRuleOrder", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Number,
        title: "Repeat Count",
        description: "Number of times the policy has been repeated",
    }),
    Column({
        nullable: true,
        type: ColumnType.Number,
        default: 0,
    }),
    __metadata("design:type", Number)
], IncomingCallLog.prototype, "repeatCount", void 0);
IncomingCallLog = __decorate([
    EnableDocumentation(),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.ReadProjectIncomingCallLog,
        ],
        delete: [],
        update: [],
    }),
    CrudApiEndpoint(new Route("/incoming-call-log")),
    Entity({
        name: "IncomingCallLog",
    }),
    TableMetadata({
        tableName: "IncomingCallLog",
        singularName: "Incoming Call Log",
        pluralName: "Incoming Call Logs",
        icon: IconProp.Call,
        tableDescription: "Parent log for each incoming call instance. Groups all escalation attempts together.",
    })
], IncomingCallLog);
export default IncomingCallLog;
//# sourceMappingURL=IncomingCallLog.js.map