UNPKG

@botonic/plugin-contentful

Version:

## What Does This Plugin Do?

32 lines 1.32 kB
import { __awaiter } from "tslib"; import * as cms from '../../cms'; import { addCustomFields, ContentfulEntryUtils, } from '../delivery-utils'; import { getTargetCallback } from './callback-delivery'; import { DeliveryWithReference } from './reference'; export class InputDelivery extends DeliveryWithReference { constructor(delivery, resumeErrors) { super(cms.ContentType.INPUT, delivery, resumeErrors); } input(id, context) { return __awaiter(this, void 0, void 0, function* () { const entry = yield this.getEntry(id, context); return this.fromEntry(entry, context); }); } fromEntry(entry, context) { const fields = entry.fields; const common = ContentfulEntryUtils.commonFieldsFromEntry(entry); const referenceDelivery = { delivery: this.reference, context, }; return addCustomFields(new cms.Input(common, fields.title, fields.keywords, this.target(entry, context), fields.type), entry.fields, referenceDelivery); } target(entry, context) { if (!entry.fields.target) { throw new cms.CmsException(`Input ${this.entryId(entry)} has no target`); } return getTargetCallback(entry.fields.target, context); } } //# sourceMappingURL=input.js.map