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 Project from "./Project";
import User from "./User";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
import { PlanType } from "../../Types/Billing/SubscriptionPlan";
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import TableBillingAccessControl from "../../Types/Database/AccessControl/TableBillingAccessControl";
import ColumnLength from "../../Types/Database/ColumnLength";
import ColumnType from "../../Types/Database/ColumnType";
import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
import SlugifyColumn from "../../Types/Database/SlugifyColumn";
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 UniqueColumnBy from "../../Types/Database/UniqueColumnBy";
import IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import Phone from "../../Types/Phone";
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
let ProjectCallSMSConfig = class ProjectCallSMSConfig extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.name = undefined;
        this.slug = undefined;
        this.description = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        // Twilio config.
        this.twilioAccountSID = undefined;
        this.twilioAuthToken = undefined;
        this.twilioPrimaryPhoneNumber = undefined;
        this.twilioSecondaryPhoneNumbers = undefined; // phone numbers separated by comma
        this.isProjectDefault = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        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)
], ProjectCallSMSConfig.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        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)
], ProjectCallSMSConfig.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectCallSMSConfig,
        ],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        example: "Production Twilio Config",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    UniqueColumnBy("projectId"),
    __metadata("design:type", String)
], ProjectCallSMSConfig.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        update: [],
    }),
    TableColumn({
        required: true,
        unique: true,
        type: TableColumnType.Slug,
        computed: true,
        title: "Slug",
        description: "Friendly globally unique name for your object",
        example: "production-twilio-config",
    }),
    Column({
        nullable: false,
        type: ColumnType.Slug,
        length: ColumnLength.Slug,
    }),
    __metadata("design:type", String)
], ProjectCallSMSConfig.prototype, "slug", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectCallSMSConfig,
        ],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.LongText,
        title: "Description",
        description: "Friendly description that will help you remember",
        example: "Twilio configuration for production SMS and call notifications",
    }),
    Column({
        nullable: true,
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
    }),
    __metadata("design:type", String)
], ProjectCallSMSConfig.prototype, "description", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        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: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
    }),
    ManyToOne(() => {
        return User;
    }, {
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "createdByUserId" }),
    __metadata("design:type", User)
], ProjectCallSMSConfig.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        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: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], ProjectCallSMSConfig.prototype, "createdByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        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: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
    }),
    ManyToOne(() => {
        return User;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "deletedByUserId" }),
    __metadata("design:type", User)
], ProjectCallSMSConfig.prototype, "deletedByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        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: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], ProjectCallSMSConfig.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectCallSMSConfig,
        ],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        title: "Twilio Account SID",
        description: "Account SID for your Twilio Account",
        example: "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: true,
    }),
    __metadata("design:type", String)
], ProjectCallSMSConfig.prototype, "twilioAccountSID", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectCallSMSConfig,
        ],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        title: "Twilio Auth Token",
        description: "Auth Token for your Twilio Account",
        example: "your-twilio-auth-token",
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: true,
    }),
    __metadata("design:type", String)
], ProjectCallSMSConfig.prototype, "twilioAuthToken", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectCallSMSConfig,
        ],
    }),
    TableColumn({
        type: TableColumnType.Phone,
        title: "Twilio Primary Phone Number",
        description: "Primary Phone Number for your Twilio account",
        example: "+15551234567",
    }),
    Column({
        type: ColumnType.Phone,
        length: ColumnLength.Phone,
        nullable: true,
        unique: false,
        transformer: Phone.getDatabaseTransformer(),
    }),
    __metadata("design:type", Phone)
], ProjectCallSMSConfig.prototype, "twilioPrimaryPhoneNumber", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectCallSMSConfig,
        ],
    }),
    TableColumn({
        type: TableColumnType.LongText,
        title: "Twilio Secondary Phone Numbers",
        description: "Secondary Phone Number for your Twilio account",
        example: "+15551234568,+15551234569",
    }),
    Column({
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], ProjectCallSMSConfig.prototype, "twilioSecondaryPhoneNumbers", void 0);
__decorate([
    ColumnAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectCallSMSConfig,
        ],
    }),
    TableColumn({
        isDefaultValueColumn: true,
        required: true,
        type: TableColumnType.Boolean,
        title: "Is Project Default",
        description: "When set, all SMS and Calls sent to project team members (on-call notifications, alerts, verification codes, etc.) will use this Twilio config instead of the global config. Only one Twilio config per project can be the project default. This does not affect status pages — they use the config explicitly assigned to each status page.",
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        unique: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], ProjectCallSMSConfig.prototype, "isProjectDefault", void 0);
ProjectCallSMSConfig = __decorate([
    TableBillingAccessControl({
        create: PlanType.Growth,
        read: PlanType.Growth,
        update: PlanType.Growth,
        delete: PlanType.Growth,
    }),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.CreateProjectCallSMSConfig,
        ],
        read: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.ProjectMember,
            Permission.Viewer,
            Permission.SettingsAdmin,
            Permission.SettingsMember,
            Permission.SettingsViewer,
            Permission.ReadProjectCallSMSConfig,
        ],
        delete: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.DeleteProjectCallSMSConfig,
        ],
        update: [
            Permission.ProjectOwner,
            Permission.ProjectAdmin,
            Permission.EditProjectCallSMSConfig,
        ],
    }),
    CrudApiEndpoint(new Route("/call-sms-config")),
    SlugifyColumn("name", "slug"),
    TableMetadata({
        tableName: "ProjectCallSMSConfig",
        singularName: "Call and SMS Config",
        pluralName: "Call and SMS Configs",
        icon: IconProp.Email,
        tableDescription: "Manage Custom SMTP Servers for your project",
    }),
    Entity({
        name: "ProjectCallSMSConfig",
    })
], ProjectCallSMSConfig);
export default ProjectCallSMSConfig;
//# sourceMappingURL=ProjectCallSMSConfig.js.map