@eang/core
Version:
eang - model driven enterprise event processing
163 lines (162 loc) • 6.09 kB
TypeScript
import { Obj, IObj } from './entity.js';
export interface ObjOptions extends Omit<Partial<IObj>, 'typeOf' | 'entityType'> {
[key: string]: unknown;
}
export interface InstanceObjOptions extends ObjOptions {
instanceOf: string;
}
export declare class OrganizationObj extends Obj<'Organization'> {
readonly typeOf: "Organization";
constructor(opts: ObjOptions);
}
export declare function isOrganizationObj(obj: AnyObj): obj is OrganizationObj;
export declare class ItemObj extends Obj<'Item'> {
readonly typeOf: "Item";
constructor(opts: ObjOptions);
}
export declare function isItemObj(obj: AnyObj): obj is ItemObj;
export declare class GroupObj extends Obj<'Group'> {
readonly typeOf: "Group";
constructor(opts: ObjOptions);
}
export declare function isGroupObj(obj: AnyObj): obj is GroupObj;
export declare class SystemObj extends Obj<'System'> {
readonly typeOf: "System";
constructor(opts: ObjOptions);
}
export declare function isSystemObj(obj: AnyObj): obj is SystemObj;
export declare class FolderObj extends Obj<'Folder'> {
readonly typeOf: "Folder";
constructor(opts: ObjOptions);
}
export declare function isFolderObj(obj: AnyObj): obj is FolderObj;
export declare class Security_PolicyObj extends Obj<'Security_Policy'> {
readonly typeOf: "Security_Policy";
constructor(opts: ObjOptions);
}
export declare function isSecurityPolicyObj(obj: AnyObj): obj is Security_PolicyObj;
export interface PersonObjOptions extends ObjOptions {
username: string;
}
export declare class PersonObj extends Obj<'Person'> {
readonly typeOf: "Person";
username: string;
constructor(opts: PersonObjOptions);
}
export declare function isPersonObj(obj: AnyObj): obj is PersonObj;
export declare class EventInstanceObj extends Obj<'Event_Instance'> {
readonly typeOf: "Event_Instance";
constructor(opts: InstanceObjOptions);
}
export declare function isEventInstanceObj(obj: AnyObj): obj is EventInstanceObj;
export interface ErrorEventInstanceObjOptions extends 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 declare function isErrorEventInstanceObj(obj: AnyObj): obj is ErrorEventInstanceObj;
export interface ProcessInstanceObjOptions extends InstanceObjOptions {
startedAt?: number;
stoppedAt?: number;
}
export declare class ProcessInstanceObj extends Obj<'Process_Instance'> {
readonly typeOf: "Process_Instance";
startedAt?: number;
stoppedAt?: number;
constructor(opts: ProcessInstanceObjOptions);
}
export declare function isProcessInstanceObj(obj: AnyObj): obj is ProcessInstanceObj;
export interface FunctionInstanceObjOptions extends InstanceObjOptions {
startedAt?: number;
stoppedAt?: number;
}
export declare class FunctionInstanceObj extends Obj<'Function_Instance'> {
readonly typeOf: "Function_Instance";
startedAt: number;
stoppedAt?: number;
constructor(opts: FunctionInstanceObjOptions);
}
export declare function isFunctionInstanceObj(obj: AnyObj): obj is FunctionInstanceObj;
export interface FunctionObjOptions extends 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 declare function isFunctionObj(obj: AnyObj): obj is FunctionObj;
export interface ServiceObjOptions extends 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 declare function isServiceObj(obj: AnyObj): obj is ServiceObj;
export type AnyObj = ItemObj | PersonObj | EventInstanceObj | ErrorEventInstanceObj | ProcessInstanceObj | FunctionInstanceObj | FunctionObj | ServiceObj | GroupObj | SystemObj | FolderObj | Security_PolicyObj | OrganizationObj | PersonObj;
export declare function isObjOfType<T extends AnyObj['typeOf']>(obj: AnyObj, typeOf: T): obj is Extract<AnyObj, {
typeOf: T;
}>;
type AnyConstructor = new (data: Record<string, unknown>) => AnyObj;
export declare const typeOfToClassMap: Record<AnyObj['typeOf'], AnyConstructor>;
export declare function registerTypeOfClass<T extends string>(typeOf: T, cls: new (data: Record<string, unknown>) => Obj<T>): void;
export declare function createObj(data: Record<string, unknown> & {
id: string;
}): IObj;
export declare function createObj(data: Record<string, unknown> & {
key: string;
typeOf: string;
}): IObj;
export declare function createObj(data: Record<string, unknown>, typeOf: string, key: string): IObj;
export {};