Skip to content

Commit

Permalink
Add reference docs for helper types in TS SDK v3.3.0 (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwilliams authored Oct 19, 2023
1 parent 935a18f commit 72a7fca
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pages/docs/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,48 @@ export default inngest.createFunction(
);
```
</CodeGroup>

## Helpers

The TS SDK exports some helper types to allow you to access the type of particular Inngest internals outside of an Inngest function.

### GetEvents <VersionBadge version="v2.0.0+" />

Get a record of all available events given an Inngest client.

It's recommended to use this instead of directly reusing your own event types, as Inngest will add extra properties and internal events such as `ts` and `inngest/function.failed`.

```ts
import { type GetEvents } from "inngest";
import { inngest } from "@/inngest";

type Events = GetEvents<typeof inngest>;
```

### GetFunctionInput <VersionBadge version="v3.3.0+" />

Get the argument passed to Inngest functions given an Inngest client and, optionally, an event trigger.

Useful for building function factories or other such abstractions.

```ts
import { type GetFunctionInput } from "inngest";
import { inngest } from "@/inngest";

type InputArg = GetFunctionInput<typeof inngest>;
type InputArgWithTrigger = GetFunctionInput<typeof inngest, "app/user.created">;
```

### GetStepTools <VersionBadge version="v3.3.0+" />

Get the `step` object passed to an Inngest function given an Inngest client and, optionally, an event trigger.

Is a small shim over the top of `GetFunctionInput<...>["step"]`.

```ts
import { type GetStepTools } from "inngest";
import { inngest } from "@/inngest";

type StepTools = GetStepTools<typeof inngest>;
type StepToolsWithTrigger = GetStepTools<typeof inngest, "app/user.created">;
```

1 comment on commit 72a7fca

@vercel
Copy link

@vercel vercel bot commented on 72a7fca Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

website – ./

inngest.vercel.app
website-git-main-inngest.vercel.app
website-inngest.vercel.app
www.inngest.com

Please sign in to comment.