erp-construccion/backend/dist/modules/auth/entities/user-role.entity.js

79 lines
3.3 KiB
JavaScript

"use strict";
/**
* UserRole Entity
* Relación usuarios-roles con soporte multi-tenant
*
* @module Auth
*/
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.UserRole = void 0;
const typeorm_1 = require("typeorm");
const user_entity_1 = require("../../core/entities/user.entity");
const role_entity_1 = require("./role.entity");
const tenant_entity_1 = require("../../core/entities/tenant.entity");
let UserRole = class UserRole {
id;
userId;
roleId;
tenantId;
assignedBy;
assignedAt;
// Relations
user;
role;
tenant;
};
exports.UserRole = UserRole;
__decorate([
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
__metadata("design:type", String)
], UserRole.prototype, "id", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'user_id', type: 'uuid' }),
__metadata("design:type", String)
], UserRole.prototype, "userId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'role_id', type: 'uuid' }),
__metadata("design:type", String)
], UserRole.prototype, "roleId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], UserRole.prototype, "tenantId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'assigned_by', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], UserRole.prototype, "assignedBy", void 0);
__decorate([
(0, typeorm_1.CreateDateColumn)({ name: 'assigned_at', type: 'timestamptz' }),
__metadata("design:type", Date)
], UserRole.prototype, "assignedAt", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, { onDelete: 'CASCADE' }),
(0, typeorm_1.JoinColumn)({ name: 'user_id' }),
__metadata("design:type", user_entity_1.User)
], UserRole.prototype, "user", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => role_entity_1.Role, (role) => role.userRoles, { onDelete: 'CASCADE' }),
(0, typeorm_1.JoinColumn)({ name: 'role_id' }),
__metadata("design:type", role_entity_1.Role)
], UserRole.prototype, "role", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => tenant_entity_1.Tenant, { onDelete: 'CASCADE' }),
(0, typeorm_1.JoinColumn)({ name: 'tenant_id' }),
__metadata("design:type", tenant_entity_1.Tenant)
], UserRole.prototype, "tenant", void 0);
exports.UserRole = UserRole = __decorate([
(0, typeorm_1.Entity)({ schema: 'auth', name: 'user_roles' }),
(0, typeorm_1.Index)(['userId', 'roleId', 'tenantId'], { unique: true })
], UserRole);
//# sourceMappingURL=user-role.entity.js.map