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 BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
import Project from "./Project";
import StatusPage from "./StatusPage";
import StatusPagePrivateUser from "./StatusPagePrivateUser";
import Route from "../../Types/API/Route";
import { PlanType } from "../../Types/Billing/SubscriptionPlan";
import AllowAccessIfSubscriptionIsUnpaid from "../../Types/Database/AccessControl/AllowAccessIfSubscriptionIsUnpaid";
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
import OwnedThrough from "../../Types/Database/AccessControl/OwnedThrough";
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
import TableBillingAccessControl from "../../Types/Database/AccessControl/TableBillingAccessControl";
import CanAccessIfCanReadOn from "../../Types/Database/CanAccessIfCanReadOn";
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 TenantColumn from "../../Types/Database/TenantColumn";
import HashedString from "../../Types/HashedString";
import IconProp from "../../Types/Icon/IconProp";
import ObjectID from "../../Types/ObjectID";
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
let StatusPagePrivateUserSession = class StatusPagePrivateUserSession extends BaseModel {
    constructor() {
        super(...arguments);
        this.project = undefined;
        this.projectId = undefined;
        this.statusPage = undefined;
        this.statusPageId = undefined;
        this.statusPagePrivateUser = undefined;
        this.statusPagePrivateUserId = undefined;
        this.refreshToken = undefined;
        this.refreshTokenExpiresAt = undefined;
        this.lastActiveAt = undefined;
        this.deviceName = undefined;
        this.deviceType = undefined;
        this.deviceOS = undefined;
        this.deviceBrowser = undefined;
        this.ipAddress = undefined;
        this.userAgent = undefined;
        this.isRevoked = undefined;
        this.revokedAt = undefined;
        this.revokedReason = undefined;
        this.additionalInfo = undefined;
    }
};
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "projectId",
        type: TableColumnType.Entity,
        modelType: Project,
        title: "Project",
        description: "Project that owns this private status page session.",
    }),
    ManyToOne(() => {
        return Project;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "projectId" }),
    __metadata("design:type", Project)
], StatusPagePrivateUserSession.prototype, "project", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Project ID",
        description: "Project identifier for this session.",
        required: true,
        canReadOnRelationQuery: true,
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], StatusPagePrivateUserSession.prototype, "projectId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "statusPageId",
        type: TableColumnType.Entity,
        modelType: StatusPage,
        title: "Status Page",
        description: "Status page associated with this session.",
    }),
    ManyToOne(() => {
        return StatusPage;
    }, {
        eager: false,
        nullable: true,
        onDelete: "CASCADE",
        orphanedRowAction: "nullify",
    }),
    JoinColumn({ name: "statusPageId" }),
    __metadata("design:type", StatusPage)
], StatusPagePrivateUserSession.prototype, "statusPage", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Status Page ID",
        description: "Identifier for the status page.",
        required: true,
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], StatusPagePrivateUserSession.prototype, "statusPageId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        manyToOneRelationColumn: "statusPagePrivateUserId",
        type: TableColumnType.Entity,
        modelType: StatusPagePrivateUser,
        title: "Status Page Private User",
        description: "Private user record associated with this session.",
    }),
    ManyToOne(() => {
        return StatusPagePrivateUser;
    }, {
        eager: false,
        nullable: false,
        onDelete: "CASCADE",
        orphanedRowAction: "delete",
    }),
    JoinColumn({ name: "statusPagePrivateUserId" }),
    __metadata("design:type", StatusPagePrivateUser)
], StatusPagePrivateUserSession.prototype, "statusPagePrivateUser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    Index(),
    TableColumn({
        type: TableColumnType.ObjectID,
        title: "Status Page Private User ID",
        description: "Identifier for the status page private user.",
        required: true,
        canReadOnRelationQuery: true,
    }),
    Column({
        type: ColumnType.ObjectID,
        nullable: false,
        transformer: ObjectID.getDatabaseTransformer(),
    }),
    __metadata("design:type", ObjectID)
], StatusPagePrivateUserSession.prototype, "statusPagePrivateUserId", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    Index({ unique: true }),
    TableColumn({
        type: TableColumnType.HashedString,
        title: "Refresh Token",
        description: "Hashed refresh token for the private user session.",
        required: true,
        hideColumnInDocumentation: true,
    }),
    Column({
        type: ColumnType.HashedString,
        length: ColumnLength.HashedString,
        nullable: false,
        unique: true,
        transformer: HashedString.getDatabaseTransformer(),
    }),
    __metadata("design:type", HashedString)
], StatusPagePrivateUserSession.prototype, "refreshToken", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Date,
        title: "Refresh Token Expires At",
        description: "Expiration timestamp for the refresh token.",
        required: true,
    }),
    Column({
        type: ColumnType.Date,
        nullable: false,
    }),
    __metadata("design:type", Date)
], StatusPagePrivateUserSession.prototype, "refreshTokenExpiresAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Date,
        title: "Last Active At",
        description: "Last time this session was active.",
    }),
    Column({
        type: ColumnType.Date,
        nullable: true,
    }),
    __metadata("design:type", Date)
], StatusPagePrivateUserSession.prototype, "lastActiveAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        title: "Device Name",
        description: "Friendly name for the device used to access the status page.",
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
    }),
    __metadata("design:type", String)
], StatusPagePrivateUserSession.prototype, "deviceName", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        title: "Device Type",
        description: "Type of device (desktop, mobile, etc).",
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
    }),
    __metadata("design:type", String)
], StatusPagePrivateUserSession.prototype, "deviceType", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        title: "Device OS",
        description: "Operating system reported for this session.",
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
    }),
    __metadata("design:type", String)
], StatusPagePrivateUserSession.prototype, "deviceOS", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        title: "Browser",
        description: "Browser or client application used for the session.",
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
    }),
    __metadata("design:type", String)
], StatusPagePrivateUserSession.prototype, "deviceBrowser", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        title: "IP Address",
        description: "IP address recorded for this session.",
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
    }),
    __metadata("design:type", String)
], StatusPagePrivateUserSession.prototype, "ipAddress", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.VeryLongText,
        title: "User Agent",
        description: "User agent string supplied by the client.",
    }),
    Column({
        type: ColumnType.VeryLongText,
        nullable: true,
    }),
    __metadata("design:type", String)
], StatusPagePrivateUserSession.prototype, "userAgent", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Boolean,
        title: "Is Revoked",
        description: "Indicates if the session has been revoked.",
        isDefaultValueColumn: true,
        defaultValue: false,
    }),
    Column({
        type: ColumnType.Boolean,
        nullable: false,
        default: false,
    }),
    __metadata("design:type", Boolean)
], StatusPagePrivateUserSession.prototype, "isRevoked", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.Date,
        title: "Revoked At",
        description: "Timestamp when the session was revoked, if applicable.",
    }),
    Column({
        type: ColumnType.Date,
        nullable: true,
    }),
    __metadata("design:type", Date)
], StatusPagePrivateUserSession.prototype, "revokedAt", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.ShortText,
        title: "Revoked Reason",
        description: "Reason provided for revoking this session.",
    }),
    Column({
        type: ColumnType.ShortText,
        length: ColumnLength.ShortText,
        nullable: true,
    }),
    __metadata("design:type", String)
], StatusPagePrivateUserSession.prototype, "revokedReason", void 0);
__decorate([
    ColumnAccessControl({
        create: [],
        read: [],
        update: [],
    }),
    TableColumn({
        type: TableColumnType.JSON,
        title: "Additional Info",
        description: "Flexible JSON payload for storing structured metadata.",
    }),
    Column({
        type: ColumnType.JSON,
        nullable: true,
    }),
    __metadata("design:type", Object)
], StatusPagePrivateUserSession.prototype, "additionalInfo", void 0);
StatusPagePrivateUserSession = __decorate([
    AllowAccessIfSubscriptionIsUnpaid(),
    TableBillingAccessControl({
        create: PlanType.Growth,
        read: PlanType.Growth,
        update: PlanType.Growth,
        delete: PlanType.Growth,
    }),
    CanAccessIfCanReadOn("statusPage"),
    TenantColumn("projectId"),
    TableAccessControl({
        create: [],
        read: [],
        delete: [],
        update: [],
    }),
    CrudApiEndpoint(new Route("/status-page-private-user-session")),
    OwnedThrough("statusPageId", StatusPage),
    Entity({
        name: "StatusPagePrivateUserSession",
    }),
    TableMetadata({
        tableName: "StatusPagePrivateUserSession",
        singularName: "Status Page Private User Session",
        pluralName: "Status Page Private User Sessions",
        icon: IconProp.Lock,
        tableDescription: "Stores status page private user sessions, refresh tokens, and device metadata for secure access control.",
    })
], StatusPagePrivateUserSession);
export default StatusPagePrivateUserSession;
//# sourceMappingURL=StatusPagePrivateUserSession.js.map