@attivio/suit
Version:
Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.
39 lines (30 loc) • 1.33 kB
JavaScript
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Principal object used by the Attivio server.
*/
var SimplePrincipal = function () {
/** Any groups the principal belongs to (they should all have their type field set to 'group') */
/** The principal's name */
function SimplePrincipal(name, realm) {
var groupMemberships = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'user';
_classCallCheck(this, SimplePrincipal);
this.name = name;
this.realm = realm;
this.groupMemberships = groupMemberships;
this.type = type;
}
/** Whether this is a user or a group */
/** The principal's realm */
SimplePrincipal.fromJson = function fromJson(json) {
var groupMemberships = [];
if (json.groupMemberships && json.groupMemberships.length > 0) {
groupMemberships = json.groupMemberships.map(function (group) {
return new SimplePrincipal(json.name, json.realm, group, json.type);
});
}
return new SimplePrincipal(json.name, json.realm, groupMemberships, json.type);
};
return SimplePrincipal;
}();
export { SimplePrincipal as default };