UNPKG

@sitecore/sc-contenthub-webclient-sdk

Version:

Sitecore Content Hub WebClient SDK.

92 lines 3.98 kB
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); }; import { JsonElementType, JsonObject, JsonProperty } from "ta-json"; import { CultureLoadOption } from "./culture-load-option"; import { PropertyLoadOption } from "./property-load-option"; import { QueryLoadConfiguration } from "./query-load-configuration"; import { RelationLoadOption } from "./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 QueryLoadConfiguration(); result.loadEntities = this.loadEntities; // Map properties to load if (this.propertiesToLoad === null || this.propertiesToLoad.length === 0) { result.propertyLoadOption = PropertyLoadOption.None; } else if (this.propertiesToLoad.includes("*")) { result.propertyLoadOption = PropertyLoadOption.All; } else { result.propertyLoadOption = new PropertyLoadOption(this.propertiesToLoad); } // Map relations to load if (this.relationsToLoad === null || this.relationsToLoad.length === 0) { result.relationLoadOption = RelationLoadOption.None; } else { result.relationLoadOption = new RelationLoadOption(this.relationsToLoad); } // Map cultures to load if (!this.culturesToLoad || this.culturesToLoad.length === 0) { result.cultureLoadOption = CultureLoadOption.None; } else if (this.culturesToLoad.includes("*")) { result.cultureLoadOption = CultureLoadOption.All; } else { result.cultureLoadOption = new CultureLoadOption(this.culturesToLoad); } return result; } }; __decorate([ JsonProperty("load_entities"), __metadata("design:type", Boolean) ], EntityLoadOption.prototype, "loadEntities", void 0); __decorate([ JsonProperty("properties_to_load"), JsonElementType(String), __metadata("design:type", Object) ], EntityLoadOption.prototype, "propertiesToLoad", void 0); __decorate([ JsonProperty("relations_to_load"), JsonElementType(String), __metadata("design:type", Object) ], EntityLoadOption.prototype, "relationsToLoad", void 0); __decorate([ JsonProperty("cultures_to_load"), JsonElementType(String), __metadata("design:type", Array) ], EntityLoadOption.prototype, "culturesToLoad", void 0); EntityLoadOption = __decorate([ JsonObject() ], EntityLoadOption); export { EntityLoadOption }; //# sourceMappingURL=entity-load-option.js.map