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 File from "./File";
import UserModel from "../../Models/DatabaseModels/DatabaseBaseModel/UserModel";
import Route from "../../Types/API/Route";
import CompanySize from "../../Types/Company/CompanySize";
import JobRole from "../../Types/Company/JobRole";
import AllowAccessIfSubscriptionIsUnpaid from "../../Types/Database/AccessControl/AllowAccessIfSubscriptionIsUnpaid";
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 CurrentUserCanAccessRecordBy from "../../Types/Database/CurrentUserCanAccessRecordBy";
import EnableDocumentation from "../../Types/Database/EnableDocumentation";
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 Email from "../../Types/Email";
import HashedString from "../../Types/HashedString";
import IconProp from "../../Types/Icon/IconProp";
import Name from "../../Types/Name";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import Phone from "../../Types/Phone";
import Timezone from "../../Types/Timezone";
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
let User = class User extends UserModel {
    constructor() {
        super(...arguments);
        this.name = undefined;
        this.email = undefined;
        this.newUnverifiedTemporaryEmail = undefined;
        this.slug = undefined;
        this.password = undefined;
        this.isEmailVerified = undefined;
        this.companyName = undefined;
        this.jobRole = undefined;
        this.companySize = undefined;
        this.referral = undefined;
        this.companyPhoneNumber = undefined;
        this.profilePictureFile = undefined;
        this.profilePictureId = undefined;
        this.twoFactorAuthEnabled = undefined;
        this.paymentProviderCustomerId = undefined;
        this.resetPasswordToken = undefined;
        this.resetPasswordExpires = undefined;
        this.webauthnChallenge = undefined;
        this.webauthnChallengeExpiresAt = undefined;
        this.timezone = undefined;
        this.lastActive = undefined;
        this.promotionName = undefined;
        this.isDisabled = undefined;
        this.paymentFailedDate = undefined;
        this.isMasterAdmin = undefined;
        this.isBlocked = undefined;
        this.alertPhoneVerificationCode = undefined;
        this.utmSource = undefined;
        this.utmMedium = undefined;
        this.utmCampaign = undefined;
        this.utmTerm = undefined;
        this.utmContent = undefined;
        this.utmUrl = undefined;
        this.alertPhoneVerificationCodeRequestTime = undefined;
        this.tempAlertPhoneNumber = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.enableTwoFactorAuth = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({
        type: TableColumnType.Name,
        canReadOnRelationQuery: true,
        example: "John Smith",
    }),
    Column({
        type: ColumnType.Name,
        length: ColumnLength.Name,
        nullable: true,
        unique: false,
        transformer: Name.getDatabaseTransformer(),
    }),
    __metadata("design:type", Name)
], User.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({
        title: "Email",
        required: true,
        unique: true,
        type: TableColumnType.Email,
        canReadOnRelationQuery: true,
        example: "john.smith@company.com",
    }),
    Column({
        type: ColumnType.Email,
        length: ColumnLength.Email,
        unique: true,
        nullable: false,
        transformer: Email.getDatabaseTransformer(),
    }),
    __metadata("design:type", Email)
], User.prototype, "email", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({ type: TableColumnType.Email }),
    Column({
        type: ColumnType.Email,
        length: ColumnLength.Email,
        unique: false,
        nullable: true,
        transformer: Email.getDatabaseTransformer(),
    }),
    __metadata("design:type", String)
], User.prototype, "newUnverifiedTemporaryEmail", void 0);
__decorate([
    Index(),
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        required: true,
        unique: true,
        type: TableColumnType.Slug,
        computed: true,
        title: "Slug",
        description: "Friendly globally unique name for your object",
        example: "john-smith",
    }),
    Column({
        nullable: false,
        type: ColumnType.Slug,
        length: ColumnLength.Slug,
        unique: true,
    }),
    __metadata("design:type", String)
], User.prototype, "slug", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({
        title: "Password",
        hashed: true,
        type: TableColumnType.HashedString,
    }),
    Column({
        type: ColumnType.HashedString,
        length: ColumnLength.HashedString,
        unique: false,
        nullable: true,
        transformer: HashedString.getDatabaseTransformer(),
    }),
    __metadata("design:type", HashedString)
], User.prototype, "password", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.CurrentUser],
        update: [],
    }),
    TableColumn({
        isDefaultValueColumn: true,
        type: TableColumnType.Boolean,
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        default: false,
    }),
    __metadata("design:type", Boolean)
], User.prototype, "isEmailVerified", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({ type: TableColumnType.ShortText }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "companyName", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({ type: TableColumnType.ShortText }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "jobRole", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({ type: TableColumnType.ShortText }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "companySize", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({ type: TableColumnType.ShortText }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "referral", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({ type: TableColumnType.Phone }),
    Column({
        type: ColumnType.Phone,
        length: ColumnLength.Phone,
        nullable: true,
        unique: false,
        transformer: Phone.getDatabaseTransformer(),
    }),
    __metadata("design:type", Phone)
], User.prototype, "companyPhoneNumber", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({
        manyToOneRelationColumn: "profilePictureId",
        type: TableColumnType.Entity,
        modelType: File,
    }),
    ManyToOne(() => {
        return File;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "delete",
    }),
    JoinColumn({ name: "profilePictureId" }),
    __metadata("design:type", File)
], User.prototype, "profilePictureFile", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({
        type: TableColumnType.ObjectID,
        canReadOnRelationQuery: true,
        example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: true,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], User.prototype, "profilePictureId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({
        isDefaultValueColumn: true,
        required: true,
        type: TableColumnType.Boolean,
        canReadOnRelationQuery: true,
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        default: false,
        nullable: false,
        unique: false,
    }),
    __metadata("design:type", Boolean)
], User.prototype, "twoFactorAuthEnabled", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.ShortText }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "paymentProviderCustomerId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.ShortText }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "resetPasswordToken", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.Date }),
    Column({
        type: ColumnType.Date,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Date)
], User.prototype, "resetPasswordExpires", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.ShortText }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "webauthnChallenge", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.Date }),
    Column({
        type: ColumnType.Date,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Date)
], User.prototype, "webauthnChallengeExpiresAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({ type: TableColumnType.ShortText }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "timezone", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.Date }),
    Column({
        type: ColumnType.Date,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Date)
], User.prototype, "lastActive", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        hideColumnInDocumentation: true,
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "promotionName", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.CustomerSupport],
        update: [Permission.CustomerSupport],
    }),
    TableColumn({
        isDefaultValueColumn: true,
        required: true,
        type: TableColumnType.Boolean,
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        unique: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], User.prototype, "isDisabled", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.Date }),
    Column({
        type: ColumnType.Date,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Date)
], User.prototype, "paymentFailedDate", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        isDefaultValueColumn: true,
        required: true,
        type: TableColumnType.Boolean,
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        unique: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], User.prototype, "isMasterAdmin", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.CustomerSupport],
        update: [Permission.CustomerSupport],
    }),
    TableColumn({
        isDefaultValueColumn: true,
        required: true,
        type: TableColumnType.Boolean,
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        unique: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], User.prototype, "isBlocked", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.OTP,
        computed: true,
    }),
    Column({
        type: ColumnType.OTP,
        length: ColumnLength.OTP,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "alertPhoneVerificationCode", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.LongText,
        hideColumnInDocumentation: true,
    }),
    Column({
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "utmSource", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.LongText,
        hideColumnInDocumentation: true,
    }),
    Column({
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "utmMedium", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.LongText,
        hideColumnInDocumentation: true,
    }),
    Column({
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "utmCampaign", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.LongText,
        hideColumnInDocumentation: true,
    }),
    Column({
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "utmTerm", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.LongText,
        hideColumnInDocumentation: true,
    }),
    Column({
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "utmContent", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.Public],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.LongText,
        hideColumnInDocumentation: true,
    }),
    Column({
        type: ColumnType.LongText,
        length: ColumnLength.LongText,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", String)
], User.prototype, "utmUrl", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.Date }),
    Column({
        type: ColumnType.Date,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Date)
], User.prototype, "alertPhoneVerificationCodeRequestTime", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({ type: TableColumnType.Phone }),
    Column({
        type: ColumnType.Phone,
        length: ColumnLength.Phone,
        nullable: true,
        unique: false,
    }),
    __metadata("design:type", Phone)
], User.prototype, "tempAlertPhoneNumber", 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)",
    }),
    ManyToOne(() => {
        return User;
    }, {
        cascade: false,
        eager: false,
        nullable: true,
        onDelete: "SET NULL",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "deletedByUserId" }),
    __metadata("design:type", User)
], User.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)
], User.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [Permission.CurrentUser],
        read: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    TableColumn({
        title: "Two Factor Auth Enabled",
        description: "Is two factor authentication enabled?",
        isDefaultValueColumn: true,
        type: TableColumnType.Boolean,
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        default: false,
    }),
    __metadata("design:type", Boolean)
], User.prototype, "enableTwoFactorAuth", void 0);
User = __decorate([
    EnableDocumentation({
        isMasterAdminApiDocs: true,
    }),
    AllowAccessIfSubscriptionIsUnpaid(),
    TableAccessControl({
        create: [],
        read: [Permission.CurrentUser],
        delete: [Permission.CurrentUser],
        update: [Permission.CurrentUser],
    }),
    CrudApiEndpoint(new Route("/user")),
    SlugifyColumn("name", "slug"),
    Entity({
        name: "User",
    }),
    TableMetadata({
        tableName: "User",
        singularName: "User",
        pluralName: "Users",
        icon: IconProp.User,
        tableDescription: "A signed up or invited OneUptime user.",
    }),
    CurrentUserCanAccessRecordBy("_id")
], User);
export default User;
//# sourceMappingURL=User.js.map