UNPKG

contentful-migration

Version:
61 lines 2.21 kB
"use strict"; 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 content_type_annotate_1 = require("../action/content-type-annotate"); class ContentTypeAnnotateIntent extends base_intent_1.default { isContentTypeAnnotate() { return true; } groupsWith(other) { const sameContentType = other.getContentTypeId() === this.getContentTypeId(); return ((other.isContentTypeUpdate() || other.isContentTypeCreate() || other.isContentTypeAnnotate() || 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) => ({ sys: { id, type: 'Link', linkType: 'Annotation' } })); return [new content_type_annotate_1.ContentTypeAnnotateAction(this.getContentTypeId(), 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(', ')}` : 'Clear annotations'; return { heading: (0, chalk_1.default) `Update Content Type {bold.yellow ${this.getContentTypeId()}}`, sections: [ { heading, details: [] } ], details: [] }; } } exports.default = ContentTypeAnnotateIntent; //# sourceMappingURL=content-type-annotate.js.map