@sitecore/sc-contenthub-webclient-sdk
Version:
Sitecore Content Hub WebClient SDK.
79 lines • 3.47 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var RelationLoadOption_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RelationLoadOption = void 0;
const ta_json_1 = require("ta-json");
const guard_1 = __importDefault(require("../../guard"));
const type_guards_1 = require("../../type-guards");
const load_options_1 = require("./load-options");
const relation_specification_1 = require("./relation-specification");
let RelationLoadOption = RelationLoadOption_1 = class RelationLoadOption {
constructor(param) {
this.loadOption = load_options_1.LoadOption.None;
this.relations = [];
if (param == null) {
return;
}
else if (param instanceof RelationLoadOption_1) {
this.loadOption = param.loadOption;
this.relations = [...param.relations];
}
else if (param instanceof Array) {
guard_1.default.arrayNotEmpty(param);
this.loadOption = load_options_1.LoadOption.Custom;
if (type_guards_1.TypeGuards.isStringArray(param)) {
this.relations = param.map((relationName) => {
return new relation_specification_1.RelationSpecification(relationName);
});
}
else {
this.relations = [...param];
}
}
else {
this.loadOption = param;
}
}
deepClone() {
return ta_json_1.JSON.deserialize(ta_json_1.JSON.serialize(this), RelationLoadOption_1);
}
};
exports.RelationLoadOption = RelationLoadOption;
/**
* Load no relations.
*/
RelationLoadOption.None = new RelationLoadOption_1(load_options_1.LoadOption.None);
/**
* Load all relations.
*/
RelationLoadOption.All = new RelationLoadOption_1(load_options_1.LoadOption.All);
__decorate([
(0, ta_json_1.JsonProperty)("load_option"),
__metadata("design:type", Number)
], RelationLoadOption.prototype, "loadOption", void 0);
__decorate([
(0, ta_json_1.JsonProperty)("relations"),
(0, ta_json_1.JsonElementType)(relation_specification_1.RelationSpecification),
__metadata("design:type", Array)
], RelationLoadOption.prototype, "relations", void 0);
__decorate([
(0, ta_json_1.JsonProperty)("max_related_items"),
__metadata("design:type", Number)
], RelationLoadOption.prototype, "maxRelatedItems", void 0);
exports.RelationLoadOption = RelationLoadOption = RelationLoadOption_1 = __decorate([
(0, ta_json_1.JsonObject)(),
__metadata("design:paramtypes", [Object])
], RelationLoadOption);
//# sourceMappingURL=relation-load-option.js.map