fix npm run build
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PermissionData = void 0;
|
||||
class PermissionData {
|
||||
id;
|
||||
code;
|
||||
name;
|
||||
description;
|
||||
createdAt;
|
||||
updatedAt;
|
||||
constructor(id, code, name, description, createdAt, updatedAt) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
changeName(name) {
|
||||
this.name = name;
|
||||
}
|
||||
changeDescription(description) {
|
||||
this.description = description;
|
||||
}
|
||||
changeCode(code) {
|
||||
this.code = code;
|
||||
}
|
||||
static restore(props) {
|
||||
return new PermissionData(props.id, props.code || props.name, props.name, props.description, props.createdAt, props.updatedAt);
|
||||
}
|
||||
}
|
||||
exports.PermissionData = PermissionData;
|
||||
//# sourceMappingURL=permission.entity.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"permission.entity.js","sourceRoot":"","sources":["../../../../../src/modules/identity/domain/entities/permission.entity.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;IAEP;IACT;IACA;IACA;IACA;IACA;IANT,YACkB,EAAU,EACnB,IAAY,EACZ,IAAY,EACZ,WAAmB,EACnB,SAAe,EACf,SAAe;QALN,OAAE,GAAF,EAAE,CAAQ;QACnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,cAAS,GAAT,SAAS,CAAM;QACf,cAAS,GAAT,SAAS,CAAM;IACrB,CAAC;IAEJ,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,iBAAiB,CAAC,WAAmB;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,KAOd;QACC,OAAO,IAAI,cAAc,CACvB,KAAK,CAAC,EAAE,EACR,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,EACxB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;CACF;AAvCD,wCAuCC"}
|
||||
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"role.entity.js","sourceRoot":"","sources":["../../../../../src/modules/identity/domain/entities/role.entity.ts"],"names":[],"mappings":";;;AAEA,MAAa,QAAQ;IAED;IACT;IACA;IACA;IACA;IACA;IACA;IACA;IART,YACkB,EAAU,EACnB,IAAY,EACZ,IAAY,EACZ,WAAmB,EACnB,WAA6B,EAC7B,SAAkB,EAClB,SAAe,EACf,SAAe;QAPN,OAAE,GAAF,EAAE,CAAQ;QACnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAkB;QAC7B,cAAS,GAAT,SAAS,CAAS;QAClB,cAAS,GAAT,SAAS,CAAM;QACf,cAAS,GAAT,SAAS,CAAM;IACrB,CAAC;IAEJ,cAAc,CAAC,YAAoB;QACjC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;IACvF,CAAC;IAED,gBAAgB,CAAC,cAA8B;QAC7C,IAAI,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAE1F,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;IAED,gBAAgB,CAAC,YAAoB;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/F,IAAI,GAAG,KAAK,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACzE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,iBAAiB,CAAC,WAAmB;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,SAAkB;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,KASd;QACC,OAAO,IAAI,QAAQ,CACjB,KAAK,CAAC,EAAE,EACR,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,WAAW,IAAI,EAAE,EACvB,KAAK,CAAC,SAAS,IAAI,KAAK,EACxB,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;CACF;AA7DD,4BA6DC"}
|
||||
@@ -0,0 +1,143 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UserData = void 0;
|
||||
class UserData {
|
||||
id;
|
||||
authentikId;
|
||||
username;
|
||||
email;
|
||||
password;
|
||||
roles;
|
||||
permissions;
|
||||
isActive;
|
||||
deletedAt;
|
||||
lastSeenAt;
|
||||
storageQuota;
|
||||
storageUsed;
|
||||
constructor(id, authentikId, username, email, password, roles, permissions, isActive, deletedAt, lastSeenAt, storageQuota, storageUsed) {
|
||||
this.id = id;
|
||||
this.authentikId = authentikId;
|
||||
this.username = username;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.roles = roles;
|
||||
this.permissions = permissions;
|
||||
this.isActive = isActive;
|
||||
this.deletedAt = deletedAt;
|
||||
this.lastSeenAt = lastSeenAt;
|
||||
this.storageQuota = storageQuota;
|
||||
this.storageUsed = storageUsed;
|
||||
}
|
||||
//#region Create
|
||||
static create(data) {
|
||||
const quota = data.storageQuota !== undefined ? data.storageQuota : 10737418240; // 10 GB
|
||||
const used = data.storageUsed !== undefined ? data.storageUsed : 0;
|
||||
return new UserData(crypto.randomUUID(), data.authentikId || null, data.username, data.email, data.password ?? null, [], [], true, null, null, quota, used);
|
||||
}
|
||||
//#endregion
|
||||
//#region Read
|
||||
hasRole(roleId) {
|
||||
return this.roles.some(x => x.id.toLowerCase() === roleId.toLowerCase());
|
||||
}
|
||||
assignRole(roleData) {
|
||||
if (this.hasRole(roleData.id))
|
||||
throw new Error("Role Sudah dimiliki.");
|
||||
this.roles.push(roleData);
|
||||
}
|
||||
hasPermissions(permissionId) {
|
||||
return this.permissions.some(x => x.id.toLowerCase() === permissionId.toLowerCase());
|
||||
}
|
||||
hasPermission(permission) {
|
||||
const byPerm = this.permissions.some(x => x.id.toLowerCase() === permission.toLowerCase() || x.name.toLowerCase() === permission.toLowerCase());
|
||||
if (byPerm)
|
||||
return true;
|
||||
// check roles
|
||||
return this.roles.some(r => r.permissions.some(p => p.id.toLowerCase() === permission.toLowerCase() || p.name.toLowerCase() === permission.toLowerCase()));
|
||||
}
|
||||
assignPermission(permissionData) {
|
||||
if (this.hasPermissions(permissionData.id))
|
||||
throw new Error("Permission sudah dimiliki.");
|
||||
this.permissions.push(permissionData);
|
||||
}
|
||||
//#endregion
|
||||
//#region Update
|
||||
changeEmail(email) {
|
||||
this.email = email;
|
||||
}
|
||||
changeUsername(username) {
|
||||
this.username = username;
|
||||
}
|
||||
touchLastSeen() {
|
||||
this.lastSeenAt = new Date();
|
||||
}
|
||||
enable() {
|
||||
this.isActive = true;
|
||||
}
|
||||
disable() {
|
||||
this.isActive = false;
|
||||
}
|
||||
//#endregion
|
||||
//#region Delete
|
||||
softDelete() {
|
||||
this.deletedAt = new Date();
|
||||
this.isActive = false;
|
||||
}
|
||||
restoreInstance() {
|
||||
this.deletedAt = null;
|
||||
}
|
||||
//#endregion
|
||||
static restore(props) {
|
||||
return new UserData(props.id, props.authentikId || null, props.username, props.email, props.password, props.roles || [], props.permissions || [], props.isActive !== undefined ? props.isActive : true, props.deletedAt || null, props.lastSeenAt || null, props.storageQuota !== undefined && props.storageQuota !== null ? props.storageQuota : 10737418240, props.storageUsed !== undefined && props.storageUsed !== null ? props.storageUsed : 0);
|
||||
}
|
||||
removeRole(roleId) {
|
||||
const idx = this.roles.findIndex(r => r.id.toLowerCase() === roleId.toLowerCase());
|
||||
if (idx === -1)
|
||||
throw new Error('Role tidak ditemukan pada user.');
|
||||
this.roles.splice(idx, 1);
|
||||
}
|
||||
removePermission(permissionId) {
|
||||
const idx = this.permissions.findIndex(p => p.id.toLowerCase() === permissionId.toLowerCase());
|
||||
if (idx === -1)
|
||||
throw new Error('Permission tidak ditemukan pada user.');
|
||||
this.permissions.splice(idx, 1);
|
||||
}
|
||||
// Storage helpers
|
||||
setStorageQuota(bytes) {
|
||||
if (bytes < 0)
|
||||
throw new Error('storageQuota must be >= 0');
|
||||
if (this.storageUsed > bytes)
|
||||
throw new Error('storageQuota cannot be less than storageUsed');
|
||||
this.storageQuota = bytes;
|
||||
}
|
||||
setStorageUsed(bytes) {
|
||||
if (bytes < 0)
|
||||
throw new Error('storageUsed must be >= 0');
|
||||
if (bytes > this.storageQuota)
|
||||
throw new Error('storageUsed cannot exceed storageQuota');
|
||||
this.storageUsed = bytes;
|
||||
}
|
||||
// Response helper for API
|
||||
toResponse() {
|
||||
const remaining = this.storageQuota - this.storageUsed;
|
||||
const usagePercentage = this.storageQuota > 0 ? Math.round((this.storageUsed / this.storageQuota) * 100) : 0;
|
||||
return {
|
||||
id: this.id,
|
||||
authentikId: this.authentikId,
|
||||
username: this.username,
|
||||
email: this.email,
|
||||
roles: this.roles,
|
||||
permissions: this.permissions,
|
||||
isActive: this.isActive,
|
||||
deletedAt: this.deletedAt,
|
||||
lastSeenAt: this.lastSeenAt,
|
||||
storage: {
|
||||
quota: this.storageQuota,
|
||||
used: this.storageUsed,
|
||||
remaining,
|
||||
usagePercentage,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.UserData = UserData;
|
||||
//# sourceMappingURL=user.entity.js.map
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user