contentful-migration
Version:
Migration tooling for contentful
140 lines • 5.38 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContentTypeClearTaxonomyValidationsIntent = exports.ContentTypeAddTaxonomyValidationIntent = void 0;
const base_intent_1 = __importDefault(require("./base-intent"));
const chalk_1 = __importDefault(require("chalk"));
const content_type_taxonomy_validation_1 = require("../action/content-type-taxonomy-validation");
class ContentTypeSetTaxonomyValidationsIntent extends base_intent_1.default {
isContentTypeTaxonomyValidation() {
return true;
}
groupsWith(other) {
const sameContentType = other.getContentTypeId() === this.getContentTypeId();
return ((other.isContentTypeUpdate() ||
other.isContentTypeCreate() ||
other.isContentTypeAnnotate() ||
other.isContentTypeTaxonomyValidation() ||
other.isFieldCreate() ||
other.isFieldUpdate() ||
other.isFieldMove()) &&
sameContentType);
}
endsGroup() {
return false;
}
shouldSave() {
return true;
}
toActions() {
return [
new content_type_taxonomy_validation_1.ContentTypeSetTaxonomyValidationsAction(this.getContentTypeId(), this.payload.taxonomyValidations)
];
}
toPlanMessage() {
var _a;
const count = ((_a = this.payload.taxonomyValidations) === null || _a === void 0 ? void 0 : _a.length) || 0;
const heading = count
? `Assign taxonomy validation${count > 1 ? 's' : ''} ${this.payload.taxonomyValidations
.map((validation) => (0, chalk_1.default) `{yellow ${validation.sys.id}}`)
.join(', ')}`
: 'Clear taxonomy validations';
return {
heading: (0, chalk_1.default) `Update Content Type {bold.yellow ${this.getContentTypeId()}}`,
sections: [
{
heading,
details: []
}
],
details: []
};
}
}
exports.default = ContentTypeSetTaxonomyValidationsIntent;
class ContentTypeAddTaxonomyValidationIntent extends base_intent_1.default {
isContentTypeTaxonomyValidation() {
return true;
}
groupsWith(other) {
const sameContentType = other.getContentTypeId() === this.getContentTypeId();
return ((other.isContentTypeUpdate() ||
other.isContentTypeCreate() ||
other.isContentTypeAnnotate() ||
other.isContentTypeTaxonomyValidation() ||
other.isFieldCreate() ||
other.isFieldUpdate() ||
other.isFieldMove()) &&
sameContentType);
}
endsGroup() {
return false;
}
shouldSave() {
return true;
}
toActions() {
return [
new content_type_taxonomy_validation_1.ContentTypeAddTaxonomyValidationAction(this.getContentTypeId(), this.payload.taxonomyValidation.sys.id, this.payload.taxonomyValidation.sys.linkType, { required: this.payload.taxonomyValidation.required })
];
}
toPlanMessage() {
const linkTypeLabel = this.payload.taxonomyValidation.sys.linkType === 'TaxonomyConcept'
? 'concept'
: 'concept scheme';
const requiredLabel = this.payload.taxonomyValidation.required ? ' (required)' : '';
const heading = `Add taxonomy ${linkTypeLabel} ${(0, chalk_1.default) `{yellow ${this.payload.taxonomyValidation.sys.id}}`}${requiredLabel}`;
return {
heading: (0, chalk_1.default) `Update Content Type {bold.yellow ${this.getContentTypeId()}}`,
sections: [
{
heading,
details: []
}
],
details: []
};
}
}
exports.ContentTypeAddTaxonomyValidationIntent = ContentTypeAddTaxonomyValidationIntent;
class ContentTypeClearTaxonomyValidationsIntent extends base_intent_1.default {
isContentTypeTaxonomyValidation() {
return true;
}
groupsWith(other) {
const sameContentType = other.getContentTypeId() === this.getContentTypeId();
return ((other.isContentTypeUpdate() ||
other.isContentTypeCreate() ||
other.isContentTypeAnnotate() ||
other.isContentTypeTaxonomyValidation() ||
other.isFieldCreate() ||
other.isFieldUpdate() ||
other.isFieldMove()) &&
sameContentType);
}
endsGroup() {
return false;
}
shouldSave() {
return true;
}
toActions() {
return [new content_type_taxonomy_validation_1.ContentTypeClearTaxonomyValidationsAction(this.getContentTypeId())];
}
toPlanMessage() {
return {
heading: (0, chalk_1.default) `Update Content Type {bold.yellow ${this.getContentTypeId()}}`,
sections: [
{
heading: 'Clear all taxonomy validations',
details: []
}
],
details: []
};
}
}
exports.ContentTypeClearTaxonomyValidationsIntent = ContentTypeClearTaxonomyValidationsIntent;
//# sourceMappingURL=content-type-taxonomy-validation.js.map