-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
150 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
"sst": minor | ||
--- | ||
|
||
There is a slight breaking change in this release if you are using SST Events with `createEventBuilder()` - you should receive type errors for all the issues. We now support specifying any validation library so will need to configure that. | ||
|
||
To continue using Zod you can specify the validator like so | ||
|
||
``` | ||
import { createEventBuilder, ZodValidator } from "sst/node/event-bus" | ||
const event = createEventBuilder({ | ||
bus: "MyBus", | ||
validator: ZodValidator | ||
}) | ||
``` | ||
|
||
Additionally we no longer assume you are passing in a zod object as the schema. | ||
You'll have to update code from: | ||
|
||
``` | ||
const MyEvent = event("my.event", { | ||
foo: z.string(), | ||
}) | ||
``` | ||
|
||
to this: | ||
|
||
``` | ||
const MyEvent = event("my.event", z.object({ | ||
foo: z.string(), | ||
})) | ||
``` | ||
|
||
This also allows you to specify non-objects as the event properties. Additionally, if you were using advanced inference the `shape` field has been replaced with `typeof MyEvent.$input`, `typeof MyEvent.$output`, and `typeof MyEvent.$metadata` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { createEventBuilder } from "sst/node/event-bus"; | ||
import { createEventBuilder, ZodValidator } from "sst/node/event-bus"; | ||
|
||
export const event = createEventBuilder({ | ||
bus: "bus", | ||
validator: ZodValidator, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { createEventBuilder } from "sst/node/event-bus"; | ||
import { createEventBuilder, ZodValidator } from "sst/node/event-bus"; | ||
|
||
export const event = createEventBuilder({ | ||
bus: "bus", | ||
validator: ZodValidator, | ||
}); |
3 changes: 2 additions & 1 deletion
3
packages/create-sst/bin/presets/standard/api/templates/packages/core/src/event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { createEventBuilder } from "sst/node/event-bus"; | ||
import { createEventBuilder, ZodValidator } from "sst/node/event-bus"; | ||
|
||
export const event = createEventBuilder({ | ||
bus: "bus", | ||
validator: ZodValidator, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters