@eang/core
Version:
eang - model driven enterprise event processing
149 lines (148 loc) • 5.66 kB
TypeScript
import { Obj, IObj } from './entity.js';
import { Prettify } from './types.js';
export type ObjOptions = Prettify<Omit<Partial<IObj>, 'typeOf' | 'entityType'>>;
export type InstanceObjOptions = Prettify<ObjOptions & {
instanceOf: string;
}>;
export declare class OrganizationObj extends Obj<'Organization'> {
readonly typeOf: "Organization";
constructor(opts: ObjOptions);
}
export declare class ItemObj extends Obj<'Item'> {
readonly typeOf: "Item";
constructor(opts: ObjOptions);
}
export declare class GroupObj extends Obj<'Group'> {
readonly typeOf: "Group";
constructor(opts: ObjOptions);
}
export declare class SystemObj extends Obj<'System'> {
readonly typeOf: "System";
constructor(opts: ObjOptions);
}
export declare class FolderObj extends Obj<'Folder'> {
readonly typeOf: "Folder";
constructor(opts: ObjOptions);
}
export declare class Security_PolicyObj extends Obj<'Security_Policy'> {
readonly typeOf: "Security_Policy";
constructor(opts: ObjOptions);
}
export declare class EventInstanceObj extends Obj<'Event_Instance'> {
readonly typeOf: "Event_Instance";
constructor(opts: InstanceObjOptions);
}
export type ErrorEventInstanceObjOptions = Prettify<InstanceObjOptions & {
message: string;
code?: string;
stack?: string;
cause?: Error;
severity?: 'error' | 'warning' | 'info' | 'critical';
}>;
export declare class ErrorEventInstanceObj extends Obj<'Error_Event_Instance'> {
readonly typeOf: "Error_Event_Instance";
message: string;
code?: string;
stack?: string;
cause?: Error;
severity: 'error' | 'warning' | 'info' | 'critical';
/** Error occurrence time is tracked via createdAt */
constructor(opts: ErrorEventInstanceObjOptions);
}
export type ProcessInstanceObjOptions = Prettify<InstanceObjOptions & {
startedAt?: number;
stoppedAt?: number;
}>;
export declare class ProcessInstanceObj extends Obj<'Process_Instance'> {
readonly typeOf: "Process_Instance";
startedAt?: number;
stoppedAt?: number;
constructor(opts: ProcessInstanceObjOptions);
}
type FunctionInstanceObjOptions = Prettify<InstanceObjOptions & {
startedAt?: number;
stoppedAt?: number;
}>;
export declare class FunctionInstanceObj extends Obj<'Function_Instance'> {
readonly typeOf: "Function_Instance";
startedAt?: number;
stoppedAt?: number;
constructor(opts: FunctionInstanceObjOptions);
}
type FunctionObjOptions = Prettify<ObjOptions & {
timeout?: number;
memoryLimit?: number;
env?: {
[key: string]: string;
};
secrets?: {
[key: string]: string;
};
}>;
export declare class FunctionObj extends Obj<'Function'> {
readonly typeOf: "Function";
/** Function timeout in milliseconds */
timeout?: number;
/** Memory limit in MB */
memoryLimit?: number;
/** Environment variables specific to this function */
env?: {
[key: string]: string;
};
/** Key-value pairs of secrets available to this object */
secrets?: {
[key: string]: string;
};
constructor(opts: FunctionObjOptions);
}
export type ServiceObjOptions = Prettify<ObjOptions & {
env?: {
[key: string]: string;
};
secrets?: {
[key: string]: string;
};
}>;
export declare class ServiceObj extends Obj<'Service'> {
readonly typeOf: "Service";
/** Service type (e.g., 'http', 'grpc', 'websocket') */
/** Service port */
/** Service host */
/** Service health check endpoint */
/** Service version */
/** Environment variables specific to this service */
env?: {
[key: string]: string;
};
/** Secrets available to this service */
secrets?: {
[key: string]: string;
};
/** Service scaling configuration */
/** Service deployment configuration */
constructor(opts: ServiceObjOptions);
}
export type AnyObj = ItemObj | EventInstanceObj | ErrorEventInstanceObj | ProcessInstanceObj | FunctionInstanceObj | FunctionObj | ServiceObj | GroupObj | SystemObj | FolderObj | Security_PolicyObj | OrganizationObj;
export type ObjByType<T extends AnyObj['typeOf']> = Extract<AnyObj, {
typeOf: T;
}>;
export declare function isOrganizationObj(obj: AnyObj): obj is OrganizationObj;
export declare function isItemObj(obj: AnyObj): obj is ItemObj;
export declare function isEventInstanceObj(obj: AnyObj): obj is EventInstanceObj;
export declare function isErrorEventInstanceObj(obj: AnyObj): obj is ErrorEventInstanceObj;
export declare function isProcessInstanceObj(obj: AnyObj): obj is ProcessInstanceObj;
export declare function isFunctionInstanceObj(obj: AnyObj): obj is FunctionInstanceObj;
export declare function isFunctionObj(obj: AnyObj): obj is FunctionObj;
export declare function isServiceObj(obj: AnyObj): obj is ServiceObj;
export declare function isGroupObj(obj: AnyObj): obj is GroupObj;
export declare function isSystemObj(obj: AnyObj): obj is SystemObj;
export declare function isFolderObj(obj: AnyObj): obj is FolderObj;
export declare function isSecurityPolicyObj(obj: AnyObj): obj is Security_PolicyObj;
export declare function isObjOfType<T extends AnyObj['typeOf']>(obj: AnyObj, typeOf: T): obj is ObjByType<T>;
export declare const typeOfToClassMap: Record<AnyObj['typeOf'], new (data: any) => AnyObj>;
export declare function registerTypeOfClass<T extends string>(typeOf: T, cls: new (data: any) => Obj<T>): void;
export declare function createObjFromTypeOf<T extends AnyObj['typeOf']>(data: any, typeOf: T): ObjByType<T>;
export declare function createObjFromTypeOf(data: any & {
typeOf: AnyObj['typeOf'];
}): AnyObj;
export {};