contentful-migration
Version:
Migration tooling for contentful
55 lines • 2.21 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const base_intent_1 = __importDefault(require("./base-intent"));
const chalk_1 = __importDefault(require("chalk"));
const field_annotate_1 = require("../action/field-annotate");
class FieldAnnotateIntent extends base_intent_1.default {
groupsWith(other) {
const sameContentType = other.getContentTypeId() === this.getContentTypeId();
return ((other.isContentTypeUpdate() ||
other.isContentTypeCreate() ||
other.isFieldCreate() ||
other.isFieldUpdate() ||
other.isFieldMove()) &&
sameContentType);
}
endsGroup() {
return false;
}
shouldSave() {
return true;
}
toActions() {
var _a;
const annotationLinks = (_a = this.payload.annotations) === null || _a === void 0 ? void 0 : _a.map((id) => (Object.assign({ sys: {
id,
type: 'Link',
linkType: 'Annotation'
} }, this.payload.fieldAnnotationPayload)));
return [new field_annotate_1.FieldAnnotateAction(this.getContentTypeId(), this.getFieldId(), annotationLinks)];
}
toPlanMessage() {
var _a;
const count = ((_a = this.payload.annotations) === null || _a === void 0 ? void 0 : _a.length) || 0;
const heading = count
? `Assign annotation${count > 1 ? 's' : ''} ${this.payload.annotations
.map((aId) => (0, chalk_1.default) `{yellow ${aId}}`)
.join(', ')} to field ${this.getFieldId()}`
: (0, chalk_1.default) `Clear annotations on field {yellow ${this.getFieldId()}}`;
return {
heading: (0, chalk_1.default) `Update Content Type {bold.yellow ${this.getContentTypeId()}}`,
sections: [
{
heading,
details: []
}
],
details: []
};
}
}
exports.default = FieldAnnotateIntent;
//# sourceMappingURL=field-annotate.js.map