Repository navigation
feat: add hooks to restoreVersion collection operation - #13333
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
| docWithLocales: result, | ||
| draft: shouldSaveDraft, | ||
| global: globalConfig, | ||
| operation: 'update', |
There was a problem hiding this comment.
Wow, this wasn't here before?
There was a problem hiding this comment.
I added an argument to saveVersions, so this is new. I needed it so the saveVersions function could be re-used in the restoreVersions operation. Before we were doing similar things but not exactly the same - figured it was best to consolidate and re-use the function we already had written.
The reason for the new arg is so the saveVersions can respect the createdAt date when restoring. So here it passes update and in the restoreVersion op, it passes restoreVersion which allows it to use the date on the incoming data (the version to restore createdAt).
DanRibbens
left a comment
There was a problem hiding this comment.
We should also do this change for packages/payload/src/globals/operations/restoreVersion.ts.
Continuation of [#13333](#13333). Aligns global version restoration with collections by calling `saveVersion` within the global restore operation: - Returns the restored global document directly, matching collection restoration (**breaking change**). - Localized `_status` values are not normalized when restoring a draft. - `versions.max` is not enforced, allowing version history to exceed the configured limit. Draft restores also leave live global content intact. ## Breaking Changes Global restores now return the global document directly. This affects `payload.restoreGlobalVersion`, REST responses, and global `afterRead` / `afterChange` hooks that use the version-row wrapper. ```diff const restored = await payload.restoreGlobalVersion({ slug: 'settings', id: versionID }) -const title = restored.version.title +const title = restored.title ```
Adds missing hooks to the restoreVersion operation.