@upv/ushi-shared
Version:
Shared DTOs, types, and utilities for the USHI platform (LMS, Trials, Social, Wallet).
74 lines (73 loc) • 2.06 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const BaseDto_1 = __importDefault(require("../base/BaseDto"));
/**
* RoleAssignmentDto
*
* DTO class for managing user roles within scoped domains and contexts.
* Supports auditing, expiration, and status tracking.
*/
class RoleAssignmentDto extends BaseDto_1.default {
constructor(data) {
super(data);
this._userId = data.userId;
this._role = data.role;
this._domain = data.domain;
this._contextId = data.contextId;
this._assignedBy = data.assignedBy;
this._expiresAt = data.expiresAt;
this._status = data.status ?? 'active';
this._revokedAt = data.revokedAt;
this._revokedBy = data.revokedBy;
this._notes = data.notes;
}
async serialize() {
return {
...(await this.serializeBase()),
userId: this._userId,
role: this._role,
domain: this._domain,
contextId: this._contextId ?? null,
assignedBy: this._assignedBy ?? null,
expiresAt: this._expiresAt ?? null,
status: this._status,
revokedAt: this._revokedAt ?? null,
revokedBy: this._revokedBy ?? null,
notes: this._notes ?? null,
};
}
get userId() {
return this._userId;
}
get role() {
return this._role;
}
get domain() {
return this._domain;
}
get contextId() {
return this._contextId;
}
get assignedBy() {
return this._assignedBy;
}
get expiresAt() {
return this._expiresAt;
}
get status() {
return this._status;
}
get revokedAt() {
return this._revokedAt;
}
get revokedBy() {
return this._revokedBy;
}
get notes() {
return this._notes;
}
}
exports.default = RoleAssignmentDto;