UNPKG

contentful-migration

Version:
24 lines 931 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EntryFieldRenameAction = void 0; const action_1 = require("./action"); class EntryFieldRenameAction extends action_1.APIAction { constructor(contentTypeId, fieldId, props) { super(); this.contentTypeId = contentTypeId; this.fieldId = fieldId; this.props = props; } async applyTo(api) { const entries = await api.getEntriesForContentType(this.contentTypeId); for (const entry of entries) { const { newId } = this.props; const field = entry.fields[this.fieldId]; const newFields = Object.assign(Object.assign({}, entry.fields), { [newId]: field }); delete newFields[this.fieldId]; entry.fields = newFields; } } } exports.EntryFieldRenameAction = EntryFieldRenameAction; //# sourceMappingURL=entry-field-rename.js.map