@sitecore/sc-contenthub-webclient-sdk
Version:
Sitecore Content Hub WebClient SDK.
91 lines • 3.24 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityCopyOptionsBuilder = void 0;
const guard_1 = __importDefault(require("../../guard"));
const entity_copy_options_1 = require("./entity-copy-options");
const property_copy_option_1 = require("./property-copy-option");
const relation_copy_option_1 = require("./relation-copy-option");
class EntityCopyOptionsBuilder {
constructor(copyOptions) {
this._copyOptions = new entity_copy_options_1.EntityCopyOptions();
if (copyOptions) {
this._copyOptions = new entity_copy_options_1.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_1.default.stringNotNullOrEmpty(property);
guard_1.default.notNullOrUndefined(method);
return this.withProperties([new property_copy_option_1.PropertyCopyOption(property, method, newValue)]);
}
/**
* {@inheritDoc}
*/
withProperties(properties) {
guard_1.default.notNullOrUndefined(properties);
this._copyOptions.propertyCopyOptions = [
...new Set((this._copyOptions.propertyCopyOptions || []).concat(properties)),
];
return this;
}
/**
* {@inheritDoc}
*/
withRelation(relation, method, relatedOptions = null) {
guard_1.default.stringNotNullOrEmpty(relation);
guard_1.default.notNullOrUndefined(method);
return this.withRelations([new relation_copy_option_1.RelationCopyOption(relation, method, relatedOptions)]);
}
/**
* {@inheritDoc}
*/
withRelations(relations) {
guard_1.default.notNullOrUndefined(relations);
this._copyOptions.relationCopyOptions = [
...new Set((this._copyOptions.relationCopyOptions || []).concat(relations)),
];
return this;
}
/**
* {@inheritDoc}
*/
withDestinationEntityId(id) {
guard_1.default.validId(id);
this._copyOptions.destinationEntityId = id;
return this;
}
/**
* {@inheritDoc}
*/
withCopyProfileId(id) {
guard_1.default.validId(id);
this._copyOptions.copyProfileId = id;
return this;
}
/**
* {@inheritDoc}
*/
withCopyProfileIdentifier(identifier) {
guard_1.default.stringNotNullOrEmpty(identifier);
this._copyOptions.copyProfileIdentifier = identifier;
return this;
}
/**
* {@inheritDoc}
*/
build() {
return this._copyOptions;
}
}
exports.EntityCopyOptionsBuilder = EntityCopyOptionsBuilder;
//# sourceMappingURL=entity-copy-options-builder.js.map