temporal-forge
Version:
A comprehensive framework for building resilient Temporal workflows, advanced state management, and real-time streaming activities in TypeScript. Designed for a seamless developer experience with powerful abstractions, dynamic orchestration, and full cont
63 lines (62 loc) • 1.98 kB
TypeScript
import { DirectedGraph } from 'eventemitter3-graphology';
import { StepMetadata } from '../decorators/Step';
export type DSLDefinition = {
variables: Record<string, unknown>;
plan: Statement;
};
export type Statement = {
condition?: (dsl: DSLDefinition) => Promise<boolean>;
retries?: number;
timeout?: number;
required?: boolean;
} & ({
sequence: Sequence;
} | {
parallel: Parallel;
} | {
execute: Execute;
});
export type Sequence = {
elements: Statement[];
};
export type Parallel = {
branches: Statement[];
};
export type Execute = {
code?: string;
step?: StepInvocation;
activity?: ActivityInvocation;
workflow?: WorkflowInvocation;
};
export type ActivityInvocation = {
name: string;
arguments?: string[];
result?: string;
};
export type WorkflowInvocation = {
name: string;
arguments?: string[];
result?: string;
};
export type StepInvocation = {
name: string;
arguments?: string[];
result?: string;
};
export type DSLGeneration = {
nodeId: string;
graph: DirectedGraph;
bindings: Record<string, string>;
acts: Record<string, (...args: string[]) => Promise<string | undefined>>;
steps: Record<string, (...args: string[]) => Promise<string | undefined>>;
nodeIds: string[];
execute: () => Promise<unknown>;
};
export declare function DSLInterpreter(dsl: DSLDefinition, injectedActivities?: Record<string, (...args: string[]) => Promise<string | undefined>>, injectedSteps?: Record<string, (...args: string[]) => Promise<string | undefined>>): AsyncGenerator<DSLGeneration, void, unknown>;
/**
* Adapter function to convert StepMetadata from the @Step decorator into DSLDefinition format
*
* @param steps Array of step metadata from a Workflow class
* @returns DSLDefinition object representing the workflow steps
*/
export declare function convertStepsToDSL(steps: StepMetadata[], initialVariables?: Record<string, unknown>): DSLDefinition;