Closed jpwilliams closed 8 months ago
Latest commit: 507a51a358881339e7d05a1221ac13b117f08a2b
The changes in this PR will be included in the next version bump.
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](https://github.com/inngest/inngest-js/new/feat/middleware-invoke-send-event-hook?filename=.changeset/smart-glasses-type.md&value=---%0A%22inngest%22%3A%20patch%0A---%0A%0ARun%20%60onSendEvent%60%20middleware%20hooks%20for%20%60step.invoke()%60%20payloads%0A)
A user has added the prerelease/inngest label, so this PR will be published to npm with the tag pr-503
. It will be updated with the latest changes as you push commits to this PR.
You can install this prerelease version with:
npm install inngest@pr-503
The last release was built and published from 507a51a358881339e7d05a1221ac13b117f08a2b.
Summary
The
onSendEvent.transformInput()
middleware hook is used to intercept events being sent and change either the shape or number of events being sent. When invoking a function viastep.invoke()
, an internalinngest/function.invoked
event is sent, though theonSendEvent.transformInput()
hook is not currently run.For middleware like
@inngest/middleware-encryption
, this poses a challenge, as it can no longer encrypt fields when usingstep.invoke()
instead ofstep.sendEvent()
.This PR ensures that the hook is also used for events being sent via
step.invoke()
, such that middleware can now appropriately affect the payloads.Some notes on design decisions here:
onSendEvent
hook will be run for each individualstep.invoke()
. This is the same functionality as callingstep.sendEvent()
multiple times. While thetransformInput()
hook supports batchedpayloads
, this makes it difficult to determine which payloads have been affected if a user has omitted some from the returned array.step.sendEvent()
orinngest.send()
, we do not allow a developer to omit the event to be sent bystep.invoke()
Checklist