Skip to content

feat(plugins): add content:afterPublish and content:afterUnpublish hooks - #367

Merged
ascorbic merged 6 commits into
emdash-cms:mainfrom
ttmx:feat/after-publish-unpublish-hooks
Apr 8, 2026
Merged

feat(plugins): add content:afterPublish and content:afterUnpublish hooks#367
ascorbic merged 6 commits into
emdash-cms:mainfrom
ttmx:feat/after-publish-unpublish-hooks

Conversation

@ttmx

@ttmx ttmx commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds two new plugin hooks — content:afterPublish and content:afterUnpublish — that fire after content is published or unpublished. Both are notification hooks requiring read:content capability, with support for trusted and sandboxed plugins.

Type of change

  • Bug fix
  • Feature (requires approved Discussion)
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm --silent lint:json | jq '.diagnostics | length' returns 0
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

All 41 hook pipeline tests pass (6 new), 0 lint diagnostics, build succeeds.

Adds two new plugin hooks that fire after content is published or
unpublished. Both require read:content capability and support trusted
and sandboxed plugins.

- ContentPublishEvent type with content record and collection
- HookPipeline methods, PluginManager delegates, runtime wiring
- Capability enforcement tests
- Hooks reference doc updated
Copilot AI review requested due to automatic review settings April 7, 2026 23:46
@changeset-bot

changeset-bot Bot commented Apr 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e31be29

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
emdash Minor
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-ai-moderation Major
@emdash-cms/plugin-atproto Patch
@emdash-cms/plugin-audit-log Patch
@emdash-cms/plugin-color Major
@emdash-cms/plugin-embeds Major
@emdash-cms/plugin-forms Major
@emdash-cms/plugin-webhook-notifier Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
✅ (ascorbic)[https://github.com/ascorbic]
❌ @tteles-cf
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@ttmx

ttmx commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds two new plugin notification hooks, content:afterPublish and content:afterUnpublish, intended to run after content is published/unpublished for both trusted and sandboxed plugins.

Changes:

  • Adds new hook handler types/events and registers the hook names in the core hook pipeline.
  • Triggers the new hooks from the runtime after publish/unpublish operations (trusted + sandboxed dispatch).
  • Updates plugin author docs and extends HookPipeline unit tests and adds a changeset.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
skills/creating-plugins/references/hooks.md Documents the two new hooks and updates the quick reference table.
packages/core/tests/unit/plugins/hooks.test.ts Adds unit tests for hook registration/capability gating in HookPipeline.
packages/core/src/plugins/types.ts Introduces the publish/unpublish hook event type and handler types; wires into PluginHooks typings.
packages/core/src/plugins/manager.ts Exposes PluginManager methods to run the new hooks.
packages/core/src/plugins/hooks.ts Registers the new hook names, adds capability requirements, and implements hook execution methods.
packages/core/src/emdash-runtime.ts Invokes the new hooks after publish/unpublish, including sandboxed plugin invocation.
.changeset/full-pugs-invent.md Declares a minor version bump and describes the new hooks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/plugins/hooks.ts
Comment thread packages/core/src/plugins/types.ts Outdated
Comment thread skills/creating-plugins/references/hooks.md
Comment thread skills/creating-plugins/references/hooks.md
Comment thread packages/core/src/emdash-runtime.ts
ttmx added 2 commits April 8, 2026 01:10
The event type is used for both publish and unpublish hooks, so the
name should reflect that it represents a state change, not just
publishing.
@ttmx

ttmx commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

recheck

@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@pkg-pr-new

pkg-pr-new Bot commented Apr 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@367

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@367

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@367

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@367

emdash

npm i https://pkg.pr.new/emdash@367

create-emdash

npm i https://pkg.pr.new/create-emdash@367

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@367

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@367

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@367

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@367

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@367

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@367

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@367

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@367

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@367

commit: e31be29

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is lookign great. Just one addition needed: can you update the docs in docs/src/content/docs/plugins/. You have most of the content already in the skills, but it should be in the docs too.

@ascorbic
ascorbic merged commit 8f44ec2 into emdash-cms:main Apr 8, 2026
23 of 25 checks passed
This was referenced Apr 8, 2026
fmhall pushed a commit to fmhall/emdash that referenced this pull request Apr 13, 2026
…oks (emdash-cms#367)

* feat(plugins): add content:afterPublish and content:afterUnpublish hooks

Adds two new plugin hooks that fire after content is published or
unpublished. Both require read:content capability and support trusted
and sandboxed plugins.

- ContentPublishEvent type with content record and collection
- HookPipeline methods, PluginManager delegates, runtime wiring
- Capability enforcement tests
- Hooks reference doc updated

* fix: rename ContentPublishEvent to ContentPublishStateChangeEvent

The event type is used for both publish and unpublish hooks, so the
name should reflect that it represents a state change, not just
publishing.

* fix: add afterPublish/afterUnpublish to manifest HOOK_NAMES and docs

* docs: add afterPublish/afterUnpublish hooks to public docs site

---------

Co-authored-by: Tiago Teles <tteles@cloudflare.com>
Co-authored-by: Matt Kane <mkane@cloudflare.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment