/** * Event materialization helpers. * * These functions convert a flat list of workflow events into entity-like * objects (steps, hooks, waits) by grouping events by correlationId and * stitching together lifecycle events. * * This enables a "top-down" data fetching pattern where the client fetches * all events for a run once, then materializes entities client-side instead * of making separate API calls for each entity type. */ import type { Event, StepStatus } from '@workflow/world'; export interface MaterializedStep { stepId: string; runId: string; stepName: string; status: StepStatus; attempt: number; createdAt: Date; occurredAt?: Date; startedAt?: Date; completedAt?: Date; updatedAt: Date; /** All events for this step, in insertion order */ events: Event[]; } export interface MaterializedHook { hookId: string; runId: string; token?: string; createdAt: Date; occurredAt?: Date; receivedCount: number; lastReceivedAt?: Date; disposedAt?: Date; /** All events for this hook, in insertion order */ events: Event[]; } export interface MaterializedWait { waitId: string; runId: string; status: 'waiting' | 'completed'; createdAt: Date; occurredAt?: Date; resumeAt?: Date; completedAt?: Date; /** All events for this wait, in insertion order */ events: Event[]; } export interface MaterializedEntities { steps: MaterializedStep[]; hooks: MaterializedHook[]; waits: MaterializedWait[]; } /** * Group step_* events by correlationId and build Step-like entities. * * Handles partial event lists gracefully: a step may only have a * step_created event with no completion yet. */ export declare function materializeSteps(events: Event[]): MaterializedStep[]; /** * Group hook_* events by correlationId and build Hook-like entities. */ export declare function materializeHooks(events: Event[]): MaterializedHook[]; /** * Group wait_* events by correlationId and build Wait-like entities. */ export declare function materializeWaits(events: Event[]): MaterializedWait[]; /** * Convenience function that materializes all entity types from a flat * event list. */ export declare function materializeAll(events: Event[]): MaterializedEntities; //# sourceMappingURL=event-materialization.d.ts.map