@sitecore/sc-contenthub-webclient-sdk
Version:
Sitecore Content Hub WebClient SDK.
61 lines • 2.59 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());
});
};
import { TaJson } from "ta-json";
import { DEFINITIONS } from "../../constants";
import { Entity } from "../base/entity";
import { UserGroupConfiguration } from "./user-group-configuration";
export class User extends Entity {
get username() {
return this.getPropertyValue(DEFINITIONS["User"].username);
}
set username(value) {
this.setPropertyValue(DEFINITIONS["User"].username, value);
}
get userGroupConfiguration() {
const token = this.getPropertyValue(DEFINITIONS["User"].userGroupConfiguration);
if (token == null) {
return null;
}
return TaJson.deserialize(token, UserGroupConfiguration);
}
constructor(client, args) {
super(client, args);
}
getUserProfileAsync(loadConfiguration) {
return __awaiter(this, void 0, void 0, function* () {
const profileRelation = (yield this.getRelationAsync(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(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);
});
}
}
//# sourceMappingURL=user.js.map