feat: Webhooks#28
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class outbound webhooks for “new version created” events, including persistence for deliveries, background retry/purge jobs, management API endpoints, and a collection settings UI to configure endpoints and inspect delivery logs.
Changes:
- Introduces
collection_webhooks+webhook_deliveriestables (migration0006) and background jobs for retry + 30‑day retention purging (in-process + cron tool). - Adds webhook delivery pipeline with HMAC signing, SSRF checks, retries with exponential backoff, and manual retry/test endpoints.
- Adds collection settings UI section and loader wiring to create/manage webhooks and view delivery logs.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/pruneWebhookLogs.ts | Adds cron-invoked tool to purge old webhook delivery logs. |
| tools/cron.ts | Schedules daily webhook log pruning in production cron container. |
| src/routes/[owner]/[collection]/settings.tsx | Renders new Webhooks settings section in collection settings UI. |
| src/routes/[owner]/[collection]/settings.data.ts | Loads initial webhooks list for settings page. |
| src/lib/webhooks.server.ts | Implements webhook enqueueing, delivery, retry sweep, and purge jobs + SSRF/signing utilities. |
| src/lib/webhooks.server.test.ts | Adds unit tests for signing, IP blocking, and URL validation helpers. |
| src/db/schema.ts | Defines collection_webhooks and webhook_deliveries tables and indexes in Drizzle schema. |
| src/db/migrations/0006_moaning_mauler.sql | Creates webhook tables + indexes and foreign keys. |
| src/db/migrations/meta/0006_snapshot.json | Drizzle migration snapshot update for schema version 7. |
| src/db/migrations/meta/_journal.json | Registers migration 0006. |
| src/components/WebhooksSettings.tsx | Adds UI for CRUD, test sends, delivery logs, and retries. |
| src/api/webhooks.ts | Adds authenticated/authorized webhook CRUD + deliveries/test/retry API. |
| src/api/versions.ts | Fires webhooks when metadata patch creates a new version. |
| src/api/negotiate.ts | Fires webhooks when a negotiated version is committed. |
| server.ts | Mounts webhooks API routes and starts in-process webhook background jobs. |
| package.json | Adds tool:pruneWebhookLogs script for cron/tooling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds outbound webhooks that fire when a new version is created, so downstream consumers can react to changes instead of polling.
What's included
collection_webhooks(bumpFilter text[], secret, enabled) andwebhook_deliveries(status/attempts/response/timing) with indexes for the retry sweep and 30-day purge. Migration0006.readypoint innegotiate.tsand the metadata-patch path inversions.ts; filtered by bump type (major/minor/patch). Never blocks the 201.src/lib/webhooks.server.ts) — HMAC-SHA256 signing (X-Underlay-Signature), SSRF guard (blocks localhost/private/link-local incl. cloud-metadata IP, DNS-resolved at delivery), 10s timeout, retry with backoff.tools/pruneWebhookLogs.tscron./api/collections/:owner/:slug/webhooks+/deliveries,/test, and retry; gatedrequireAuth('write')+ owner/admin + API-key scope. Secret returned once on create.