@glowlabs-org/events-sdk
Version:
Typed event SDK for Glow, powered by RabbitMQ and Zod.
65 lines (64 loc) • 3.06 kB
TypeScript
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 { AuditPfeesPaidV2AlphaPayload } from "./schemas/audit-pfees-paid.v2-alpha";
import type { ApplicationCreatedV1Payload } from "./schemas/application-created.v1";
import type { ApplicationCreatedV2AlphaPayload } from "./schemas/application-created.v2-alpha";
import type { ApplicationPriceQuoteV2AlphaPayload } from "./schemas/application-price-quote.v2-alpha";
import type { AuditPushedV2Payload } from "./schemas/audit-pushed.v2";
import type { AuditPushedV2AlphaPayload } from "./schemas/audit-pushed.v2-alpha";
import { eventTypes, EventType } from "./event-types";
import type { AuditorFeesPaidV2AlphaPayload } from "./schemas/auditor-fees-paid.v2-alpha";
import type { GctlMintedV2AlphaPayload } from "./schemas/gctl-minted.v2-alpha";
import type { FractionCreatedV2AlphaPayload } from "./schemas/fraction-created.v2-alpha";
import type { FractionSoldV2AlphaPayload } from "./schemas/fraction-sold.v2-alpha";
import type { FractionClosedV2AlphaPayload } from "./schemas/fraction-closed.v2-alpha";
import type { FractionRefundedV2AlphaPayload } from "./schemas/fraction-refunded.v2-alpha";
export { EventType, eventTypes };
export type EventVersion = "v1" | "v2" | "v2-alpha";
export interface EventPayloadMap {
[eventTypes.auditPushed]: {
v1: AuditPushedV1Payload;
v2: AuditPushedV2Payload;
"v2-alpha": AuditPushedV2AlphaPayload;
};
[eventTypes.auditSlashed]: {
v1: AuditSlashedV1Payload;
};
[eventTypes.auditPfeesPaid]: {
v1: AuditPfeesPaidV1Payload;
v2: AuditPfeesPaidV2Payload;
"v2-alpha": AuditPfeesPaidV2AlphaPayload;
};
[eventTypes.applicationCreated]: {
v1: ApplicationCreatedV1Payload;
"v2-alpha": ApplicationCreatedV2AlphaPayload;
};
[eventTypes.applicationPriceQuote]: {
"v2-alpha": ApplicationPriceQuoteV2AlphaPayload;
};
[eventTypes.gctlMinted]: {
"v2-alpha": GctlMintedV2AlphaPayload;
};
[eventTypes.auditorFeesPaid]: {
"v2-alpha": AuditorFeesPaidV2AlphaPayload;
};
[eventTypes.fractionCreated]: {
"v2-alpha": FractionCreatedV2AlphaPayload;
};
[eventTypes.fractionSold]: {
"v2-alpha": FractionSoldV2AlphaPayload;
};
[eventTypes.fractionClosed]: {
"v2-alpha": FractionClosedV2AlphaPayload;
};
[eventTypes.fractionRefunded]: {
"v2-alpha": FractionRefundedV2AlphaPayload;
};
}
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;
}