sea-of-amoebas
Version:
A declarative and event-driven execution framework for building scalable, asynchronous flow systems.
41 lines (38 loc) • 1.4 kB
TypeScript
//index.d.ts
// Constantes
export const SEA_READY_EVENT: string;
export const EXECUTED_EVENT_SUFFIX: string;
export const ERROR_EVENT_SUFFIX: string;
// API principal
export class AmoebaSea {
constructor(options?: { eventEmitter?: any; storeResults?: boolean; verbose?: boolean });
amoebas: Record<string, any>;
addAmoeba(def: AmoebaDefinition): void;
finalizeConfiguration(): void;
setInput(eventName: string, data?: any): void;
waitForOutputEvent(eventName: string): Promise<any>;
waitForAmoebaExecution(id: string): Promise<any>;
waitForAmoebaError(id: string): Promise<any>;
stopAll(): void;
}
export type AmoebaDefinition = {
id: string;
func: Function | string;
inputEvents?: string[];
outputEvents?: (string | {
condition: string | Function;
then: Array<string | { event: string; reflexive?: boolean }>;
else?: Array<string | { event: string; reflexive?: boolean }>;
})[];
stickyInputs?: boolean;
triggerMode?: boolean;
storeResults?: boolean;
verbose?: boolean;
};
// Parser
export class AmoebaFlowParser {
static fromObject(obj: any, isTrustedSource?: boolean): AmoebaSea;
static fromJSON(json: string | object, isTrustedSource?: boolean): AmoebaSea;
static fromYAML(yaml: string, isTrustedSource?: boolean): AmoebaSea;
static fromYaml(yaml: string, isTrustedSource?: boolean): AmoebaSea;
}