Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit cec70a7

Browse files
authored
fix: Flatten webhook types (#219)
1 parent 04099ff commit cec70a7

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

docs/modules.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/types/webhook-events.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { SeamEvent } from "seamapi-types"
33
type Distribute<EventType> = EventType extends SeamEvent["event_type"]
44
? {
55
event_type: EventType
6-
data: Extract<SeamEvent, { event_type: EventType }>["payload"]
7-
}
6+
} & Extract<SeamEvent, { event_type: EventType }>["payload"]
87
: never
98

109
export type SeamWebhookEvent = Distribute<SeamEvent["event_type"]>

tests/webhooks.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ test.skip("webhook payload is correctly verified", async (t) => {
3939
)
4040

4141
t.is(callback.event_type, "access_code.created")
42-
t.is((callback.data as any).device_id, seed.devices.augustLock.id1)
42+
t.is((callback as any).device_id, seed.devices.augustLock.id1)
4343
// Check types
4444
t.true(
4545
callback.event_type === "access_code.created" &&
46-
typeof callback.data.access_code_id === "string"
46+
typeof callback.access_code_id === "string"
4747
)
4848
})

0 commit comments

Comments
 (0)