UNPKG

@sitecore/sc-contenthub-webclient-sdk

Version:

Sitecore Content Hub WebClient SDK.

84 lines 2.71 kB
import Guard from "../../guard"; import { EntityCopyOptions } from "./entity-copy-options"; import { PropertyCopyOption } from "./property-copy-option"; import { RelationCopyOption } from "./relation-copy-option"; export class EntityCopyOptionsBuilder { constructor(copyOptions) { this._copyOptions = new EntityCopyOptions(); if (copyOptions) { this._copyOptions = new EntityCopyOptions(); this._copyOptions.relationCopyOptions = copyOptions.relationCopyOptions; this._copyOptions.propertyCopyOptions = copyOptions.propertyCopyOptions; this._copyOptions.destinationEntityId = copyOptions.destinationEntityId; this._copyOptions.copyProfileId = copyOptions.copyProfileId; this._copyOptions.copyProfileIdentifier = copyOptions.copyProfileIdentifier; } } /** * {@inheritDoc} */ withProperty(property, method, newValue = null) { Guard.stringNotNullOrEmpty(property); Guard.notNullOrUndefined(method); return this.withProperties([new PropertyCopyOption(property, method, newValue)]); } /** * {@inheritDoc} */ withProperties(properties) { Guard.notNullOrUndefined(properties); this._copyOptions.propertyCopyOptions = [ ...new Set((this._copyOptions.propertyCopyOptions || []).concat(properties)), ]; return this; } /** * {@inheritDoc} */ withRelation(relation, method, relatedOptions = null) { Guard.stringNotNullOrEmpty(relation); Guard.notNullOrUndefined(method); return this.withRelations([new RelationCopyOption(relation, method, relatedOptions)]); } /** * {@inheritDoc} */ withRelations(relations) { Guard.notNullOrUndefined(relations); this._copyOptions.relationCopyOptions = [ ...new Set((this._copyOptions.relationCopyOptions || []).concat(relations)), ]; return this; } /** * {@inheritDoc} */ withDestinationEntityId(id) { Guard.validId(id); this._copyOptions.destinationEntityId = id; return this; } /** * {@inheritDoc} */ withCopyProfileId(id) { Guard.validId(id); this._copyOptions.copyProfileId = id; return this; } /** * {@inheritDoc} */ withCopyProfileIdentifier(identifier) { Guard.stringNotNullOrEmpty(identifier); this._copyOptions.copyProfileIdentifier = identifier; return this; } /** * {@inheritDoc} */ build() { return this._copyOptions; } } //# sourceMappingURL=entity-copy-options-builder.js.map