refactor(payload): pass literal operation to buildBeforeOperation - #17820
refactor(payload): pass literal operation to buildBeforeOperation#17820DanRibbens wants to merge 1 commit into
Conversation
The find, findByID, findDistinct, deleteByID, and updateByID operations now
pass their literal operation name to buildBeforeOperation instead of the coarse
aliases ('read', 'readDistinct', 'delete', 'update'). This lets the deprecated
per-operation overloads be collapsed into a single generic passthrough overload.
Behavior is unchanged: operationToHookOperation still maps these to the public
hook operation values, so beforeOperation hooks continue to receive 'read',
'readDistinct', 'delete', and 'update' as documented in the v4 migration guide.
The operationToHookOperation mapping and the 'read'/'readDistinct' union options
on BeforeOperationArg are intentionally left for a follow-up, since removing them
would change the public beforeOperation hook contract.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Pull Request titles must follow the Conventional Commits specification and have valid scopes. Unknown scope "payload" found in pull request title "refactor(payload): pass literal operation to buildBeforeOperation". Scope must match one of: cpa, claude, codemod, db-*, db-d1-sqlite, db-mongodb, db-postgres, db-vercel-postgres, db-sqlite, db-d1-sqlite, drizzle, email-*, email-nodemailer, email-resend, eslint, evals, graphql, kv, kv-redis, live-preview, live-preview-react, live-preview-vue, next, payload-cloud, plugin-cloud, plugin-cloud-storage, plugin-ecommerce, plugin-form-builder, plugin-import-export, plugin-mcp, plugin-multi-tenant, plugin-nested-docs, plugin-redirects, plugin-search, plugin-sentry, plugin-seo, plugin-stripe, richtext-*, richtext-lexical, sdk, skills, storage-*, storage-azure, storage-gcs, storage-r2, storage-vercel-blob, storage-s3, tanstack-start, translations, ui, templates, examples(/(\w|-)+)?, deps. |
📦 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.
|
|
The deferred breaking-change follow-up (removing the |
What / Why
Resolves the
buildBeforeOperation.tsTODO to "remove overloads and operations should be the literal operation that was called" — the non-controversial slice of the v4beforeOperationcleanup.The
find,findByID,findDistinct,deleteByID, andupdateByIDoperations now pass their literal operation name tobuildBeforeOperationinstead of coarse aliases ('read','readDistinct','delete','update'). With every caller now passing a literal op, the six deprecated per-operation overloads collapse into a single generic passthrough overload.Behavior is unchanged
operationToHookOperationstill maps the internal op to the public hook operation, so userbeforeOperationhooks continue to receive'read','readDistinct','delete', and'update'— matching the promise indocs/migration-guide/v4.mdx("Theoperation: 'read'value on thebeforeOperationhook is unchanged.") and the existing integration tests.Deferred follow-up
The remaining TODOs change what value
beforeOperationhooks receive (a breaking change) and are tracked, with a full checklist, in PYLD-2687.Verification
pnpm build:types(payloadtsc): 0 errorspnpm test:int hooks -t beforeOperation: 13 passed (hook still receives'read'/'readDistinct'/'delete'/'update')🤖 Generated with Claude Code