112 lines
4.3 KiB
JavaScript
112 lines
4.3 KiB
JavaScript
"use strict";
|
|
/**
|
|
* User Entity
|
|
* Entidad de usuarios del sistema
|
|
*
|
|
* @module Core
|
|
* @table core.users
|
|
*/
|
|
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.User = void 0;
|
|
const typeorm_1 = require("typeorm");
|
|
const tenant_entity_1 = require("./tenant.entity");
|
|
let User = class User {
|
|
id;
|
|
tenantId;
|
|
email;
|
|
username;
|
|
passwordHash;
|
|
firstName;
|
|
lastName;
|
|
roles;
|
|
isActive;
|
|
lastLoginAt;
|
|
defaultTenantId;
|
|
deletedAt;
|
|
// Placeholder para relación de roles (se implementará en ST-004)
|
|
userRoles;
|
|
createdAt;
|
|
updatedAt;
|
|
// Relations
|
|
tenant;
|
|
// Computed property
|
|
get fullName() {
|
|
return [this.firstName, this.lastName].filter(Boolean).join(' ') || this.email;
|
|
}
|
|
};
|
|
exports.User = User;
|
|
__decorate([
|
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
__metadata("design:type", String)
|
|
], User.prototype, "id", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", String)
|
|
], User.prototype, "tenantId", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ type: 'varchar', length: 255 }),
|
|
__metadata("design:type", String)
|
|
], User.prototype, "email", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: true }),
|
|
__metadata("design:type", String)
|
|
], User.prototype, "username", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'password_hash', type: 'varchar', length: 255, select: false }),
|
|
__metadata("design:type", String)
|
|
], User.prototype, "passwordHash", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'first_name', type: 'varchar', length: 100, nullable: true }),
|
|
__metadata("design:type", String)
|
|
], User.prototype, "firstName", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'last_name', type: 'varchar', length: 100, nullable: true }),
|
|
__metadata("design:type", String)
|
|
], User.prototype, "lastName", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ type: 'varchar', array: true, default: ['viewer'] }),
|
|
__metadata("design:type", Array)
|
|
], User.prototype, "roles", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'is_active', type: 'boolean', default: true }),
|
|
__metadata("design:type", Boolean)
|
|
], User.prototype, "isActive", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'last_login_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Date)
|
|
], User.prototype, "lastLoginAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'default_tenant_id', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", String)
|
|
], User.prototype, "defaultTenantId", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'deleted_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Date)
|
|
], User.prototype, "deletedAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
__metadata("design:type", Date)
|
|
], User.prototype, "createdAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
|
|
__metadata("design:type", Date)
|
|
], User.prototype, "updatedAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.ManyToOne)(() => tenant_entity_1.Tenant, (tenant) => tenant.users),
|
|
(0, typeorm_1.JoinColumn)({ name: 'tenant_id' }),
|
|
__metadata("design:type", tenant_entity_1.Tenant)
|
|
], User.prototype, "tenant", void 0);
|
|
exports.User = User = __decorate([
|
|
(0, typeorm_1.Entity)({ schema: 'auth', name: 'users' }),
|
|
(0, typeorm_1.Index)(['tenantId', 'email'], { unique: true })
|
|
], User);
|
|
//# sourceMappingURL=user.entity.js.map
|