Skip to content

fix(api-website-builder): let page before-event handlers change what gets saved - #6001

Open
adrians5j wants to merge 6 commits into
release/6.5.0from
claude/page-before-events-persist
Open

adrians5j wants to merge 6 commits into
release/6.5.0from
claude/page-before-events-persist

Conversation

@adrians5j

@adrians5j adrians5j commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

What changed

Website Builder page "before" event handlers can now change the page that gets saved when a page is created, updated, published, or used to create a new revision. Before, changes made in page.beforePublish were dropped. page.beforeCreateRevisionFrom gave handlers nothing to change. In create and update, replacing the input object was ignored.

All four events now follow the same convention as CMS (EntryBefore* → entry) and File Manager (FileBefore* → file) events. page is the record that gets saved. original is the stored revision, and input is the request, where those exist. page starts as a copy, so editing it never changes original or input. Whatever page holds after the handlers run is what's saved. Authorization still runs first, and a handler that throws still stops the save.

Event Payload
page.beforeCreate { input, page }
page.beforeUpdate { original, input: { id, data }, page }. page is original with the update applied.
page.beforePublish { original, page }
page.beforeCreateRevisionFrom { params, original, page }

This changes the payload of all four events. Handlers that read event.payload.page on publish, or that changed input on create or update, have to switch to the new fields.

Supporting changes:

  • CMS publish values: the CMS PublishEntryUseCase accepts optional values, so the handler's page can be published. They go through the normal publish validation, and existing callers are unaffected.
  • Workflows handler: our own page.beforePublish handler in api-website-builder-workflows now reads original.
  • Tests: pages.beforeEvents.test.ts checks that a handler replacing page gets it saved, for all four events. It also checks that original is left alone, and that a handler that throws stops publish and create-revision-from.

Restore isn't covered. page.beforeRestore can't change the saved data yet.

Changelog

Title: Page event handlers can change the page before it is saved

Body: Changes that page event handlers made before publishing a page, or before creating a new revision of it, were not saved. They're now saved, and all page "before" events give handlers the page to change in the same way content entry and file events do.

Squash Merge Commit

fix(api-website-builder): let page before-events change the saved page (#6001)
fix: align page before-events with CMS and File Manager events (#6001)

Workspace: wby-next6 · 🧹 Forth - 6.5.0 Fixes

🤖 Generated with Claude Code

…h and page.beforeCreateRevisionFrom

Handlers for `page.beforePublish` received the page, but the publish only
passed the page id on, so the CMS published the stored revision. Replacing
a field on the page in a handler had no effect. `page.beforeCreateRevisionFrom`
did not receive the page at all.

`PublishPageUseCase` now publishes the page values the handlers left on the
event, through a new optional `values` option on the CMS
`PublishEntryUseCase`. The values go through the publish data factory, so
they are validated like stored values. `page.beforeCreateRevisionFrom` now
receives the source page, and the new revision is created with its values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added this to the 6.5.0 milestone Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 388eeeb8-f1dd-4dd6-aa84-54e680f5ad28

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…what handlers leave in input

`page.beforePublish` and `page.beforeCreateRevisionFrom` now carry
`{ original, input: { id, data } }`, like `page.beforeUpdate`. `original` is
the stored revision and `input.data` is what gets saved. `page.beforePublish`
keeps `page` as a deprecated alias of `original`, so existing handlers keep
working.

Create, update, publish and create-revision-from now save the input as it is
on the event after the handlers ran. A handler that replaces `input` or
`input.data` is no longer ignored. Before, only in-place edits reached the
write, because the use cases saved their own reference to the input.

The workflows `page.beforePublish` handler reads `original` instead of the
deprecated `page`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adrians5j adrians5j changed the title fix(api-website-builder): save page changes made in page.beforePublish and page.beforeCreateRevisionFrom fix(api-website-builder): let page before-event handlers change what gets saved Oct 15, 2026
The payload is now `{ original, input: { id, data } }`, the same as `page.beforeUpdate`. `original` is the stored revision; `page` duplicated it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adrians5j

Copy link
Copy Markdown
Member Author

/vitest

@adrians5j

Copy link
Copy Markdown
Member Author

/e2e

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Vitest tests have been initiated (for more information, click here). ✨

Group Status
No storage ✅ 49/49 passed
DDB ✅ 19/19 passed
DDB+OS ✅ 22/22 passed
SQL ❌ Failed
PGlite ❌ Failed

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

E2E tests have been initiated (for more information, click here). ✨

Database Status Admin URL
DDB ❌ Failed -
DDB+OS ❌ Failed -
Standalone (SQLite) ❌ Failed -
Standalone (Postgres) ❌ Failed -
Standalone (SQLite, WCP) ❌ Failed -
Standalone (Postgres, WCP) ❌ Failed -

adrians5j and others added 3 commits October 16, 2026 09:27
…Manager events

Every page before-event now carries `page`, the record that gets saved,
next to `original` (the stored revision) and `input` (the request) where
those exist. This matches `EntryBefore*` (`entry`) and `FileBefore*`
(`file`).

- `page.beforeCreate`: `{ input, page }`
- `page.beforeUpdate`: `{ original, input, page }`, where `page` is
  `original` with the update applied
- `page.beforePublish`: `{ original, page }`
- `page.beforeCreateRevisionFrom`: `{ params, original, page }`

`page` starts as a copy, so editing it never changes `original` or
`input`. Whatever `page` holds after the handlers run is what gets saved.
`IUpdateWbPageData` gains the optional `extensions` that create already
had.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…S events

Each use case now saves the `page` object it put on the event, so
handlers edit `page` in place. Assigning a new object to
`event.payload.page` is not picked up. This matches CMS (`entry`) and
File Manager (`file`) before-events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…before-events-persist

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant