@wasl-flow/data-adapter-contentful
v1.0.1
Published
Contentful payload adapter for Wasl Flow content models
Maintainers
Readme
@wasl-flow/data-adapter-contentful
Normalize Contentful delivery payloads into Wasl Flow content models.
Install
pnpm add @wasl-flow/data-adapter-contentfulUsage
import { adaptContentfulPayload } from '@wasl-flow/data-adapter-contentful';
const model = adaptContentfulPayload(entry, {
typeField: 'type',
outputShape: 'enveloped',
unresolvedLinkStrategy: 'null',
onUnresolvedLink: link => {
console.warn('Unresolved Contentful link detected', link);
},
});Options
typeField(default:'type'): target type field name in normalized output.assetType(default:'asset'): fallback type for Contentful assets.outputShape(default:'enveloped'):'enveloped'or'flat'.collisionStrategy(default:'error'): flat-mode collision behavior ('error'or'overwrite').includeSys(default:false): includesysmetadata on adapted nodes.unresolvedLinkStrategy(default:'null'): behavior for unresolvedLinkobjects.onUnresolvedLink: notification hook for unresolved links.onCollision: notification hook for flat-mode collisions.entryTypeResolver: override entry type resolution.
Notes
- Assumes a single locale has already been selected (field values are not localized maps).
- Nested entries and assets are normalized recursively.
onUnresolvedLinkis best-effort and does not break adaptation flow if its callback throws.envelopedoutput avoids key collisions by design:{ [typeField]: string, fields: Record<string, unknown>, sys?: object }
