@upv/ushi-shared
Version:
Shared DTOs, types, and utilities for the USHI platform (LMS, Trials, Social, Wallet).
56 lines (55 loc) • 1.69 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"));
/**
* RoleDto
*
* Data Transfer Object for Role entities in the USHI platform.
* Encapsulates role identity (e.g., 'admin', 'student') and domain scope (e.g., LMS, Trial),
* providing consistent serialization and access to role data.
*/
class RoleDto extends BaseDto_1.default {
/**
* Constructs a new RoleDto instance.
* @param data - Raw role DTO input
*/
constructor(data) {
super(data);
this._key = data.key;
this._label = data.label;
this._domain = data.domain;
this._description = data.description;
}
/**
* Serializes the RoleDto into a plain IRole object.
*/
async serialize() {
return {
...(await this.serializeBase()),
key: this._key,
label: this._label,
domain: this._domain,
description: this._description ?? null,
};
}
/** Gets the role key (e.g., 'admin', 'student') */
get key() {
return this._key;
}
/** Gets the user-facing label for this role (e.g., 'Administrator') */
get label() {
return this._label;
}
/** Gets the domain in which this role applies (e.g., LMS, Trial) */
get domain() {
return this._domain;
}
/** Gets the optional description of the role */
get description() {
return this._description;
}
}
exports.default = RoleDto;