UNPKG

@eang/core

Version:

eang - model driven enterprise event processing

116 lines (115 loc) 3.47 kB
import { IFunctionStartContext, IFunctionStopContext } from './context.js'; import { FunctionInstanceObj, ProcessInstanceObj } from './objects.js'; import { Prettify } from './types.js'; export interface IEntity { entityType: 'obj' | 'cnx'; id: string; key: string; typeOf: string; name?: string; instanceOf?: string; data?: Record<string, unknown>; tags: { [key: string]: string; }; attributes: { [key: string]: string | number | boolean | object; }; createdBy?: string; createdAt: number; updatedBy?: string; updatedAt?: number; } export interface IObj extends IEntity { entityType: 'obj'; } export interface ICnx extends IEntity { entityType: 'cnx'; fromObjId: string; fromObjKey: string; fromObjTypeOf: string; fromObjInstanceOf?: string; toObjId: string; toObjKey: string; toObjTypeOf: string; toObjInstanceOf?: string; } declare abstract class Entity implements IEntity { abstract readonly entityType: 'obj' | 'cnx'; readonly id: string; readonly key: string; readonly typeOf: string; instanceOf?: string; name?: string; data?: Record<string, unknown>; tags: { [key: string]: string; }; attributes: { [key: string]: string | number | boolean | object; }; createdBy?: string; createdAt: number; updatedBy?: string; updatedAt?: number; constructor(entityOpts: Prettify<Partial<IEntity> & { id: string; key: string; typeOf: string; }>); } export declare abstract class Obj<T extends string = string> extends Entity implements IObj { readonly entityType: "obj"; abstract readonly typeOf: T; constructor(objOpts: Prettify<Partial<IObj> & { typeOf: T; }>); } export declare class Cnx extends Entity implements ICnx { readonly entityType = "cnx"; readonly typeOf: string; fromObjId: string; fromObjKey: string; fromObjTypeOf: string; fromObjInstanceOf?: string; toObjId: string; toObjKey: string; toObjTypeOf: string; toObjInstanceOf?: string; constructor(cnxOpts: Prettify<(Partial<ICnx> & { id: string; }) | (Partial<ICnx> & { typeOf: string; })>); } export type EangEventTypes = (typeof EangEventType)[keyof typeof EangEventType]; export declare const EangEventType: { readonly create: "create"; readonly update: "update"; readonly delete: "delete"; readonly start: "start"; readonly stop: "stop"; }; export interface EntityEventOptions { tenant: string; organizationalUnit: string; user: string; } export declare class EntityEvent { entity: Obj | Cnx; eventType: EangEventTypes; context?: any; tenant?: string; organizationalUnit?: string; user?: string; private constructor(); static parse(entity: Obj | Cnx, eventType: EangEventTypes, context?: any, options?: EntityEventOptions): EntityEvent; static create<T extends IObj | ICnx>(entity: T, options?: EntityEventOptions): EntityEvent; static start(entity: FunctionInstanceObj | ProcessInstanceObj, context?: IFunctionStartContext, options?: EntityEventOptions): EntityEvent; static stop(entity: ProcessInstanceObj | FunctionInstanceObj, context?: IFunctionStopContext, options?: EntityEventOptions): EntityEvent; } export declare function parseCombinedId(id: string): { typeOf: string; key: string; }; export {};