Add Webhook Delivery module
Parent: #172
Blocked by: #173
Goal
Add an internal API module that can create, persist and retrieve
WebhookDelivery records using the types introduced in #173
This establishes the persistence layer without changing existing webhook
dispatch behaviour.
Proposed solution
Create apps/api/src/modules/WebhookDelivery.ts containing a
WebhookDeliveryModule.
The module should initially support:
- Creating and persisting a
WebhookDelivery.
- Retrieving a
WebhookDelivery by ID.
- Returning
null when a delivery does not exist.
New deliveries should:
- Use a generated ID with the
whd_z prefix.
- Reference one Event and one Webhook Endpoint.
- Start with
pending status.
- Have
delivered_at and claim_until set to null.
- Have an empty
attempts array.
- Set
next_attempt_at so the initial attempt is eligible for processing.
Add WebhookDeliveries to the collections initialized by
Database.EnsureCollections().
Follow the structure and dependency-injection patterns used by existing API
modules.
Expected files
apps/api/src/modules/WebhookDelivery.ts
apps/api/src/__tests__/WebhookDelivery.spec.ts
apps/api/src/modules/Database.ts
Acceptance criteria
WebhookDeliveryModule can create and persist a delivery.
- Created deliveries use the
whd_z ID prefix.
- Created deliveries contain the expected initial values.
- The module can retrieve a persisted delivery by ID.
- Retrieving an unknown ID returns
null.
- The
WebhookDeliveries collection is initialized with other known
collections.
- Focused tests cover creation, retrieval and missing deliveries.
npx nx test api passes.
Non-goals
- Creating or recording delivery attempts
- Delivery state transitions
- Integration with
EventService or WebhookDispatcher
- Retry processing
- Scheduler routes
- Public API endpoints or request schemas
Add Webhook Delivery module
Parent: #172
Blocked by: #173
Goal
Add an internal API module that can create, persist and retrieve
WebhookDeliveryrecords using the types introduced in #173This establishes the persistence layer without changing existing webhook
dispatch behaviour.
Proposed solution
Create
apps/api/src/modules/WebhookDelivery.tscontaining aWebhookDeliveryModule.The module should initially support:
WebhookDelivery.WebhookDeliveryby ID.nullwhen a delivery does not exist.New deliveries should:
whd_zprefix.pendingstatus.delivered_atandclaim_untilset tonull.attemptsarray.next_attempt_atso the initial attempt is eligible for processing.Add
WebhookDeliveriesto the collections initialized byDatabase.EnsureCollections().Follow the structure and dependency-injection patterns used by existing API
modules.
Expected files
apps/api/src/modules/WebhookDelivery.tsapps/api/src/__tests__/WebhookDelivery.spec.tsapps/api/src/modules/Database.tsAcceptance criteria
WebhookDeliveryModulecan create and persist a delivery.whd_zID prefix.null.WebhookDeliveriescollection is initialized with other knowncollections.
npx nx test apipasses.Non-goals
EventServiceorWebhookDispatcher