UNPKG

@glowlabs-org/events-sdk

Version:

Typed event SDK for Glow, powered by RabbitMQ and Zod.

31 lines (30 loc) 1.35 kB
import type { BaseEvent } from "./base-event"; import type { AuditPushedV1Payload } from "./schemas/audit-pushed.v1"; import type { AuditSlashedV1Payload } from "./schemas/audit-slashed.v1"; import type { AuditPfeesPaidV1Payload } from "./schemas/audit-pfees-paid.v1"; import type { AuditPfeesPaidV2Payload } from "./schemas/audit-pfees-paid.v2"; import type { ApplicationCreatedV1Payload } from "./schemas/application-created.v1"; import type { AuditPushedV2Payload } from "./schemas/audit-pushed.v2"; import { eventTypes, EventType } from "./event-types"; export { EventType, eventTypes }; export type EventVersion = "v1" | "v2"; export interface EventPayloadMap { [eventTypes.auditPushed]: { v1: AuditPushedV1Payload; v2: AuditPushedV2Payload; }; [eventTypes.auditSlashed]: { v1: AuditSlashedV1Payload; }; [eventTypes.auditPfeesPaid]: { v1: AuditPfeesPaidV1Payload; v2: AuditPfeesPaidV2Payload; }; [eventTypes.applicationCreated]: { v1: ApplicationCreatedV1Payload; }; } export type EventPayload<T extends EventType, V extends keyof EventPayloadMap[T]> = T extends keyof EventPayloadMap ? V extends keyof EventPayloadMap[T] ? EventPayloadMap[T][V] : never : never; export interface GlowEvent<TPayload> extends Omit<BaseEvent, "payload"> { payload: TPayload; }