UNPKG

@c11/engine.types

Version:

Typescript types for everything engine related

55 lines (54 loc) 1.71 kB
import { GetValue, UpdateValue } from "."; import { OperationTypes } from "./producer"; export declare enum EventNames { ENGINE_STARTED = "ENGINE_STARTED", ENGINE_STOPPED = "ENGINE_STOPPED", MODULE_MOUNTED = "MODULE_MOUNTED", MODULE_UNMOUNTED = "MODULE_UNMOUNTED", VIEW_MOUNTED = "VIEW_MOUNTED", VIEW_UNMOUNTED = "VIEW_UNMOUNTED", VIEW_CALLED = "VIEW_CALLED", PRODUCER_MOUNTED = "PRODUCER_MOUNTED", PRODUCER_UNMOUNTED = "PRODUCER_UNMOUNTED", PRODUCER_CALLED = "PRODUCER_CALLED", STATE_UPDATED = "STATE_UPDATED", PATCH_APPLIED = "PATCH_APPLIED", ERROR = "ERROR" } export declare type EmitFn = (eventName: EventNames, payload?: {}, context?: {}) => void; export declare type EngineEventContext = { engineId: string; }; export declare type ModuleEventContext = { moduleId: string; moduleName: string; }; export declare type ViewEventContext = { viewId: string; viewInstanceId: string; }; export declare type ProducerEventContext = { producerId: string; producerInstanceId: string; }; export declare type OperationEventContext = { operationId: string; operationType: OperationTypes; operationFnName?: keyof UpdateValue | keyof GetValue; }; export declare type EventContext = Partial<EngineEventContext & ModuleEventContext & ViewEventContext & ProducerEventContext & OperationEventContext>; export declare type Event<Name = EventNames> = { eventName: Name; eventId: string; createdAt: number; context: EventContext; payload: any; }; export declare type EventPayload = { sourceId?: string; parentId?: string; [k: string]: any; }; export declare type Events = { [k in EventNames]: Event; };