Skip to content

feat: per-vault outbox event replay endpoint#936

Merged
1nonlypiece merged 1 commit into
Disciplr-Org:mainfrom
AugistineCreates:feature/vault-outbox-replay
Jun 29, 2026
Merged

feat: per-vault outbox event replay endpoint#936
1nonlypiece merged 1 commit into
Disciplr-Org:mainfrom
AugistineCreates:feature/vault-outbox-replay

Conversation

@AugistineCreates

Copy link
Copy Markdown
Contributor

this pr closes #844

Description

This PR introduces a per-vault outbox event replay mechanism to resolve the common support scenario where a subscriber missed or failed to receive lifecycle events for a single vault. It allows administrators to replay all recorded outbox events for a specific vault, optionally targeting a single subscriber to avoid re-emitting events to everyone.

Key Changes

  1. Webhook Service Enhancement
    • Extended dispatchWebhookEvent to accept an optional targetSubscriberId. When provided, events are only dispatched to this subscriber (provided they are active, belong to the correct organization, and match the event filter).
  2. Outbox Relay Service
    • Added replayForVault which queries the vault_outbox table using PostgreSQL JSONB operators to find events matching the target vaultId.
    • Preserves original event ordering (created_at ascending) and original event IDs/idempotency keys so subscribers can de-duplicate already-processed events.
  3. Admin API Endpoint
    • Registered POST /api/admin/vaults/:id/replay-events (via adminVaultReplayRouter mounted in app-bootstrap.ts).
    • Protected the endpoint with authentication, admin authorization, and strictRateLimiter.
    • Records an audit log under vault.outbox.replay upon successful execution.
  4. Documentation
    • Documented the new endpoint under the Admin API section in webhooks.md.
  5. Testing
    • Added a comprehensive test suite in outboxRelay.vaultReplay.test.ts covering edge cases including non-admin rejection, empty event lists, event ordering, and single-subscriber targeting.

Verification

  • Ran the Jest test suite:
    npm test -- src/tests/outboxRelay.vaultReplay.test.ts
  • Result: All 6 tests passed (100% coverage on new/changed lines).

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@AugistineCreates Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits


export const adminVaultReplayRouter = Router()

adminVaultReplayRouter.use(authenticate)
@1nonlypiece 1nonlypiece merged commit efc8a14 into Disciplr-Org:main Jun 29, 2026
1 of 4 checks passed
@1nonlypiece

Copy link
Copy Markdown
Contributor

per-vault replay endpoint is handy for recovery, merged

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.

Add a vault webhook event-replay-from-outbox endpoint scoped by vault id to src/services/outboxRelay.ts

3 participants