npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@microstack-dev/workflow

v0.1.0

Published

A minimal, strongly-typed, event-driven workflow engine for TypeScript

Readme

@microstack-dev/workflow

npm version build status coverage license downloads

A minimal, strongly-typed, event-driven workflow engine for TypeScript.

v0.1.0 Scope Notice: This version intentionally focuses on core workflow execution only. No CLI, config loaders, persistence, or plugins.

What workflow Is

  • Core workflow execution engine - Run sequential steps with shared context
  • Event-driven lifecycle - First-class events for monitoring and debugging
  • Strong TypeScript support - Fully typed with no any types
  • Explicit over implicit - Clear, predictable behavior with no magic
  • Extensible by design - Clean architecture for future enhancements

What workflow Is Not

  • ❌ A CLI tool
  • ❌ A YAML/JSON configuration system
  • ❌ A persistence layer
  • ❌ A cloud service or CI runner
  • ❌ A plugin marketplace
  • ❌ A visual workflow designer

Quick Start

import { defineWorkflow, createStep, WorkflowEngine } from 'workflow';

// Define a workflow
const workflow = defineWorkflow({
  name: 'data-pipeline',
  steps: [
    createStep('fetch-data')
      .run(async (ctx) => {
        const data = await fetchData();
        ctx.set('rawData', data);
      })
      .timeout(5000)
      .build(),
      
    createStep('process-data')
      .run(async (ctx) => {
        const rawData = ctx.get('rawData');
        const processed = processData(rawData);
        ctx.set('processedData', processed);
      })
      .condition(async (ctx) => ctx.has('rawData'))
      .build(),
      
    createStep('save-results')
      .run(async (ctx) => {
        const results = ctx.get('processedData');
        await saveToDatabase(results);
      })
      .retry(3)
      .build()
  ]
});

// Execute the workflow
const engine = new WorkflowEngine();

// Listen to events
engine.on('workflow:start', (event) => {
  console.log(`Starting workflow: ${event.workflowName}`);
});

engine.on('step:success', (event) => {
  console.log(`Step completed: ${event.stepId}`);
});

engine.on('workflow:success', (event) => {
  console.log(`Workflow completed successfully`);
});

// Run the workflow
await engine.run(workflow);

Core Concepts

Workflow Definition

Use defineWorkflow to create workflows with sequential steps:

const workflow = defineWorkflow({
  name: string,
  steps: Step[]
});

Steps

Steps are units of execution with optional conditions, retries, and timeouts:

interface Step {
  id: string;
  run(ctx: WorkflowContext): Promise<void>;
  condition?: (ctx: WorkflowContext) => boolean | Promise<boolean>;
  retry?: number;
  timeout?: number;
}

Step Builder

Use the fluent builder API for cleaner step creation:

createStep('my-step')
  .run(async (ctx) => { /* ... */ })
  .condition(async (ctx) => true)
  .retry(3)
  .timeout(5000)
  .build();

Workflow Context

Shared execution context that persists across steps:

class WorkflowContext {
  data: Record<string, unknown>;
  env: NodeJS.ProcessEnv;

  get<T>(key: string): T | undefined;
  set(key: string, value: unknown): void;
  has(key: string): boolean;
  delete(key: string): boolean;
  clear(): void;
  clone(): WorkflowContext;
}

Event Lifecycle

workflow emits first-class events for monitoring and debugging:

Workflow Events

  • workflow:start - Workflow execution begins
  • workflow:success - Workflow completed successfully
  • workflow:fail - Workflow failed with error

Step Events

  • step:start - Step execution begins
  • step:success - Step completed successfully
  • step:fail - Step failed with error
  • step:skip - Step skipped due to condition

Event Structure

interface WorkflowEvent {
  workflowName: string;
  stepId?: string;
  timestamp: Date;
  error?: Error;
}

Error Handling

Explicit error types for different failure scenarios:

// Workflow-level errors
class WorkflowError extends Error {
  workflowName: string;
  timestamp: Date;
}

// Step execution errors  
class StepError extends Error {
  stepId: string;
  workflowName: string;
  timestamp: Date;
}

// Step timeout errors
class TimeoutError extends Error {
  stepId: string;
  workflowName: string;
  timeout: number;
  timestamp: Date;
}

API Reference

Classes

  • Workflow - Workflow definition with validation
  • WorkflowEngine - Core execution engine with event emission
  • WorkflowContext - Shared execution context
  • EventEmitter - Event system for lifecycle events

Functions

  • defineWorkflow(options) - Create a workflow definition
  • createStep(id) - Create a step with builder pattern

Types

  • Step - Step interface definition
  • WorkflowEvent - Event structure
  • WorkflowEventType - Union of all event types
  • WorkflowEventListener - Event handler function type

Installation

npm install workflow

Requirements:

  • Node.js >= 18.0.0
  • TypeScript >= 5.0

Development

# Install dependencies
npm install

# Run tests
npm test

# Type checking
npm run typecheck

# Build
npm run build

# Development mode
npm run dev

License

MIT © microstack-dev


v0.1.0 Release Notes

Initial release of workflow.

  • Core workflow execution engine
  • Step-based sequential execution
  • Shared execution context
  • Retry & conditional logic
  • Event-driven lifecycle

This version intentionally excludes CLI tooling, config loaders, and plugins.