@sitecore/sc-contenthub-webclient-sdk
Version:
Sitecore Content Hub WebClient SDK.
73 lines • 2.94 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 RelationLoadOption_1;
import { JSON, JsonElementType, JsonObject, JsonProperty } from "ta-json";
import Guard from "../../guard";
import { TypeGuards } from "../../type-guards";
import { LoadOption } from "./load-options";
import { RelationSpecification } from "./relation-specification";
let RelationLoadOption = RelationLoadOption_1 = class RelationLoadOption {
constructor(param) {
this.loadOption = 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.arrayNotEmpty(param);
this.loadOption = LoadOption.Custom;
if (TypeGuards.isStringArray(param)) {
this.relations = param.map((relationName) => {
return new RelationSpecification(relationName);
});
}
else {
this.relations = [...param];
}
}
else {
this.loadOption = param;
}
}
deepClone() {
return JSON.deserialize(JSON.serialize(this), RelationLoadOption_1);
}
};
/**
* Load no relations.
*/
RelationLoadOption.None = new RelationLoadOption_1(LoadOption.None);
/**
* Load all relations.
*/
RelationLoadOption.All = new RelationLoadOption_1(LoadOption.All);
__decorate([
JsonProperty("load_option"),
__metadata("design:type", Number)
], RelationLoadOption.prototype, "loadOption", void 0);
__decorate([
JsonProperty("relations"),
JsonElementType(RelationSpecification),
__metadata("design:type", Array)
], RelationLoadOption.prototype, "relations", void 0);
__decorate([
JsonProperty("max_related_items"),
__metadata("design:type", Number)
], RelationLoadOption.prototype, "maxRelatedItems", void 0);
RelationLoadOption = RelationLoadOption_1 = __decorate([
JsonObject(),
__metadata("design:paramtypes", [Object])
], RelationLoadOption);
export { RelationLoadOption };
//# sourceMappingURL=relation-load-option.js.map