Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Webhooks>;

type ExtractedWebhooks = ExtractJsonRequestBodies<Webhooks>;
export type WebhookPayloadSchemas = {
[EventType in WebhooksComponents["schemas"]["WebhookEventType"]]: EventType extends keyof Required<ExtractedWebhooks>
? Omit<NonNullable<ExtractedWebhooks[EventType]>, "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<string, unknown>;
};
}[WebhooksComponents["schemas"]["WebhookEventType"]];

export { createManagementClient, createStorefrontClient, isPayNowError };