@eang/core
Version:
eang - model driven enterprise event processing
81 lines (80 loc) • 2.86 kB
TypeScript
import { EntityEvent, IEntity } from './entity.js';
import type { DiagramPatchOperation } from './diagram.js';
import { ErrorEventInstanceObj, EventInstanceObj } from './objects.js';
import { Prettify } from './types.js';
export interface FieldDiff {
field: string;
oldValue: any;
newValue: any;
}
export interface UpdateMeta {
editorId?: string;
[key: string]: unknown;
}
export declare class EntityUpdateContext {
diff: FieldDiff[];
meta?: UpdateMeta;
constructor(data: any);
static create(oldEntity: IEntity, newData: Record<string, any>, meta?: UpdateMeta): 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 interface DiagramUpdateMeta extends UpdateMeta {
interaction?: 'drag' | 'resize' | 'connect' | 'label-edit' | 'viewport';
}
export interface IDiagramUpdateContext {
kind: 'diagram';
patch: DiagramPatchOperation[];
meta?: DiagramUpdateMeta;
}
export declare class DiagramUpdateContext extends EntityUpdateContext implements IDiagramUpdateContext {
readonly kind: "diagram";
patch: DiagramPatchOperation[];
constructor(data?: DiagramPatchOperation[] | IDiagramUpdateContext);
static fromPatch(patch: DiagramPatchOperation[], meta?: DiagramUpdateMeta): DiagramUpdateContext;
applyDiffTo(entity: IEntity): void;
}
export declare function isDiagramUpdateContext(context: unknown): context is DiagramUpdateContext | IDiagramUpdateContext;
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>);
}