State-machine execution model engineered with write-ahead persistence, distributed worker dispatching, and zero-loss crash recovery.
Decoupled state management and worker execution guaranteeing reliable distributed operations.
Declarative graph definition supporting linear, branching, conditional fan-out, and join barrier coordination with strict cycle detection.
Every transition is committed to durable storage (SQLite / PostgreSQL / Redis) before invoking step handlers, allowing zero-loss recovery from crashes.
Full step-by-step audit traces capturing input payloads, output results, memory utilization, step durations, and error stack snapshots.
Execute tasks across local in-process threads, distributed worker queues, serverless lambdas, or containerized background jobs seamlessly.
Functional domain decomposition, conceptual boundaries, and mathematical finite-state automata progression models independent of physical infrastructure.
Physical Kubernetes pod sizing, container resource envelopes, network ports, concurrency models, and high availability active-active clustering.
Type-safe DAG definition with intellisense, autocomplete, and compile-time input/output contract enforcement.
import { WorkflowBuilder } from '@vaakworkflow/sdk';
interface OrderContext {
orderId: string;
amount: number;
userId: string;
paymentConfirmed?: boolean;
inventoryReserved?: boolean;
}
export const orderFulfillment = new WorkflowBuilder<OrderContext>('order-fulfillment')
.startWith('validate-order', async ({ context }) => {
if (context.amount <= 0) throw new Error('Invalid order amount');
return { status: 'VALIDATED' };
})
.then('charge-payment', async ({ context }) => {
const charge = await paymentGateway.charge(context.userId, context.amount);
return { paymentConfirmed: true, transactionId: charge.id };
}, {
retry: { maxAttempts: 3, backoffMs: 1000, exponent: 2 }
})
.parallel('provision-services', [
builder => builder.step('reserve-inventory', async ({ context }) => {
await inventoryService.reserve(context.orderId);
}),
builder => builder.step('generate-tax-invoice', async ({ context }) => {
await invoiceService.create(context.orderId, context.amount);
})
])
.then('dispatch-notification', async ({ context }) => {
await notificationService.sendOrderConfirmation(context.userId, context.orderId);
})
.build();