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 User from "./User";
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Route from "../../Types/API/Route";
import URL from "../../Types/API/URL";
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 TableColumn from "../../Types/Database/TableColumn";
import TableColumnType from "../../Types/Database/TableColumnType";
import TableMetadata from "../../Types/Database/TableMetadata";
import IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import Permission from "../../Types/Permission";
import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
let Reseller = class Reseller extends BaseModel {
    constructor() {
        super(...arguments);
        this.resellerId = undefined;
        this.name = undefined;
        this.description = undefined;
        this.username = undefined;
        this.password = undefined;
        this.createdByUser = undefined;
        this.createdByUserId = undefined;
        this.deletedByUser = undefined;
        this.deletedByUserId = undefined;
        this.changePlanLink = undefined;
        this.hidePhoneNumberOnSignup = undefined;
        this.enableTelemetryFeatures = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.Public],
        update: [],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Resller ID",
        description: "ID that is shared between resller and OneUptime.",
        example: "reseller_1234567890",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Reseller.prototype, "resellerId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Name",
        description: "Name of the reseller",
        example: "Enterprise Solutions Inc.",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Reseller.prototype, "name", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: true,
        title: "Description",
        description: "Description of the reseller",
        example: "Leading provider of monitoring solutions for enterprises",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Reseller.prototype, "description", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: false,
        title: "Username",
        description: "Username of the reseller",
        example: "enterprise_admin",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Reseller.prototype, "username", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        required: true,
        type: TableColumnType.ShortText,
        canReadOnRelationQuery: false,
        title: "Password",
        description: "Password for reseller to login",
        example: "$2b$10$abcdefghijklmnopqrstuvwxyz1234567890",
    }),
    Column({
        nullable: false,
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
    }),
    __metadata("design:type", String)
], Reseller.prototype, "password", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        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)
], Reseller.prototype, "createdByUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        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)
], Reseller.prototype, "createdByUserId", 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)
], Reseller.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)
], Reseller.prototype, "deletedByUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.ShortURL,
        canReadOnRelationQuery: true,
        title: "Change Plan Link",
        description: "Reseller Change plan Link",
        example: "https://reseller.oneuptime.com/change-plan",
    }),
    Column({
        nullable: true,
        type: ColumnType.ShortURL,
        length: ColumnLength.ShortURL,
        transformer: URL.getDatabaseTransformer(),
    }),
    __metadata("design:type", URL)
], Reseller.prototype, "changePlanLink", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.Public],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        canReadOnRelationQuery: true,
        title: "Hide Phone Number on Signup",
        description: "Should we hide the phone number on sign up form based on reseller request?",
        example: true,
    }),
    Column({
        nullable: true,
        type: ColumnType.Boolean,
    }),
    __metadata("design:type", Boolean)
], Reseller.prototype, "hidePhoneNumberOnSignup", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [Permission.Public],
        update: [],
    }),
    TableColumn({
        required: false,
        type: TableColumnType.Boolean,
        canReadOnRelationQuery: true,
        title: "Enable Telemetry Features",
        description: "Should we enable telemetry features for this reseller?",
        defaultValue: false,
        example: false,
    }),
    Column({
        nullable: true,
        default: false,
        type: ColumnType.Boolean,
    }),
    __metadata("design:type", Boolean)
], Reseller.prototype, "enableTelemetryFeatures", void 0);
Reseller = __decorate([
    TableAccessControl({
        create: [],
        read: [Permission.ProjectOwner, Permission.Public],
        delete: [],
        update: [],
    }),
    CrudApiEndpoint(new Route("/reseller")),
    TableMetadata({
        tableName: "Reseller",
        singularName: "Reseller",
        pluralName: "Resellers",
        icon: IconProp.Billing,
        tableDescription: "List of Resellers that sell OneUptime to their customers",
    }),
    Entity({
        name: "Reseller",
    })
], Reseller);
export default Reseller;
//# sourceMappingURL=Reseller.js.map