@logistically/events
Version:
A production-ready event-driven architecture library for NestJS with Redis Streams, comprehensive batching, reliable consumption, and enterprise-grade features.
33 lines (32 loc) • 1.15 kB
TypeScript
import { z } from 'zod';
export interface EventHeader {
id: string;
type: string;
origin: string;
timestamp: string;
hash: string;
version: string;
}
export interface EventEnvelope<T = any> {
header: EventHeader;
body: T;
}
export declare function generateEventId(): string;
export declare function generateEventHash(body: any): string;
export declare function createEventHeader(eventType: string, origin: string, body: any): EventHeader;
export declare function createEventEnvelope<T>(eventType: string, origin: string, body: T, namespace?: string): EventEnvelope<T>;
export interface EventValidator {
validate(eventType: string, body: any): ValidationResult;
getSchema(eventType: string): z.ZodSchema;
}
export interface ValidationResult {
valid: boolean;
error?: string;
}
export declare class DefaultEventValidator implements EventValidator {
private schemas;
constructor(schemas?: Record<string, z.ZodSchema>);
registerSchema(eventType: string, schema: z.ZodSchema): void;
getSchema(eventType: string): z.ZodSchema;
validate(eventType: string, body: any): ValidationResult;
}