UNPKG

@sitecore/sc-contenthub-webclient-sdk

Version:

Sitecore Content Hub WebClient SDK.

58 lines 2.75 kB
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 Guard from "../../guard"; import { EntityLoadConfiguration } from "../querying/entity-load-configuration"; import { MemberBase } from "./member"; import { MemberDefinitionType } from "./member-definition-type"; import { RelationRole } from "./relation-role"; export class RelationBase extends MemberBase { constructor(name, properties = null, client) { super(name, MemberDefinitionType.Relation); this.client = client; this.properties = properties == null ? {} : properties; } setIdentifiersAsync(identifiers) { return __awaiter(this, void 0, void 0, function* () { var _a; Guard.arrayNoneNullOrEmptyString(identifiers); Guard.notNullOrUndefined(this.client); const entities = yield this.client.entities.getManyAsync(identifiers, EntityLoadConfiguration.Minimal); this.setIds((_a = entities === null || entities === void 0 ? void 0 : entities.filter(x => x.id !== null).map(x => x.id)) !== null && _a !== void 0 ? _a : []); }); } getTypeName() { return RelationRole[this.role]; } static isChildRelation(r) { return r.role === RelationRole.Child; } static isChildToOneParentRelation(r) { return r.role === RelationRole.Child && !r.isMultiValue; } static isChildToManyParentsRelation(r) { return r.role === RelationRole.Child && r.isMultiValue; } static isParentRelation(r) { return r.role === RelationRole.Parent; } static isParentToOneChildRelation(r) { return r.role === RelationRole.Parent && !r.isMultiValue; } static isParentToManyChildrenRelation(r) { return r.role === RelationRole.Parent && r.isMultiValue; } } export class ChildRelationBase extends RelationBase { constructor(name, properties, client, inheritsSecurity) { super(name, properties, client); this.inheritsSecurity = inheritsSecurity !== null && inheritsSecurity !== void 0 ? inheritsSecurity : true; } } //# sourceMappingURL=relation.js.map