diff --git a/src/index.ts b/src/index.ts index 065d43d..51e06a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,10 +6,31 @@ import { createStorefrontClient } from "./storefront"; import type { components as ManagementComponents } from "./generated/management"; import type { components as StorefrontComponents } from "./generated/storefront"; -import type { webhooks as Webhooks } from "./generated/webhooks"; +import type { + webhooks as Webhooks, + components as WebhooksComponents, +} from "./generated/webhooks"; export type ManagementSchemas = ManagementComponents["schemas"]; export type StorefrontSchemas = StorefrontComponents["schemas"]; -export type WebhookPayloadSchemas = ExtractJsonRequestBodies; + +type ExtractedWebhooks = ExtractJsonRequestBodies; +export type WebhookPayloadSchemas = { + [EventType in WebhooksComponents["schemas"]["WebhookEventType"]]: EventType extends keyof Required + ? Omit, "event_type" | "event_id"> & { + event_type: EventType; + /** + * Format: flake-id + * @description The ID of the Webhook Event + * @example 411486491630370816 + */ + event_id: string; + } + : { + event_type: EventType; + event_id: string; + body: Record; + }; +}[WebhooksComponents["schemas"]["WebhookEventType"]]; export { createManagementClient, createStorefrontClient, isPayNowError };