@payloadcms/codemod 4.0.0-canary.37 → 4.0.0-canary.39
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.
- package/README.md +8 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.help.d.ts +4 -0
- package/dist/cli.help.d.ts.map +1 -0
- package/dist/cli.help.js +29 -0
- package/dist/cli.help.js.map +1 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -1
- package/dist/cli.parseFlags.d.ts +1 -0
- package/dist/cli.parseFlags.d.ts.map +1 -1
- package/dist/cli.parseFlags.js +6 -0
- package/dist/cli.parseFlags.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +12 -0
- package/dist/registry.js.map +1 -1
- package/dist/runbook/payload-v4-upgrade.md +2 -2
- package/dist/runbook/v4.mdx +480 -20
- package/dist/transforms/migrate-admin-context-properties/basic.input.js +32 -0
- package/dist/transforms/migrate-admin-context-properties/basic.input.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/basic.output.js +30 -0
- package/dist/transforms/migrate-admin-context-properties/basic.output.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/index.d.ts +3 -0
- package/dist/transforms/migrate-admin-context-properties/index.d.ts.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/index.js +302 -0
- package/dist/transforms/migrate-admin-context-properties/index.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/no-match.input.js +30 -0
- package/dist/transforms/migrate-admin-context-properties/no-match.input.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/no-match.output.js +30 -0
- package/dist/transforms/migrate-admin-context-properties/no-match.output.js.map +1 -0
- package/dist/transforms/migrate-aliased-exports/index.d.ts.map +1 -1
- package/dist/transforms/migrate-aliased-exports/index.js +4 -2
- package/dist/transforms/migrate-aliased-exports/index.js.map +1 -1
- package/dist/transforms/migrate-aliased-exports/request.input.js +6 -0
- package/dist/transforms/migrate-aliased-exports/request.input.js.map +1 -0
- package/dist/transforms/migrate-aliased-exports/request.output.js +5 -0
- package/dist/transforms/migrate-aliased-exports/request.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/already-set.input.js +15 -0
- package/dist/transforms/migrate-authorship-default/already-set.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/already-set.output.js +15 -0
- package/dist/transforms/migrate-authorship-default/already-set.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/basic.input.js +16 -0
- package/dist/transforms/migrate-authorship-default/basic.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/basic.output.js +18 -0
- package/dist/transforms/migrate-authorship-default/basic.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/build-config.input.js +32 -0
- package/dist/transforms/migrate-authorship-default/build-config.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/build-config.output.js +35 -0
- package/dist/transforms/migrate-authorship-default/build-config.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/globals.input.js +16 -0
- package/dist/transforms/migrate-authorship-default/globals.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/globals.output.js +17 -0
- package/dist/transforms/migrate-authorship-default/globals.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/index.d.ts +11 -0
- package/dist/transforms/migrate-authorship-default/index.d.ts.map +1 -0
- package/dist/transforms/migrate-authorship-default/index.js +141 -0
- package/dist/transforms/migrate-authorship-default/index.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/non-matching.input.js +18 -0
- package/dist/transforms/migrate-authorship-default/non-matching.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/non-matching.output.js +18 -0
- package/dist/transforms/migrate-authorship-default/non-matching.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/satisfies.input.js +11 -0
- package/dist/transforms/migrate-authorship-default/satisfies.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/satisfies.output.js +13 -0
- package/dist/transforms/migrate-authorship-default/satisfies.output.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/basic.input.js +8 -0
- package/dist/transforms/migrate-field-component-types/basic.input.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/basic.output.js +8 -0
- package/dist/transforms/migrate-field-component-types/basic.output.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/index.d.ts +3 -0
- package/dist/transforms/migrate-field-component-types/index.d.ts.map +1 -0
- package/dist/transforms/migrate-field-component-types/index.js +620 -0
- package/dist/transforms/migrate-field-component-types/index.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.input.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.output.js +31 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/collision.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/collision.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/comments.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/comments.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/comments.output.js +34 -0
- package/dist/transforms/migrate-payload-request-creation/comments.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/empty.input.js +5 -0
- package/dist/transforms/migrate-payload-request-creation/empty.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/empty.output.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/empty.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/evaluation-order.input.js +10 -0
- package/dist/transforms/migrate-payload-request-creation/evaluation-order.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/expression.input.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/expression.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/expression.output.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/expression.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/getters.input.js +52 -0
- package/dist/transforms/migrate-payload-request-creation/getters.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/index.d.ts +3 -0
- package/dist/transforms/migrate-payload-request-creation/index.d.ts.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/index.js +236 -0
- package/dist/transforms/migrate-payload-request-creation/index.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/internal.input.js +6 -0
- package/dist/transforms/migrate-payload-request-creation/internal.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/internal.output.js +6 -0
- package/dist/transforms/migrate-payload-request-creation/internal.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/non-matching.input.js +5 -0
- package/dist/transforms/migrate-payload-request-creation/non-matching.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/populated.input.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/populated.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/populated.output.js +30 -0
- package/dist/transforms/migrate-payload-request-creation/populated.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.input.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.output.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.input.js +12 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.output.js +12 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/unsupported.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/unsupported.input.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/basic.input.js +28 -0
- package/dist/transforms/migrate-sharp-to-transformer/basic.input.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/basic.output.js +39 -0
- package/dist/transforms/migrate-sharp-to-transformer/basic.output.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.input.js +27 -0
- package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.input.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.output.js +33 -0
- package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.output.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/index.d.ts +3 -0
- package/dist/transforms/migrate-sharp-to-transformer/index.d.ts.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/index.js +430 -0
- package/dist/transforms/migrate-sharp-to-transformer/index.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/no-match.input.js +11 -0
- package/dist/transforms/migrate-sharp-to-transformer/no-match.input.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/no-match.output.js +11 -0
- package/dist/transforms/migrate-sharp-to-transformer/no-match.output.js.map +1 -0
- package/dist/transforms/remove-storage-always-insert-fields/index.d.ts.map +1 -1
- package/dist/transforms/remove-storage-always-insert-fields/index.js +4 -0
- package/dist/transforms/remove-storage-always-insert-fields/index.js.map +1 -1
- package/dist/transforms/rename-diff-value-props/basic.input.js +38 -0
- package/dist/transforms/rename-diff-value-props/basic.input.js.map +1 -0
- package/dist/transforms/rename-diff-value-props/basic.output.js +38 -0
- package/dist/transforms/rename-diff-value-props/basic.output.js.map +1 -0
- package/dist/transforms/rename-diff-value-props/index.d.ts +3 -0
- package/dist/transforms/rename-diff-value-props/index.d.ts.map +1 -0
- package/dist/transforms/rename-diff-value-props/index.js +328 -0
- package/dist/transforms/rename-diff-value-props/index.js.map +1 -0
- package/dist/transforms/rename-diff-value-props/no-match.input.js +8 -0
- package/dist/transforms/rename-diff-value-props/no-match.input.js.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/index.d.ts.map +1 -1
- package/dist/transforms/rename-experimental-table-feature/index.js +7 -1
- package/dist/transforms/rename-experimental-table-feature/index.js.map +1 -1
- package/dist/upgrade/rewritePackageJson.d.ts.map +1 -1
- package/dist/upgrade/rewritePackageJson.js +52 -11
- package/dist/upgrade/rewritePackageJson.js.map +1 -1
- package/dist/utils/project.d.ts +7 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +20 -7
- package/dist/utils/project.js.map +1 -1
- package/package.json +2 -2
package/dist/runbook/v4.mdx
CHANGED
|
@@ -22,6 +22,55 @@ The codemod is idempotent and safe to run on a partially-migrated project.
|
|
|
22
22
|
|
|
23
23
|
## Breaking Changes
|
|
24
24
|
|
|
25
|
+
### Payload request creation is consolidated
|
|
26
|
+
|
|
27
|
+
Payload request creation now uses `createPayloadRequest` for local contexts and `createPayloadRequestFromWebRequest` to convert a Web `Request`. Admin context setup is exposed as `initAdminContext`.
|
|
28
|
+
|
|
29
|
+
| Old name | New name |
|
|
30
|
+
| --------------------------------------- | ------------------------------------------- |
|
|
31
|
+
| `createLocalReq` | `createPayloadRequest` |
|
|
32
|
+
| `CreateLocalReqOptions` (internal type) | `Omit<CreatePayloadRequestArgs, 'payload'>` |
|
|
33
|
+
| `createPayloadRequest` | `createPayloadRequestFromWebRequest` |
|
|
34
|
+
| `initReq` | `initAdminContext` |
|
|
35
|
+
| `InitReqArgs` | `InitAdminContextArgs` |
|
|
36
|
+
| `InitReqResult` | `AdminContext` |
|
|
37
|
+
| `InitReqCache` | `AdminContextCache` |
|
|
38
|
+
| `InitReqPartialResult` | `PartialAdminContext` |
|
|
39
|
+
|
|
40
|
+
`initAdminContext` and its cache types are primarily contracts for framework adapters. Custom Root layout adapters must rename their injected `initReq` callback to `initAdminContext`.
|
|
41
|
+
|
|
42
|
+
Local request creation now takes a single object argument containing `payload`. For a request without options:
|
|
43
|
+
|
|
44
|
+
```diff
|
|
45
|
+
-import { createLocalReq } from 'payload'
|
|
46
|
+
+import { createPayloadRequest } from 'payload'
|
|
47
|
+
|
|
48
|
+
-const req = await createLocalReq({}, payload)
|
|
49
|
+
+const req = await createPayloadRequest({ payload })
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`CreatePayloadRequestArgs` is exported from `payload` and requires `payload`. Options-only values should use `Omit<CreatePayloadRequestArgs, 'payload'>`. The old `CreateLocalReqOptions` type was declared in the internal request utility, not exported from the package root; relative/private imports of that type require manual migration. The codemod handles an existing named import of that type only when its source is `payload`.
|
|
53
|
+
|
|
54
|
+
Web request conversion uses its new role-specific name:
|
|
55
|
+
|
|
56
|
+
```diff
|
|
57
|
+
-import { createPayloadRequest } from 'payload'
|
|
58
|
+
+import { createPayloadRequestFromWebRequest } from 'payload'
|
|
59
|
+
|
|
60
|
+
-const req = await createPayloadRequest({ config, request })
|
|
61
|
+
+const req = await createPayloadRequestFromWebRequest({ config, request })
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Codemod
|
|
65
|
+
|
|
66
|
+
To migrate automatically, there's a codemod for this change available by running:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx @payloadcms/codemod --transform migrate-payload-request-creation
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Automatic call migration requires a plain identifier payload argument and either `{}` or an initialized local `const` options identifier. The options type must expose all seven old option properties, or be `any`. For that identifier form, the generated argument captures payload first and uses forwarding getters for `context`, `depth`, `fallbackLocale`, `locale`, `req`, `urlSuffix`, and `user`. This preserves inherited getters, their read order, and rejected promises from throwing getters without reading unrelated properties. Complex expressions, mutable/unresolved options bindings, narrow option types, collisions, and unsupported type usages are left unchanged with notes for manual migration.
|
|
73
|
+
|
|
25
74
|
### JWT authentication is versioned without moving token data
|
|
26
75
|
|
|
27
76
|
Payload 4 keeps the decoded JWT payload flat, so integrations can continue reading `id`, `collection`, `sid`, `email`, and fields selected by `saveToJWT` from the same paths as Payload 3.
|
|
@@ -107,6 +156,31 @@ Run a typecheck after the codemod. Three patterns it cannot resolve:
|
|
|
107
156
|
|
|
108
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.
|
|
109
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
|
+
|
|
110
184
|
### Collection and Global Access Control callbacks receive `slug`
|
|
111
185
|
|
|
112
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.
|
|
@@ -301,6 +375,39 @@ export const Posts: CollectionConfig = {
|
|
|
301
375
|
}
|
|
302
376
|
```
|
|
303
377
|
|
|
378
|
+
### Authorship (`createdBy` / `updatedBy`) is now enabled by default
|
|
379
|
+
|
|
380
|
+
Collections and globals now track authorship by default: Payload injects `createdBy` and `updatedBy` polymorphic relationship fields (related to every auth-enabled collection) and stamps them from `req.user` on each write. Previously there was no authorship tracking; you now opt out with `authorship: false`.
|
|
381
|
+
|
|
382
|
+
**What changes:**
|
|
383
|
+
|
|
384
|
+
- Every non-internal collection and global gains `createdBy` and `updatedBy` when your config has at least one auth collection. On SQL adapters this adds relationship rows (stored in each entity's `_rels` table), so existing projects need a database migration. In development the schema is pushed automatically; in production, generate a migration with `payload migrate:create` and run `payload migrate`. Existing documents are backfilled with `null`.
|
|
385
|
+
- `createdBy` is only derived on a document's first write, so editing a document whose `createdBy` is `null` (for example a migrated or anonymously created document) does not backfill the editor as the creator.
|
|
386
|
+
- Payload's internal system collections and globals are excluded automatically: `payload-jobs`, `payload-jobs-stats`, `payload-preferences`, `payload-locked-documents`, `payload-migrations`, `payload-query-presets`, and the KV collection.
|
|
387
|
+
|
|
388
|
+
**Plugins:** plugin-injected collections also receive authorship unless the plugin opts out. In this release:
|
|
389
|
+
|
|
390
|
+
- **Opted out** (no authorship): `@payloadcms/plugin-search`, `@payloadcms/payload-cloud`, and all `@payloadcms/plugin-ecommerce` collections.
|
|
391
|
+
- **Kept on** (they gain `createdBy` / `updatedBy`): `@payloadcms/plugin-redirects`, `@payloadcms/plugin-form-builder` (forms and form submissions), and `@payloadcms/plugin-import-export` (imports and exports). Existing projects using these plugins on a SQL adapter need a migration for those collections too. To opt one out, set `authorship: false` through that plugin's collection-override option.
|
|
392
|
+
|
|
393
|
+
**To opt out for an existing collection or global:**
|
|
394
|
+
|
|
395
|
+
```diff
|
|
396
|
+
export const Posts: CollectionConfig = {
|
|
397
|
+
slug: 'posts',
|
|
398
|
+
fields: [],
|
|
399
|
+
+ authorship: false,
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**A codemod is available** to preserve the previous behaviour:
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
npx @payloadcms/codemod --transform migrate-authorship-default
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
`migrate-authorship-default` adds `authorship: false` to every `CollectionConfig` and `GlobalConfig` in your source that does not already set `authorship`, so your own collections have zero schema changes. It only rewrites your config files — it cannot reach plugin-injected collections, so any plugin that keeps authorship on (above) still gains the fields and requires a migration (or an explicit `authorship: false` override).
|
|
410
|
+
|
|
304
411
|
### List View Select API is now the default
|
|
305
412
|
|
|
306
413
|
The `admin.enableListViewSelectAPI` Collection Config property has been removed. The List View now always uses the [Select API](../queries/select) to query only the active columns, which was previously opt-in.
|
|
@@ -396,20 +503,20 @@ Several types and utilities that were re-exported from `@payloadcms/ui` and `@pa
|
|
|
396
503
|
|
|
397
504
|
**Pass-through re-exports** — same name, new source:
|
|
398
505
|
|
|
399
|
-
| Symbol | Old source | New source
|
|
400
|
-
| ----------------------------- | ---------------------------- |
|
|
401
|
-
| `Column` | `@payloadcms/ui` | `payload`
|
|
402
|
-
| `ListViewSlots` | `@payloadcms/ui` | `payload`
|
|
403
|
-
| `ListViewClientProps` | `@payloadcms/ui` | `payload`
|
|
404
|
-
| `EntityType` | `@payloadcms/ui/shared` | `payload/shared`
|
|
405
|
-
| `formatAdminURL` | `@payloadcms/ui/shared` | `payload/shared`
|
|
406
|
-
| `mergeListSearchAndWhere` | `@payloadcms/ui/shared` | `payload/shared`
|
|
407
|
-
| `mergeHeaders` | `@payloadcms/next/utilities` | `payload`
|
|
408
|
-
| `headersWithCors` | `@payloadcms/next/utilities` | `payload`
|
|
409
|
-
| `createPayloadRequest` | `@payloadcms/next/utilities` | `payload`
|
|
410
|
-
| `addDataAndFileToRequest` | `@payloadcms/next/utilities` | `payload`
|
|
411
|
-
| `sanitizeLocales` | `@payloadcms/next/utilities` | `payload`
|
|
412
|
-
| `addLocalesToRequestFromData` | `@payloadcms/next/utilities` | `payload`
|
|
506
|
+
| Symbol | Old source | New source |
|
|
507
|
+
| ----------------------------- | ---------------------------- | ------------------------------------------------- |
|
|
508
|
+
| `Column` | `@payloadcms/ui` | `payload` |
|
|
509
|
+
| `ListViewSlots` | `@payloadcms/ui` | `payload` |
|
|
510
|
+
| `ListViewClientProps` | `@payloadcms/ui` | `payload` |
|
|
511
|
+
| `EntityType` | `@payloadcms/ui/shared` | `payload/shared` |
|
|
512
|
+
| `formatAdminURL` | `@payloadcms/ui/shared` | `payload/shared` |
|
|
513
|
+
| `mergeListSearchAndWhere` | `@payloadcms/ui/shared` | `payload/shared` |
|
|
514
|
+
| `mergeHeaders` | `@payloadcms/next/utilities` | `payload` |
|
|
515
|
+
| `headersWithCors` | `@payloadcms/next/utilities` | `payload` |
|
|
516
|
+
| `createPayloadRequest` | `@payloadcms/next/utilities` | `createPayloadRequestFromWebRequest` in `payload` |
|
|
517
|
+
| `addDataAndFileToRequest` | `@payloadcms/next/utilities` | `payload` |
|
|
518
|
+
| `sanitizeLocales` | `@payloadcms/next/utilities` | `payload` |
|
|
519
|
+
| `addLocalesToRequestFromData` | `@payloadcms/next/utilities` | `payload` |
|
|
413
520
|
|
|
414
521
|
**Renamed types** — use the new canonical name from `payload`:
|
|
415
522
|
|
|
@@ -428,7 +535,86 @@ Several types and utilities that were re-exported from `@payloadcms/ui` and `@pa
|
|
|
428
535
|
+ import { headersWithCors, mergeHeaders } from 'payload'
|
|
429
536
|
```
|
|
430
537
|
|
|
431
|
-
|
|
538
|
+
Running `npx @payloadcms/codemod --transform migrate-aliased-exports` preserves old local bindings by importing renamed symbols with an `as` alias (e.g. `import type { CollectionPreferences as ListPreferences } from 'payload'` or `import { createPayloadRequestFromWebRequest as createPayloadRequest } from 'payload'`). Run `migrate-payload-request-creation` to complete the request helper's identifier and call-site migration, or drop the other aliases and rename their usages manually if you want to fully commit to the new names.
|
|
539
|
+
|
|
540
|
+
### Field component types replaced by props types
|
|
541
|
+
|
|
542
|
+
Field component aliases that wrapped props in `React.ComponentType<Props>` have been removed. Import the props type directly so each component can use `React.FC<Props>` or a function declaration.
|
|
543
|
+
|
|
544
|
+
```diff
|
|
545
|
+
- import type { TextFieldClientComponent } from 'payload'
|
|
546
|
+
+ import type { TextFieldClientProps } from 'payload'
|
|
547
|
+
+ import type React from 'react'
|
|
548
|
+
|
|
549
|
+
- export const CustomTextField: TextFieldClientComponent = (props) => {
|
|
550
|
+
+ export const CustomTextField: React.FC<TextFieldClientProps> = (props) => {
|
|
551
|
+
// ...
|
|
552
|
+
}
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
Generic type arguments move to the props type:
|
|
556
|
+
|
|
557
|
+
```diff
|
|
558
|
+
- import type { FieldErrorClientComponent, TextFieldClient } from 'payload'
|
|
559
|
+
+ import type { FieldErrorClientProps, TextFieldClient } from 'payload'
|
|
560
|
+
+ import type React from 'react'
|
|
561
|
+
|
|
562
|
+
- const Error: FieldErrorClientComponent<TextFieldClient> = (props) => null
|
|
563
|
+
+ const Error: React.FC<FieldErrorClientProps<TextFieldClient>> = (props) => null
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
Function declarations can annotate their parameter without a component wrapper:
|
|
567
|
+
|
|
568
|
+
```tsx
|
|
569
|
+
import type { TextFieldServerProps } from 'payload'
|
|
570
|
+
|
|
571
|
+
export default async function CustomTextField(props: TextFieldServerProps) {
|
|
572
|
+
// ...
|
|
573
|
+
}
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
This covers main field components, labels, descriptions, errors, diffs, and block row labels. Admin-view types such as `AdminViewComponent` and `DocumentTabComponent` are separate.
|
|
577
|
+
|
|
578
|
+
#### Codemod
|
|
579
|
+
|
|
580
|
+
To migrate automatically, there's a codemod for this change available by running:
|
|
581
|
+
|
|
582
|
+
```bash
|
|
583
|
+
npx @payloadcms/codemod --transform migrate-field-component-types
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
### Diff component props `comparisonValue` and `versionValue` renamed to `valueFrom` and `valueTo`
|
|
587
|
+
|
|
588
|
+
Custom Diff Components (`admin.components.Diff`) receive the two field values being compared as `valueFrom` and `valueTo`. The `comparisonValue` and `versionValue` props have been removed from `FieldDiffClientProps` and `FieldDiffServerProps`, including every field-specific variant such as `TextFieldDiffClientProps`.
|
|
589
|
+
|
|
590
|
+
| Old prop | New prop | Description |
|
|
591
|
+
| ----------------- | ----------- | ------------------------------------------------ |
|
|
592
|
+
| `comparisonValue` | `valueFrom` | Field value from the version being compared from |
|
|
593
|
+
| `versionValue` | `valueTo` | Field value from the version being compared to |
|
|
594
|
+
|
|
595
|
+
```diff
|
|
596
|
+
import type { TextFieldDiffClientProps } from 'payload'
|
|
597
|
+
import type React from 'react'
|
|
598
|
+
|
|
599
|
+
export const MyTextDiff: React.FC<TextFieldDiffClientProps> = ({
|
|
600
|
+
- comparisonValue,
|
|
601
|
+
- versionValue,
|
|
602
|
+
+ valueFrom,
|
|
603
|
+
+ valueTo,
|
|
604
|
+
}) => {
|
|
605
|
+
// ...
|
|
606
|
+
}
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
#### Codemod
|
|
610
|
+
|
|
611
|
+
To migrate automatically, there's a codemod for this change available by running:
|
|
612
|
+
|
|
613
|
+
```bash
|
|
614
|
+
npx @payloadcms/codemod --transform rename-diff-value-props
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
The codemod updates functions whose props are typed with a Diff props or component type imported from `payload` (e.g. `TextFieldDiffClientProps`), or with a type in the same file built from one. It renames destructured props and reads such as `props.comparisonValue`. Untyped components and props passed on to other components (e.g. `<OtherDiff comparisonValue={...} />`) aren't changed automatically; the codemod prints a note for each leftover in files that import a Diff type.
|
|
432
618
|
|
|
433
619
|
### `DefaultValue` function variant is now typed to allow returning a `Promise` ([#17522](https://github.com/payloadcms/payload/pull/17522))
|
|
434
620
|
|
|
@@ -727,6 +913,49 @@ When a missing locale is already valid for the receiving API, optional chaining
|
|
|
727
913
|
const locale = useLocale()?.code
|
|
728
914
|
```
|
|
729
915
|
|
|
916
|
+
### `readOnly` removed from the `useField` return type
|
|
917
|
+
|
|
918
|
+
The deprecated `readOnly` property has been removed from `FieldType`, the object returned by `useField`. `useField` already stopped returning it in 3.x, so it was always `undefined` at runtime.
|
|
919
|
+
|
|
920
|
+
Read `readOnly` from your field component's props instead:
|
|
921
|
+
|
|
922
|
+
````diff
|
|
923
|
+
'use client'
|
|
924
|
+
import type { TextFieldClientComponent } from 'payload'
|
|
925
|
+
import { useField } from '@payloadcms/ui'
|
|
926
|
+
|
|
927
|
+
-export const MyField: TextFieldClientComponent = ({ path }) => {
|
|
928
|
+
- const { readOnly, value } = useField({ path })
|
|
929
|
+
+export const MyField: TextFieldClientComponent = ({ path, readOnly }) => {
|
|
930
|
+
+ const { value } = useField({ path })
|
|
931
|
+
|
|
932
|
+
### Deprecated `TableColumnsProvider` props removed
|
|
933
|
+
|
|
934
|
+
The following deprecated props have been removed from `TableColumnsProvider` and its `TableColumnsProviderProps` type:
|
|
935
|
+
|
|
936
|
+
- `docs`
|
|
937
|
+
- `enableRowSelections`
|
|
938
|
+
- `listPreferences`
|
|
939
|
+
- `preferenceKey`
|
|
940
|
+
- `renderRowTypes`
|
|
941
|
+
- `setTable`
|
|
942
|
+
- `sortColumnProps`
|
|
943
|
+
- `tableAppearance`
|
|
944
|
+
|
|
945
|
+
`TableColumnsProvider` has ignored these props since 3.26.0, when column state moved to the URL. Remove them where you render the provider. It now only accepts `children`, `collectionSlug`, `columnState`, and `LinkedCellOverride`.
|
|
946
|
+
|
|
947
|
+
```diff
|
|
948
|
+
<TableColumnsProvider
|
|
949
|
+
collectionSlug={collectionSlug}
|
|
950
|
+
columnState={columnState}
|
|
951
|
+
- enableRowSelections
|
|
952
|
+
- preferenceKey={preferenceKey}
|
|
953
|
+
- tableAppearance="condensed"
|
|
954
|
+
>
|
|
955
|
+
{children}
|
|
956
|
+
</TableColumnsProvider>
|
|
957
|
+
````
|
|
958
|
+
|
|
730
959
|
### RichText adapter `i18n` property removed
|
|
731
960
|
|
|
732
961
|
The `i18n` property on `RichTextAdapter` (and its return type from adapter provider functions) has been removed. It was deprecated in v3 in favour of merging translations directly into `config.i18n.translations` inside the adapter provider.
|
|
@@ -788,6 +1017,52 @@ If an affected adapter or feature performs asynchronous work, move that work to
|
|
|
788
1017
|
|
|
789
1018
|
The `transactionIDPromise` property on `PayloadRequest` has been removed. It was deprecated and unused — `transactionID` (which already supports `Promise<number | string>`) is the correct property to use for both resolved values and pending transactions.
|
|
790
1019
|
|
|
1020
|
+
### `headers` and `languageCode` removed from `AdminContext`
|
|
1021
|
+
|
|
1022
|
+
The `headers` and `languageCode` properties have been removed from `AdminContext`, the object returned by `initAdminContext`. Both duplicated values that are already available on `req`:
|
|
1023
|
+
|
|
1024
|
+
```diff
|
|
1025
|
+
const context = await initAdminContext(args)
|
|
1026
|
+
|
|
1027
|
+
-const userAgent = context.headers.get('user-agent')
|
|
1028
|
+
+const userAgent = context.req.headers.get('user-agent')
|
|
1029
|
+
|
|
1030
|
+
-const languageCode = context.languageCode
|
|
1031
|
+
+const languageCode = context.req.i18n.language
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
`req.i18n.language` is typed as `string`. Cast it to `AcceptedLanguages` if you need the narrower type.
|
|
1035
|
+
|
|
1036
|
+
`languageCode` has also been removed from `PartialAdminContext`. Use `i18n.language` instead. `getRootLayoutData` from `@payloadcms/ui` no longer accepts `headers` or `languageCode` and reads both from `req`.
|
|
1037
|
+
|
|
1038
|
+
#### Codemod
|
|
1039
|
+
|
|
1040
|
+
To migrate automatically, run:
|
|
1041
|
+
|
|
1042
|
+
```bash
|
|
1043
|
+
npx @payloadcms/codemod --transform migrate-admin-context-properties
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
The codemod rewrites property reads and destructures on `initAdminContext()` results and on parameters or variables typed as `AdminContext` or `PartialAdminContext`. It also updates `Pick<AdminContext, ...>` and `AdminContext['...']` types and drops both arguments from `getRootLayoutData()` calls. Element access such as `context['headers']`, and contexts passed through your own wrapper functions, are left unchanged for manual migration.
|
|
1047
|
+
|
|
1048
|
+
### `DiffMethod` type removed
|
|
1049
|
+
|
|
1050
|
+
The deprecated `DiffMethod` type has been removed from `payload`. It mirrored an enum from `react-diff-viewer-continued`, which Payload no longer depends on. Remove any imports of `DiffMethod`.
|
|
1051
|
+
|
|
1052
|
+
### `diffMethod` prop removed from Diff components
|
|
1053
|
+
|
|
1054
|
+
Custom Diff components (`admin.components.Diff`) no longer receive a `diffMethod` prop. It has been removed from `FieldDiffClientProps` and every field-specific variant like `TextFieldDiffClientProps`. Payload always passed the same `'diffWordsWithSpace'` value, so the prop carried no information. Each Diff component handles its own diffing.
|
|
1055
|
+
|
|
1056
|
+
Remove `diffMethod` from your props. If you passed it on to a diffing utility, pass `'diffWordsWithSpace'` directly instead:
|
|
1057
|
+
|
|
1058
|
+
```diff
|
|
1059
|
+
export const MyTextDiff: React.FC<TextFieldDiffClientProps> = ({
|
|
1060
|
+
- diffMethod,
|
|
1061
|
+
valueFrom,
|
|
1062
|
+
valueTo,
|
|
1063
|
+
}) => {
|
|
1064
|
+
```
|
|
1065
|
+
|
|
791
1066
|
### Collection `afterOperation` hook: `operation: 'read'` removed
|
|
792
1067
|
|
|
793
1068
|
The deprecated `'read'` value for the `operation` argument of collection `afterOperation` hooks has been removed. Payload has not dispatched `afterOperation` with `operation: 'read'` for some time — the `find` and `findByID` operations report their own names (`'find'` and `'findByID'`) instead.
|
|
@@ -897,13 +1172,22 @@ If you use a `declare module` augmentation to extend `GeneratedDatabaseSchema` (
|
|
|
897
1172
|
|
|
898
1173
|
Run `npx @payloadcms/codemod --transform migrate-db-types-subpath` to migrate automatically. The codemod handles import declarations, re-export declarations, and `declare module` augmentations.
|
|
899
1174
|
|
|
1175
|
+
### `findMigrationDir` removed from `@payloadcms/drizzle`
|
|
1176
|
+
|
|
1177
|
+
The deprecated `findMigrationDir` re-export has been removed from `@payloadcms/drizzle`. Import it from `payload` instead:
|
|
1178
|
+
|
|
1179
|
+
```diff
|
|
1180
|
+
- import { findMigrationDir } from '@payloadcms/drizzle'
|
|
1181
|
+
+ import { findMigrationDir } from 'payload'
|
|
1182
|
+
```
|
|
1183
|
+
|
|
900
1184
|
### Minimum supported Node.js version is now 24.15.0 ([#16540](https://github.com/payloadcms/payload/pull/16540))
|
|
901
1185
|
|
|
902
1186
|
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.
|
|
903
1187
|
|
|
904
|
-
### Minimum supported Next.js version is now 16.
|
|
1188
|
+
### Minimum supported Next.js version is now 16.4.0 ([#16537](https://github.com/payloadcms/payload/pull/16537))
|
|
905
1189
|
|
|
906
|
-
Older versions of Next.js are no longer supported. Update Next.js to **16.
|
|
1190
|
+
Older versions of Next.js are no longer supported. Update Next.js to **16.4.0** or newer.
|
|
907
1191
|
|
|
908
1192
|
### Minimum supported TypeScript version is now 6.0.3 ([#16692](https://github.com/payloadcms/payload/pull/16692))
|
|
909
1193
|
|
|
@@ -959,9 +1243,9 @@ The deprecated `isHTMLElement` utility has been removed from `@payloadcms/richte
|
|
|
959
1243
|
|
|
960
1244
|
`lexical`'s built-in `isHTMLElement` is the canonical implementation and narrows against the node's owning-document `HTMLElement`, so it is also safe across iframes and other realms.
|
|
961
1245
|
|
|
962
|
-
### Lexical: vendored `@lexical/markdown` fork removed and lexical upgraded to `0.
|
|
1246
|
+
### Lexical: vendored `@lexical/markdown` fork removed and lexical upgraded to `0.52.0`
|
|
963
1247
|
|
|
964
|
-
`@payloadcms/richtext-lexical` no longer ships a vendored copy of `@lexical/markdown`. The package is now a direct dependency, every `@lexical/*` package was upgraded from `0.41.0` to `0.
|
|
1248
|
+
`@payloadcms/richtext-lexical` no longer ships a vendored copy of `@lexical/markdown`. The package is now a direct dependency, every `@lexical/*` package was upgraded from `0.41.0` to `0.52.0`, and `@payloadcms/richtext-lexical/lexical/markdown` is a pure passthrough of `@lexical/markdown`.
|
|
965
1249
|
|
|
966
1250
|
Most projects use markdown through the editor or through `convertMarkdownToLexical` / `convertLexicalToMarkdown` and need no changes. You are only affected if you import from `@payloadcms/richtext-lexical/lexical/markdown` directly.
|
|
967
1251
|
|
|
@@ -985,7 +1269,16 @@ If you keep calling `$convertFromMarkdownString` directly, pass `editorConfig.fe
|
|
|
985
1269
|
|
|
986
1270
|
**Whitespace-only markdown table cells now import as an empty paragraph** instead of a text node of padding spaces. This comes from the lexical upgrade, not Payload's own code. No action is required unless you assert on those padding spaces in stored content.
|
|
987
1271
|
|
|
988
|
-
If you import lexical APIs directly through `@payloadcms/richtext-lexical/lexical/*`, also review the [lexical breaking changes](https://github.com/facebook/lexical/releases) between `0.41.0` and `0.
|
|
1272
|
+
If you import lexical APIs directly through `@payloadcms/richtext-lexical/lexical/*`, also review the [lexical breaking changes](https://github.com/facebook/lexical/releases) between `0.41.0` and `0.52.0`. None of them require action for typical Payload usage.
|
|
1273
|
+
|
|
1274
|
+
If your app imports Lexical types or adds custom features, check these changes from `0.50.0`. They also apply to imports through `@payloadcms/richtext-lexical/lexical` and its subpaths:
|
|
1275
|
+
|
|
1276
|
+
- Lexical packages are ESM only. Use ESM imports; CommonJS `require()` needs Node.js 20.19 or later.
|
|
1277
|
+
- `SELECTION_CHANGE_COMMAND` now runs before DOM reconciliation. Defer DOM lookups and floating UI positioning with `$onUpdate(() => editor.read('latest', callback))`, or use an update listener for work that should run after every commit.
|
|
1278
|
+
- Call `node.getLatest().exportJSON()` when serializing a node reference retained across an update. Payload continues to write the full JSON format; compact export is not enabled.
|
|
1279
|
+
- `SerializedEditorState<T>`, `SerializedElementNode<T>`, and `SerializedRootNode<T>` no longer accept a type argument. Remove `<T>` if you only need the base node type. For a document with your own node types, use Payload's `TypedEditorState<T>` instead. Without a type argument, Lexical's `children` are still typed as `SerializedLexicalNode[]`.
|
|
1280
|
+
- `ReturnType<Node['exportJSON']>` can now infer partial JSON, making fields such as `version` and `url` optional. If your code expects the full format, use the node's explicit serialized type, such as `SerializedLinkNode`. A normal `node.exportJSON()` call still returns the full format.
|
|
1281
|
+
- `LexicalNode.getCommonAncestor` was removed. Use `$getCommonAncestor(a, b)?.commonAncestor ?? null`; pass the parents of non-element nodes if you need the old method's behavior.
|
|
989
1282
|
|
|
990
1283
|
### Lexical: `EXPERIMENTAL_TableFeature` renamed to `TableFeature`
|
|
991
1284
|
|
|
@@ -1003,6 +1296,43 @@ The table feature is no longer experimental, so it drops its prefix.
|
|
|
1003
1296
|
|
|
1004
1297
|
Stored content is unaffected.
|
|
1005
1298
|
|
|
1299
|
+
### Lexical: `LexicalEditorProps` renamed to `LexicalEditorArgs`
|
|
1300
|
+
|
|
1301
|
+
The `LexicalEditorProps` type exported from `@payloadcms/richtext-lexical` has been renamed to `LexicalEditorArgs`. It describes the arguments of the `lexicalEditor` function, not component props. The shape is unchanged.
|
|
1302
|
+
|
|
1303
|
+
````diff
|
|
1304
|
+
- import type { LexicalEditorProps } from '@payloadcms/richtext-lexical'
|
|
1305
|
+
+ import type { LexicalEditorArgs } from '@payloadcms/richtext-lexical'
|
|
1306
|
+
|
|
1307
|
+
### Lexical: `UploadDataImproved` replaced by `UploadData` ([#18606](https://github.com/payloadcms/payload/pull/18606))
|
|
1308
|
+
|
|
1309
|
+
The internal `UploadDataImproved` type has been removed, and its definition is now used by the public `UploadData` type. Replace any `UploadDataImproved` imports and type references with `UploadData`:
|
|
1310
|
+
|
|
1311
|
+
```ts
|
|
1312
|
+
import type { UploadData } from '@payloadcms/richtext-lexical'
|
|
1313
|
+
````
|
|
1314
|
+
|
|
1315
|
+
### Lexical: the `version` of nodes is ignored
|
|
1316
|
+
|
|
1317
|
+
Lexical deprecated the `version` property of serialized nodes, and now ignores it when it loads a document. Payload no longer reads it either.
|
|
1318
|
+
|
|
1319
|
+
**Rich text written by the Payload 3.0 betas is no longer upgraded when it's loaded.** Payload used `version: 1` to detect two older shapes:
|
|
1320
|
+
|
|
1321
|
+
- Block nodes whose fields were wrapped in an extra `data` object (`fields.data`)
|
|
1322
|
+
- Relationship and upload nodes that stored the whole related document in `value`, instead of its ID
|
|
1323
|
+
|
|
1324
|
+
If your database may still contain rich text from the 3.0 betas, run `upgradeLexicalData` on the latest 3.x release before you upgrade to 4.0. It re-saves every document, which converts these shapes:
|
|
1325
|
+
|
|
1326
|
+
```ts
|
|
1327
|
+
import { upgradeLexicalData } from '@payloadcms/richtext-lexical'
|
|
1328
|
+
|
|
1329
|
+
await upgradeLexicalData({ payload })
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
**`version` is optional in the JSON schema of Lexical nodes.** The CLI and MCP no longer require it, and leave it out of the schema they show agents. They still accept it, so existing documents, which contain `version`, stay valid input.
|
|
1333
|
+
|
|
1334
|
+
**Payload doesn't add or remove `version` when it saves rich text.** Rich text created by Lexical, like in the admin panel, still has `version: 1` on every node, because Lexical's JSON export writes it. Payload's own nodes used to write their own numbers instead (like `2` for blocks), and now write `1` as well. Rich text sent through the API, CLI or MCP is saved as sent, so it may not contain `version`. The generated types still include `version`, marked as deprecated, so don't rely on it being there.
|
|
1335
|
+
|
|
1006
1336
|
### Field `typescriptSchema` renamed to `jsonSchema`
|
|
1007
1337
|
|
|
1008
1338
|
`typescriptSchema` accepted JSON Schema, not TypeScript, so the name lied. Renamed to `jsonSchema`. Same shape, same array of transforms. The underlying schema is now also consumed by the MCP plugin for runtime validation, not just type generation.
|
|
@@ -1540,6 +1870,8 @@ If you typed `clientUploads.access`, replace `ClientUploadsAccess` with `UploadI
|
|
|
1540
1870
|
|
|
1541
1871
|
#### If you maintain a custom storage adapter
|
|
1542
1872
|
|
|
1873
|
+
File versioning adds a required `GeneratedAdapter.copyFile` method. Copy `from` to `to` (complete storage keys) without changing the source, reject an existing destination, and return only once the destination is readable. `moveFile` stays optional. See [Custom Storage Adapters](../upload/storage-adapters) for the full contract.
|
|
1874
|
+
|
|
1543
1875
|
Replace `clientUploadContext` with `uploadReference` in generated file metadata and static handler parameters. `handleUpload` no longer receives it because Payload skips uploading files that are already stored.
|
|
1544
1876
|
|
|
1545
1877
|
Set `uploadInstructions.enabled`. When false, Payload adds `adminHandler` to the import map without rendering it. When true, Payload also renders it and exposes the instructions and supporting endpoint.
|
|
@@ -1677,6 +2009,126 @@ azureStorage({
|
|
|
1677
2009
|
|
|
1678
2010
|
Run `npx @payloadcms/codemod --transform migrate-azure-chunk-large-files` to remove the flag automatically (it collapses `clientUploads: { chunkLargeFiles: true }` to `clientUploads: true` and keeps any other `clientUploads` options).
|
|
1679
2011
|
|
|
2012
|
+
### Sharp moved out of core into `@payloadcms/transformer-sharp`
|
|
2013
|
+
|
|
2014
|
+
Image resizing is no longer built into `payload` itself. It now ships as an official [file transformer](../upload/transformers), `@payloadcms/transformer-sharp`, that you register under `upload.transformers`.
|
|
2015
|
+
|
|
2016
|
+
This affects four things:
|
|
2017
|
+
|
|
2018
|
+
1. The top-level `sharp` config property has been removed. Passing a Sharp instance now happens through `sharpTransformer({ sharp })` instead.
|
|
2019
|
+
2. Per-collection Sharp options — `constructorOptions`, `formatOptions`, `resizeOptions`, `trimOptions`, and `withMetadata` — have been removed from `CollectionConfig['upload']`. They're now authored through `sharpTransformer({ collections })`.
|
|
2020
|
+
- `imageSizes` has also been removed from `CollectionConfig['upload']`. Image sizes are now declared as `variants` on `sharpTransformer({ collections: { <slug>: { variants } } })`. The entries themselves (`name`, `width`, `height`, `generateImageName`, and so on) are unchanged. A collection that still sets `upload.imageSizes` fails the build.
|
|
2021
|
+
3. `sharp` is no longer a dependency of `payload` at all (previously a `devDependency`, not a runtime `dependency`). Install `@payloadcms/transformer-sharp` explicitly.
|
|
2022
|
+
4. The Sharp-specific types `SharpDependency`, `ImageUploadFormatOptions`, `ImageUploadTrimOptions`, and `SharpImageSizeOptions` are no longer exported from `payload`. Import `SharpDependency` from `@payloadcms/transformer-sharp`. For the option types, use `SharpCollectionConfig['formatOptions']`, `SharpCollectionConfig['trimOptions']`, and `NonNullable<SharpCollectionConfig['variants']>[number]` from the same package.
|
|
2023
|
+
|
|
2024
|
+
```sh
|
|
2025
|
+
pnpm add @payloadcms/transformer-sharp
|
|
2026
|
+
```
|
|
2027
|
+
|
|
2028
|
+
```diff
|
|
2029
|
+
+ import { sharpTransformer } from '@payloadcms/transformer-sharp'
|
|
2030
|
+
import { buildConfig } from 'payload'
|
|
2031
|
+
|
|
2032
|
+
export default buildConfig({
|
|
2033
|
+
collections: [
|
|
2034
|
+
{
|
|
2035
|
+
slug: 'media',
|
|
2036
|
+
upload: {
|
|
2037
|
+
- resizeOptions: { width: 2048, height: 2048 },
|
|
2038
|
+
- imageSizes: [{ name: 'thumbnail', width: 400, height: 300 }],
|
|
2039
|
+
},
|
|
2040
|
+
},
|
|
2041
|
+
],
|
|
2042
|
+
- sharp,
|
|
2043
|
+
upload: {
|
|
2044
|
+
+ transformers: [
|
|
2045
|
+
+ sharpTransformer({
|
|
2046
|
+
+ sharp,
|
|
2047
|
+
+ collections: {
|
|
2048
|
+
+ media: {
|
|
2049
|
+
+ resizeOptions: { width: 2048, height: 2048 },
|
|
2050
|
+
+ variants: [{ name: 'thumbnail', width: 400, height: 300 }],
|
|
2051
|
+
+ },
|
|
2052
|
+
+ },
|
|
2053
|
+
+ }),
|
|
2054
|
+
+ ],
|
|
2055
|
+
},
|
|
2056
|
+
})
|
|
2057
|
+
```
|
|
2058
|
+
|
|
2059
|
+
Run `npx @payloadcms/codemod --transform migrate-sharp-to-transformer` to migrate automatically. The codemod moves a top-level `sharp` dependency and inline collection Sharp options — including `crop` and `focalPoint` — into `sharpTransformer({ collections })` (writing `imageSizes` as `variants`), appends to an existing `upload.transformers` array if you already have one, and leaves anything it can't safely rewrite in place with a note — for example, a `collections` array built by a function call, or a collection defined outside the `buildConfig` call. Review those manually. For a config that already registers `sharpTransformer`, it only renames `imageSizes` to `variants` inside the existing `sharpTransformer` call and flags a leftover top-level `sharp` property; it doesn't move any remaining collection options.
|
|
2060
|
+
|
|
2061
|
+
Your `variants`, `crop`, and `focalPoint` are readable at `collection.upload.variants`/`.crop`/`.focalPoint` on the **sanitized** config (for example `req.payload.collections.media.config.upload.variants`). Code that read the sanitized `upload.imageSizes` in 3.x must read `upload.variants` instead. `sharpTransformer` writes a projection of what you configure back onto the sanitized collection at startup, so the Admin Panel and the rest of core see the same configuration. For a collection configured on `sharpTransformer`, a `crop` or `focalPoint` set on the transformer replaces the collection's own value; one left unset there keeps the collection's. Neither `imageSizes` nor `variants` can be set on the collection at all.
|
|
2062
|
+
|
|
2063
|
+
If you inject a custom Sharp build or version, pass it the same way:
|
|
2064
|
+
|
|
2065
|
+
```diff
|
|
2066
|
+
- buildConfig({ sharp: myCustomSharp })
|
|
2067
|
+
+ sharpTransformer({ sharp: myCustomSharp })
|
|
2068
|
+
```
|
|
2069
|
+
|
|
2070
|
+
`sharpTransformer` can also resize images at request time (`/api/media/file/photo.png?width=400`). This is new in Payload 4 and **disabled by default**, so a migrated config keeps serving only the original file and your pre-generated `variants`. The codemod doesn't enable it. To opt in, pass `dynamic: true` or `dynamic: { collections: ['media'] }` — see [Dynamic (request-time) resizing](../upload/transformers#dynamic-request-time-resizing), and [Securing dynamic resizing](../upload/transformers#securing-dynamic-resizing) before enabling it on a publicly readable collection.
|
|
2071
|
+
|
|
2072
|
+
#### The stored `sizes` field on upload documents is renamed to `variants`
|
|
2073
|
+
|
|
2074
|
+
The group field that holds each generated image size on an upload document is now `variants` instead of `sizes`. Every place that reads or queries it changes:
|
|
2075
|
+
|
|
2076
|
+
```diff
|
|
2077
|
+
- doc.sizes?.thumbnail?.url
|
|
2078
|
+
+ doc.variants?.thumbnail?.url
|
|
2079
|
+
|
|
2080
|
+
- where: { 'sizes.thumbnail.filename': { equals: 'photo-400x300.png' } }
|
|
2081
|
+
+ where: { 'variants.thumbnail.filename': { equals: 'photo-400x300.png' } }
|
|
2082
|
+
|
|
2083
|
+
- select: { sizes: { thumbnail: true } }
|
|
2084
|
+
+ select: { variants: { thumbnail: true } }
|
|
2085
|
+
```
|
|
2086
|
+
|
|
2087
|
+
GraphQL queries select `variants { thumbnail { url } }` instead of `sizes { thumbnail { url } }`, and regenerated types expose `variants?: { ... }` (and `variants?: T | { ... }` on the `*Select` types) in place of `sizes`. Update any frontend code that reads `media.sizes`, including values you pass to helpers such as `getBestFitFromSizes({ sizes: doc.variants })`.
|
|
2088
|
+
|
|
2089
|
+
Existing documents must be migrated. Create the predefined migration for your database adapter and run it:
|
|
2090
|
+
|
|
2091
|
+
<Banner type="warning">
|
|
2092
|
+
Payload 4 uses `variants` as the top-level field for generated upload
|
|
2093
|
+
variants. If an upload collection already defines a custom field named
|
|
2094
|
+
`variants`, rename that field before you run the predefined migration. Choose
|
|
2095
|
+
a new name, update your config, and write a custom migration that moves the
|
|
2096
|
+
existing custom data from `variants` to the new field. Then run the predefined
|
|
2097
|
+
`sizes-to-variants` migration. If legacy `sizes` data or columns and custom
|
|
2098
|
+
`variants` data or columns are both present, the predefined migration stops
|
|
2099
|
+
before it changes data or indexes. It cannot choose a new name or merge this
|
|
2100
|
+
custom data for you.
|
|
2101
|
+
</Banner>
|
|
2102
|
+
|
|
2103
|
+
```sh
|
|
2104
|
+
# MongoDB
|
|
2105
|
+
payload migrate:create --file @payloadcms/db-mongodb/sizes-to-variants
|
|
2106
|
+
# Postgres
|
|
2107
|
+
payload migrate:create --file @payloadcms/db-postgres/sizes-to-variants
|
|
2108
|
+
# Vercel Postgres
|
|
2109
|
+
payload migrate:create --file @payloadcms/db-vercel-postgres/sizes-to-variants
|
|
2110
|
+
# SQLite
|
|
2111
|
+
payload migrate:create --file @payloadcms/db-sqlite/sizes-to-variants
|
|
2112
|
+
# Cloudflare D1
|
|
2113
|
+
payload migrate:create --file @payloadcms/db-d1-sqlite/sizes-to-variants
|
|
2114
|
+
|
|
2115
|
+
payload migrate
|
|
2116
|
+
```
|
|
2117
|
+
|
|
2118
|
+
**Postgres and SQLite (including Vercel Postgres and D1):** the columns are renamed in place from `sizes_<name>_<property>` to `variants_<name>_<property>`, on each upload collection's table and its versions table, along with their indexes. Use the predefined migration above **instead of** a plain `payload migrate:create` for this change. A generated migration would drop the `sizes_*` columns and add new `variants_*` columns, losing the stored image size data. The predefined migration also writes the schema snapshot, so the next generated migration starts from the renamed columns.
|
|
2119
|
+
|
|
2120
|
+
On MongoDB the migration renames `sizes` (and `version.sizes` on versions) with `$rename` and re-creates the indexes on those fields under the new path. Run the migration before the upgraded app writes to upload documents.
|
|
2121
|
+
|
|
2122
|
+
#### The file endpoint changes once any transformer is registered
|
|
2123
|
+
|
|
2124
|
+
Registering any transformer under `upload.transformers` — including `sharpTransformer()` with dynamic resizing off — routes every file request through the transformer-aware handler:
|
|
2125
|
+
|
|
2126
|
+
- A file must belong to an upload document to be served. A file that exists in storage without a matching document now returns `404`.
|
|
2127
|
+
- For files whose MIME type a transformer declares (every image, with `sharpTransformer()`), `access.read` can run twice per request: once with `req.fileTransform` set to `true` to decide a possible transform, and once without it for an ordinary read. Keep `access.read` cheap, and use `req.fileTransform` to restrict transformed reads — see [Access control](../upload/transformers#access-control).
|
|
2128
|
+
- Responses produced by a transformer always carry Payload's CORS headers, which `modifyResponseHeaders` can't override.
|
|
2129
|
+
|
|
2130
|
+
To link to a file from your own code, including with transformer query parameters, use the new `generatePayloadFileURL` helper (exported from `payload` and `payload/shared`). It always builds the access-controlled Payload file endpoint, so links never bypass `access.read` by pointing straight at storage.
|
|
2131
|
+
|
|
1680
2132
|
### Storage adapters always insert the `prefix` field now — `alwaysInsertFields` removed
|
|
1681
2133
|
|
|
1682
2134
|
The `alwaysInsertFields` option (on `cloudStoragePlugin` and every `storage-*` adapter: `-s3`, `-azure`, `-gcs`, `-r2`, `-vercel-blob`) has been removed. The behavior it used to opt into — always inserting the hidden `prefix` field into the collection schema — is now unconditional, so the schema stays consistent whether or not a collection configures a `prefix` and whether or not the plugin is `enabled`.
|
|
@@ -1692,6 +2144,12 @@ The `alwaysInsertFields` option (on `cloudStoragePlugin` and every `storage-*` a
|
|
|
1692
2144
|
- Remove `alwaysInsertFields` from your storage adapter or `cloudStoragePlugin` config — it has no effect and no longer exists on the option types.
|
|
1693
2145
|
- For Postgres, SQLite, or D1 projects, run `payload migrate:create` to generate the migration that adds the `prefix` column, then run `payload migrate` to apply it.
|
|
1694
2146
|
|
|
2147
|
+
### Upload collections retain originals and file history
|
|
2148
|
+
|
|
2149
|
+
Upload collections now store `original` metadata and a `prefix` and `_objectKey` for each stored file (the main file, `original`, and each variant), so saved versions can find their files. New uploads keep their source under an `-original` filename. Update any code or infrastructure that relies on the old filename, URL, or object key.
|
|
2150
|
+
|
|
2151
|
+
**Postgres and SQLite:** after updating, run `payload migrate:create`, check that it adds these columns to each upload collection table and its versions table, then run `payload migrate`. Existing rows keep `null` values until their next write.
|
|
2152
|
+
|
|
1695
2153
|
### `FileSizeImproved` removed — use `FileSize` ([#16593](https://github.com/payloadcms/payload/pull/16593))
|
|
1696
2154
|
|
|
1697
2155
|
`FileSizeImproved` has been merged into `FileSize`. The `url`, `width`, `height`, `filesize`, `mimeType`, and `filename` properties now accept `null` directly on `FileSize`, matching what the database stores for sizes that were not generated.
|
|
@@ -1946,6 +2404,8 @@ By default, MCP items require an authenticated user. Built-in collection and glo
|
|
|
1946
2404
|
|
|
1947
2405
|
**Dependencies.** The plugin now builds on `@modelcontextprotocol/server` instead of `@modelcontextprotocol/sdk` + `mcp-handler`. It no longer depends on Zod directly; its built-in tools use the Zod Mini export from `payload`. If your custom tools use regular Zod, install Zod v4 in your project and import it directly.
|
|
1948
2406
|
|
|
2407
|
+
**HTTP requests have a size limit.** `POST /api/mcp` now answers request bodies over 4 MiB with `413`. Base64 file uploads count toward this limit. Raise it with `mcp.maxRequestBodySize`.
|
|
2408
|
+
|
|
1949
2409
|
### `@payloadcms/ui/scss` export removed and legacy `--theme-*` tokens retired
|
|
1950
2410
|
|
|
1951
2411
|
The Admin UI styles were migrated from SCSS to plain CSS. The `@payloadcms/ui/scss` package export and its SCSS source files have been removed, and the legacy `--theme-*` CSS variables were retired in favor of semantic `--color-*` tokens and the raw `--ramp-*` color palette.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getRootLayoutData } from '@payloadcms/ui/layouts/Root/getRootLayoutData';
|
|
2
|
+
import { initAdminContext } from 'payload/internal';
|
|
3
|
+
export async function getLayoutData(args) {
|
|
4
|
+
const context = await initAdminContext(args);
|
|
5
|
+
const { cookies, headers, languageCode, permissions, req, user } = context;
|
|
6
|
+
const data = await getRootLayoutData({
|
|
7
|
+
cookies,
|
|
8
|
+
headers,
|
|
9
|
+
importMap: args.importMap,
|
|
10
|
+
languageCode,
|
|
11
|
+
permissions,
|
|
12
|
+
req,
|
|
13
|
+
user
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
data,
|
|
17
|
+
userAgent: context.headers.get('user-agent')
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export async function getTheme(args) {
|
|
21
|
+
const { headers: requestHeaders, languageCode, user } = await initAdminContext(args);
|
|
22
|
+
return {
|
|
23
|
+
languageCode,
|
|
24
|
+
theme: requestHeaders.get('sec-ch-prefers-color-scheme'),
|
|
25
|
+
user
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export const getUserAgent = async (args)=>(await initAdminContext(args)).headers.get('user-agent');
|
|
29
|
+
export const getDirection = (context)=>context.languageCode === 'ar' ? 'rtl' : 'ltr';
|
|
30
|
+
export const getAcceptLanguage = ({ headers })=>headers.get('accept-language');
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=basic.input.js.map
|