UNPKG

@eang/core

Version:

eang - model driven enterprise event processing

59 lines (58 loc) 1.9 kB
import { EntityEvent, IEntity } from './entity.js'; import { ErrorEventInstanceObj, EventInstanceObj } from './objects.js'; import { Prettify } from './types.js'; export interface FieldDiff { field: string; oldValue: any; newValue: any; } export declare class EntityUpdateContext { diff: FieldDiff[]; constructor(data: any); static create(oldEntity: IEntity, newData: Record<string, any>): EntityUpdateContext; private static createDiff; /** * Apply the update context to an entity by updating its fields with the new values * @param entity - The entity to apply the updates to */ applyDiffTo(entity: IEntity): void; } export type IFunctionStartContext = Prettify<{ rootObjectId?: string; entities?: IEntity[]; data?: Record<string, unknown>; inIds?: string[]; outIds?: string[]; }>; export declare class FunctionStartContext implements IFunctionStartContext { rootObjectId?: string; entities?: IEntity[]; data?: Record<string, unknown>; inIds?: string[]; outIds?: string[]; functionInputMapping?: { [key: string]: string[]; }; inEventInstances: EventInstanceObj[]; constructor(contextOpts: IFunctionStartContext); /** * Gets the root object that owns this context * @returns The root object or undefined if not found */ getRootObject(): IEntity | undefined; } export interface IFunctionStopContext<T extends object = any> { data?: T; err?: Error; entityEvents?: EntityEvent[]; events?: EventInstanceObj[]; errEvents?: ErrorEventInstanceObj[]; } export declare class FunctionStopContext<T extends object = any> implements IFunctionStopContext<T> { data?: T; err?: Error; entityEvents?: EntityEvent[]; events?: EventInstanceObj[]; errEvents?: ErrorEventInstanceObj[]; constructor(contextOpts?: IFunctionStopContext<T>); }