fix npm run build
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RoleData = void 0;
|
||||
class RoleData {
|
||||
id;
|
||||
code;
|
||||
name;
|
||||
description;
|
||||
permissions;
|
||||
isDefault;
|
||||
createdAt;
|
||||
updatedAt;
|
||||
constructor(id, code, name, description, permissions, isDefault, createdAt, updatedAt) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.permissions = permissions;
|
||||
this.isDefault = isDefault;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
hasPermissions(permissionId) {
|
||||
return this.permissions.some(x => x.id.toLowerCase() === permissionId.toLowerCase());
|
||||
}
|
||||
assignPermission(permissionData) {
|
||||
if (this.hasPermissions(permissionData.id))
|
||||
throw new Error("Permission sudah dimiliki.");
|
||||
this.permissions.push(permissionData);
|
||||
}
|
||||
removePermission(permissionId) {
|
||||
const idx = this.permissions.findIndex(p => p.id.toLowerCase() === permissionId.toLowerCase());
|
||||
if (idx === -1)
|
||||
throw new Error('Permission tidak ditemukan pada role.');
|
||||
this.permissions.splice(idx, 1);
|
||||
}
|
||||
changeName(name) {
|
||||
this.name = name;
|
||||
}
|
||||
changeDescription(description) {
|
||||
this.description = description;
|
||||
}
|
||||
setDefault(isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
static restore(props) {
|
||||
return new RoleData(props.id, props.code, props.name, props.description, props.permissions || [], props.isDefault ?? false, props.createdAt, props.updatedAt);
|
||||
}
|
||||
}
|
||||
exports.RoleData = RoleData;
|
||||
//# sourceMappingURL=role.entity.js.map
|
||||
Reference in New Issue
Block a user