API ReferenceFunctionsmigrate

migrate

Migrate the Data payload to the latest shape, automatically transforming deprecated data.

import { migrate } from "@measured/puck"; migrate(legacyData);

Migrations

Root data to props

Migrates any props stored on root data to the props object.

Before

{ "root": { "title": "Hello, world" } }

After

{ "root": { "props": { "title": "Hello, world" } } }

DropZones to slots

Migrates all DropZone data from zones to inline slots. Requires slots to be provided via the config arg, where the field name for the slot matches the zone prop of the DropZone. See the DropZone to slots migration guide for more information.

Before

{ "content": [ { "type": "Grid", "props": { "id": "Grid-12345" } } ], "zones": { "Grid-12345:items": [ { "type": "HeadingBlock", "props": { "id": "Heading-12345", "title": "Hello, world" } } ] } }

After

{ "content": [ { "type": "Grid", "props": { "id": "Grid-12345", "items": [ { "type": "HeadingBlock", "props": { "id": "Heading-12345", "title": "Hello, world" } } ] } } ] }

Args

ParamExampleTypeStatus
data{ content: [{type: "Heading", props: {} }]}DataRequired
config{ components: {} }Config-

data

The legacy data you want to transform.

config

A config object. Normally only required if using slots.

Returns

The updated Data object.