-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Functions | ||
|
||
- [migrate](functions/migrate) - Migrate a legacy [data payload](/docs/api-reference/data) to the latest shape. | ||
- [resolveAllData](functions/resolve-all-data) - Utility function to execute all [`resolveData` methods](/docs/api-reference/configuration/component-config#resolvedatadata-params) on a data payload. | ||
- [transformProps](functions/transform-props) - Transform component props stored in the [data payload](/docs/api-reference/data). Use this for migrations, like prop renames. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: migrate | ||
--- | ||
|
||
# migrate | ||
|
||
Migrate the [Data payload](/docs/api-reference/data) to the latest shape, automatically transforming deprecated data. | ||
|
||
```tsx copy showLineNumbers {7-10} | ||
import { migrate } from "@measured/puck"; | ||
|
||
migrate(legacyData); | ||
``` | ||
|
||
## Returns | ||
|
||
The updated [Data](/docs/api-reference/data) object. | ||
|
||
## Notes | ||
|
||
- Called internally whenever you pass data to [`<Puck>`](/docs/api-reference/components/puck) or [`<Render>`](/docs/api-reference/components/render), or calling [`transformProps`](/docs/api-reference/functions/transform-props). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Data Migration | ||
|
||
Puck automatically migrates legacy data payloads on render, transforming any deprecated properties to their latest counterparts as described by [Data](/docs/api-reference/data). | ||
|
||
This data migration strategy reduces the number of breaking changes required. | ||
|
||
Specifically, Puck will migrate the data when rendering [`<Puck>`](/docs/api-reference/components/puck) or [`<Render>`](/docs/api-reference/components/render), or calling [`transformProps`](/docs/api-reference/functions/transform-props). | ||
|
||
## Types | ||
|
||
Puck exports two types: | ||
|
||
- `Data`, a backwards compatible type that supports all deprecated data shapes still supported. | ||
- `CurrentData`, the latest data shape used by Puck internally. | ||
|
||
You'll generally want to use `Data` to avoid breaking changes during minor version upgrades, but can use `CurrentData` to stay on the bleeding edge. | ||
|
||
## Manually migrating data | ||
|
||
If you manually want to update your data payload to the latest `CurrentData`, you can run the `migrate` method: | ||
|
||
```tsx | ||
import { migrate } from "@measured/puck"; | ||
|
||
migrate(legacyData); | ||
``` | ||
|
||
## Opting out | ||
|
||
There is currently no way to opt-out of automatic data migrations. | ||
|
||
## Further reading | ||
|
||
- [`Data` API reference](/docs/api-reference/data) | ||
- [`migrate` API reference](/docs/api-reference/functions/migrate) | ||
- [Prop migration](/docs/integrating-puck/prop-migration) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters