@payloadcms/codemod 4.0.0-internal.58473b9 → 4.0.0-internal.5e065b3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,11 +19,11 @@ while the v3 packages are still installed:
19
19
 
20
20
  ## 1. Next.js 16
21
21
 
22
- Payload v4 requires Next 16. The command did not touch Next. Run Next's own recommended agent
22
+ Payload v4 requires Next 16.4 or higher. The command did not touch Next. Run Next's own recommended agent
23
23
  workflow, which bumps Next + React and migrates the code as one unit:
24
24
  <https://nextjs.org/docs/app/guides/upgrading/version-16#use-an-ai-agent-recommended>
25
25
 
26
- Keep the resulting Next version within `>=16.2.6 <17` (the exact target is printed in the
26
+ Keep the resulting Next version within `>=16.4.0 <17` (the exact target is printed in the
27
27
  upgrade report), since Next's `upgrade latest` may point past 16 in future.
28
28
 
29
29
  ## 2. Regenerate generated files
@@ -156,6 +156,31 @@ Run a typecheck after the codemod. Three patterns it cannot resolve:
156
156
 
157
157
  `payload.jobs.queue`, `run`, `runByID`, `cancel`, and `cancelByID` now also default `overrideAccess` to `false`. The option remains optional, but omitting it runs the corresponding `jobs.access.queue`, `jobs.access.run`, or `jobs.access.cancel` function. The codemod adds `overrideAccess: true` to these calls—including zero-argument `payload.jobs.run()` calls—to preserve Payload 3 behavior for review.
158
158
 
159
+ ### On-demand validation adds a `validate` operation
160
+
161
+ The `Operation` type now includes `validate`. The `operation` argument for collection, global, and field `beforeValidate` and `beforeChange` hooks also includes `validate`.
162
+
163
+ On-demand validation runs these hooks without saving the candidate. Update exhaustive operation checks and skip external side effects that should only run during `create` or `update`:
164
+
165
+ ```ts
166
+ import type { CollectionBeforeChangeHook } from 'payload'
167
+
168
+ const syncCustomer: CollectionBeforeChangeHook = async ({
169
+ data,
170
+ operation,
171
+ }) => {
172
+ if (operation === 'validate') {
173
+ return data
174
+ }
175
+
176
+ await syncCustomerWithStripe(data)
177
+
178
+ return data
179
+ }
180
+ ```
181
+
182
+ Sanitized collection and global access types now require a `validate` key. Payload supplies this key during configuration sanitization and uses `update` access by default. Code that constructs a sanitized access object directly must add the key.
183
+
159
184
  ### Collection and Global Access Control callbacks receive `slug`
160
185
 
161
186
  Collection and Global Access Control callback arguments now include the document's `slug`. This additive property is unlikely to affect most projects, but code that manually invokes access callbacks or `executeAccess` must now pass `slug`. Code that validates, enumerates, or compares the exact callback argument shape may also need updating.
@@ -1029,9 +1054,9 @@ Run `npx @payloadcms/codemod --transform migrate-db-types-subpath` to migrate au
1029
1054
 
1030
1055
  The minimum supported Node.js version is now **24.15.0** (previously 18.20.2). Upgrade your runtime — along with any CI, Docker images, and deployment targets — to the latest node LTS version or newer before upgrading to 4.0.
1031
1056
 
1032
- ### Minimum supported Next.js version is now 16.2.6 ([#16537](https://github.com/payloadcms/payload/pull/16537))
1057
+ ### Minimum supported Next.js version is now 16.4.0 ([#16537](https://github.com/payloadcms/payload/pull/16537))
1033
1058
 
1034
- Older versions of Next.js are no longer supported. Update Next.js to **16.2.6** or newer.
1059
+ Older versions of Next.js are no longer supported. Update Next.js to **16.4.0** or newer.
1035
1060
 
1036
1061
  ### Minimum supported TypeScript version is now 6.0.3 ([#16692](https://github.com/payloadcms/payload/pull/16692))
1037
1062
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/codemod",
3
- "version": "4.0.0-internal.58473b9",
3
+ "version": "4.0.0-internal.5e065b3",
4
4
  "description": "Codemods for migrating Payload projects across versions.",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {