"use strict";
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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NestAuthRole = void 0;
const typeorm_1 = require("typeorm");
const auth_constants_1 = require("../../auth.constants");
const tenant_entity_1 = require("../../tenant/entities/tenant.entity");
const platform_access_entity_1 = require("../../user/entities/platform-access.entity");
const user_access_entity_1 = require("../../user/entities/user-access.entity");
const role_permission_entity_1 = require("./role-permission.entity");
let NestAuthRole = class NestAuthRole extends typeorm_1.BaseEntity {
    id;
    name;
    guard;
    tenantId;
    tenant;
    isSystem;
    isActive;
    rolePermissions;
    createdAt;
    updatedAt;
    userAccesses;
    platformAccesses;
};
exports.NestAuthRole = NestAuthRole;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    __metadata("design:type", String)
], NestAuthRole.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)(),
    __metadata("design:type", String)
], NestAuthRole.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true, default: auth_constants_1.DEFAULT_GUARD_NAME }),
    __metadata("design:type", String)
], NestAuthRole.prototype, "guard", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    (0, typeorm_1.RelationId)((role) => role.tenant),
    __metadata("design:type", String)
], NestAuthRole.prototype, "tenantId", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => tenant_entity_1.NestAuthTenant, { onDelete: 'CASCADE' }),
    __metadata("design:type", tenant_entity_1.NestAuthTenant)
], NestAuthRole.prototype, "tenant", void 0);
__decorate([
    (0, typeorm_1.Column)({ default: false }),
    __metadata("design:type", Boolean)
], NestAuthRole.prototype, "isSystem", void 0);
__decorate([
    (0, typeorm_1.Column)({ default: true }),
    __metadata("design:type", Boolean)
], NestAuthRole.prototype, "isActive", void 0);
__decorate([
    (0, typeorm_1.OneToMany)(() => role_permission_entity_1.NestAuthRolePermission, rolePermission => rolePermission.role),
    __metadata("design:type", Array)
], NestAuthRole.prototype, "rolePermissions", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)(),
    __metadata("design:type", Date)
], NestAuthRole.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)(),
    __metadata("design:type", Date)
], NestAuthRole.prototype, "updatedAt", void 0);
__decorate([
    (0, typeorm_1.ManyToMany)(() => user_access_entity_1.NestAuthUserAccess, access => access.roles, { onDelete: 'CASCADE' }),
    __metadata("design:type", Array)
], NestAuthRole.prototype, "userAccesses", void 0);
__decorate([
    (0, typeorm_1.ManyToMany)(() => platform_access_entity_1.NestAuthPlatformAccess, access => access.roles, { onDelete: 'CASCADE' }),
    __metadata("design:type", Array)
], NestAuthRole.prototype, "platformAccesses", void 0);
exports.NestAuthRole = NestAuthRole = __decorate([
    (0, typeorm_1.Entity)('nest_auth_roles'),
    (0, typeorm_1.Unique)(['name', 'guard', 'tenantId'])
], NestAuthRole);
//# sourceMappingURL=role.entity.js.map