@sitecore/sc-contenthub-webclient-sdk
Version:
Sitecore Content Hub WebClient SDK.
65 lines • 2.82 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.User = void 0;
const ta_json_1 = require("ta-json");
const constants_1 = require("../../constants");
const entity_1 = require("../base/entity");
const user_group_configuration_1 = require("./user-group-configuration");
class User extends entity_1.Entity {
get username() {
return this.getPropertyValue(constants_1.DEFINITIONS["User"].username);
}
set username(value) {
this.setPropertyValue(constants_1.DEFINITIONS["User"].username, value);
}
get userGroupConfiguration() {
const token = this.getPropertyValue(constants_1.DEFINITIONS["User"].userGroupConfiguration);
if (token == null) {
return null;
}
return ta_json_1.TaJson.deserialize(token, user_group_configuration_1.UserGroupConfiguration);
}
constructor(client, args) {
super(client, args);
}
getUserProfileAsync(loadConfiguration) {
return __awaiter(this, void 0, void 0, function* () {
const profileRelation = (yield this.getRelationAsync(constants_1.DEFINITIONS["User"].userToUserProfile));
if (profileRelation == null || profileRelation.child == null) {
return null;
}
else {
const profile = yield this._client.entities.getAsync(profileRelation.child, loadConfiguration);
return profile;
}
});
}
getUserGroupIdsAsync() {
return __awaiter(this, void 0, void 0, function* () {
const profileRelation = (yield this.getRelationAsync(constants_1.DEFINITIONS["User"].userGroupToUser));
if (profileRelation == null) {
return null;
}
return profileRelation.parents;
});
}
getUserPolicyAsync() {
return __awaiter(this, void 0, void 0, function* () {
if (this.id == null) {
return null;
}
return this._client.policies.getUserPolicyAsync(this.id);
});
}
}
exports.User = User;
//# sourceMappingURL=user.js.map