@awhere/api
Version:
The awesome aWhere API for JavaScript.
59 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var interfaces_1 = require("@awhere/interfaces");
var isSetOfItemType = function (obj) {
try {
return Object.keys(interfaces_1.ItemType).every(function (type) { return obj.includes(type); });
}
catch (err) {
return false;
}
};
var UserPermission = /** @class */ (function () {
function UserPermission(props) {
this._content = new Set();
this.manageGroup = false;
if (props) {
this.content = props.content;
if (props.manageGroup) {
this.manageGroup = props.manageGroup;
}
}
}
Object.defineProperty(UserPermission.prototype, "content", {
get: function () {
return Array.from(this._content);
},
set: function (value) {
if (value instanceof Set) {
this._content = value;
}
else if (value instanceof Array) {
this._content = new Set(value);
}
else if (typeof value === 'string') {
var types = [];
if (value === '*') {
types = value.split(',');
}
else {
types = Object.keys(interfaces_1.ItemType);
}
if (isSetOfItemType(types)) {
this._content = new Set(types);
}
}
},
enumerable: false,
configurable: true
});
UserPermission.prototype.toJSON = function () {
return {
content: this.content,
manageGroup: this.manageGroup,
};
};
return UserPermission;
}());
exports.default = UserPermission;
//# sourceMappingURL=UserPermission.js.map