@sitecore/sc-contenthub-webclient-sdk
Version:
Sitecore Content Hub WebClient SDK.
95 lines • 4.45 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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityLoadOption = void 0;
const ta_json_1 = require("ta-json");
const culture_load_option_1 = require("./culture-load-option");
const property_load_option_1 = require("./property-load-option");
const query_load_configuration_1 = require("./query-load-configuration");
const relation_load_option_1 = require("./relation-load-option");
/**
* Specifies if and how resulting entities should be loaded.
*/
let EntityLoadOption = class EntityLoadOption {
constructor() {
/**
* The names of the properties to load with the entities.
* If the value contains "*", all properties will be loaded.
* If the value is null, no properties will be loaded.
*
* The default value is ["*"], which means all properties will be loaded.
*/
this.propertiesToLoad = ["*"];
/**
* The names of the relations to load with the entities.
* If the value is null, no relations will be loaded.
*
* The default value is null, which mean no relations will be loaded.
*/
this.relationsToLoad = null;
}
toQueryLoadConfiguration() {
const result = new query_load_configuration_1.QueryLoadConfiguration();
result.loadEntities = this.loadEntities;
// Map properties to load
if (this.propertiesToLoad === null || this.propertiesToLoad.length === 0) {
result.propertyLoadOption = property_load_option_1.PropertyLoadOption.None;
}
else if (this.propertiesToLoad.includes("*")) {
result.propertyLoadOption = property_load_option_1.PropertyLoadOption.All;
}
else {
result.propertyLoadOption = new property_load_option_1.PropertyLoadOption(this.propertiesToLoad);
}
// Map relations to load
if (this.relationsToLoad === null || this.relationsToLoad.length === 0) {
result.relationLoadOption = relation_load_option_1.RelationLoadOption.None;
}
else {
result.relationLoadOption = new relation_load_option_1.RelationLoadOption(this.relationsToLoad);
}
// Map cultures to load
if (!this.culturesToLoad || this.culturesToLoad.length === 0) {
result.cultureLoadOption = culture_load_option_1.CultureLoadOption.None;
}
else if (this.culturesToLoad.includes("*")) {
result.cultureLoadOption = culture_load_option_1.CultureLoadOption.All;
}
else {
result.cultureLoadOption = new culture_load_option_1.CultureLoadOption(this.culturesToLoad);
}
return result;
}
};
exports.EntityLoadOption = EntityLoadOption;
__decorate([
(0, ta_json_1.JsonProperty)("load_entities"),
__metadata("design:type", Boolean)
], EntityLoadOption.prototype, "loadEntities", void 0);
__decorate([
(0, ta_json_1.JsonProperty)("properties_to_load"),
(0, ta_json_1.JsonElementType)(String),
__metadata("design:type", Object)
], EntityLoadOption.prototype, "propertiesToLoad", void 0);
__decorate([
(0, ta_json_1.JsonProperty)("relations_to_load"),
(0, ta_json_1.JsonElementType)(String),
__metadata("design:type", Object)
], EntityLoadOption.prototype, "relationsToLoad", void 0);
__decorate([
(0, ta_json_1.JsonProperty)("cultures_to_load"),
(0, ta_json_1.JsonElementType)(String),
__metadata("design:type", Array)
], EntityLoadOption.prototype, "culturesToLoad", void 0);
exports.EntityLoadOption = EntityLoadOption = __decorate([
(0, ta_json_1.JsonObject)()
], EntityLoadOption);
//# sourceMappingURL=entity-load-option.js.map