inngest / inngest-js

The developer platform for easily building reliable workflows with zero infrastructure for TypeScript & JavaScript
https://www.inngest.com/
GNU General Public License v3.0
440 stars 43 forks source link

Run `onSendEvent` middleware hooks for `step.invoke()` payloads #503

Closed jpwilliams closed 8 months ago

jpwilliams commented 8 months ago

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 via step.invoke(), an internal inngest/function.invoked event is sent, though the onSendEvent.transformInput() hook is not currently run.

For middleware like @inngest/middleware-encryption, this poses a challenge, as it can no longer encrypt fields when using step.invoke() instead of step.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:

Checklist

changeset-bot[bot] commented 8 months ago

🦋 Changeset detected

Latest commit: 507a51a358881339e7d05a1221ac13b117f08a2b

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

This PR includes changesets to release 1 package | Name | Type | | ------- | ----- | | inngest | 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](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)

inngest-release-bot commented 8 months ago

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.