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 🙏

© 2025 – Pkg Stats / Ryan Hefner

swfme

v0.1.2

Published

Process-Oriented Programming Framework for TypeScript - Workflow Management Engine

Readme

sWFME - TypeScript

Process-Oriented Programming Framework for TypeScript

A modern workflow management engine inspired by the original sWFME C# implementation (2010). Build complex workflows by composing atomic processes with sequential and parallel execution.

Features

  • Process Abstraction - Define atomic and orchestrated processes
  • Type-Safe Parameters - Strongly typed input/output parameters
  • Sequential & Parallel Execution - Compose workflows with execution flags
  • Event-Driven Monitoring - Real-time process events via EventBus
  • Metrics Collection - Automatic performance tracking
  • Process Registry - Dynamic workflow discovery and creation

Installation

npm install swfme

Quick Start

1. Define Atomic Processes

import {
  AtomarProcess,
  InputParameter,
  OutputParameter,
} from 'swfme';

class ProcessAdd extends AtomarProcess {
  defineParameters(): void {
    this.input.add(new InputParameter({ name: 'a', type: 'number' }));
    this.input.add(new InputParameter({ name: 'b', type: 'number' }));
    this.output.add(new OutputParameter({ name: 'sum', type: 'number' }));
  }

  async executeImpl(): Promise<void> {
    const a = this.input.get<'number'>('a')!.value!;
    const b = this.input.get<'number'>('b')!.value!;
    this.output.get<'number'>('sum')!.value = a + b;
  }
}

2. Create Orchestrated Workflows

import {
  OrchestratedProcess,
  SEQUENTIAL,
  PARALLEL,
} from 'swfme';

class MathPipeline extends OrchestratedProcess {
  defineParameters(): void {
    this.input.add(new InputParameter({ name: 'a', type: 'number' }));
    this.input.add(new InputParameter({ name: 'b', type: 'number' }));
    this.output.add(new OutputParameter({ name: 'result', type: 'number' }));
  }

  orchestrate(): void {
    // Step 1: Add
    const add = new ProcessAdd('Add');
    this.connectParam(this.input.get('a')!, add.input.get('a')!);
    this.connectParam(this.input.get('b')!, add.input.get('b')!);
    this.addChild(add, SEQUENTIAL);

    // Step 2: Multiply by 2
    const multiply = new ProcessMultiply('Multiply');
    this.connectParam(add.output.get('sum')!, multiply.input.get('value')!);
    multiply.input.get('factor')!.value = 2;
    this.addChild(multiply, SEQUENTIAL);

    // Output derivation
    this.connectParam(multiply.output.get('result')!, this.output.get('result')!);
  }
}

3. Execute Workflows

const pipeline = new MathPipeline();
pipeline.input.get('a')!.value = 5;
pipeline.input.get('b')!.value = 3;

const success = await pipeline.execute();

if (success) {
  console.log('Result:', pipeline.output.get('result')!.value); // 16
}

Execution Flags

  • SEQUENTIAL - Execute one after another
  • PARALLEL - Execute concurrently
// Sequential execution
this.addChild(process1, SEQUENTIAL);
this.addChild(process2, SEQUENTIAL); // Waits for process1

// Parallel execution
this.addChild(processA, PARALLEL);
this.addChild(processB, PARALLEL); // Runs simultaneously
this.addChild(processC, SEQUENTIAL); // Waits for A and B

Event Monitoring

import { eventBus } from 'swfme';

eventBus.subscribe('process.started', (event) => {
  console.log(`Started: ${event.processName}`);
});

eventBus.subscribe('process.completed', (event) => {
  console.log(`Completed: ${event.processName} in ${event.executionTimeMs}ms`);
});

eventBus.subscribe('process.failed', (event) => {
  console.log(`Failed: ${event.processName} - ${event.error}`);
});

Metrics

import { metricsCollector } from 'swfme';

// Get summary
const summary = metricsCollector.getSummary();
console.log(`Total: ${summary.totalProcesses}`);
console.log(`Success Rate: ${(summary.successRate * 100).toFixed(1)}%`);

// Get per-process metrics
const metrics = metricsCollector.getMetrics(process.id);
console.log(`Execution Time: ${metrics?.executionTimeMs}ms`);

Process Registry

import { processRegistry } from 'swfme';

// Register processes
processRegistry.register(MathPipeline);
processRegistry.register(DataPipeline, 'CustomName');

// List registered processes
const processes = processRegistry.listProcesses();

// Create by name
const workflow = processRegistry.create('MathPipeline');

Parameter Types

Supported parameter types:

  • 'string'
  • 'number'
  • 'boolean'
  • 'object'
  • 'array'
  • 'any'
this.input.add(new InputParameter({
  name: 'data',
  type: 'array',
  required: true,
  description: 'Input data array'
}));

Examples

Run the included examples:

npm run example        # Simple workflow
npm run example:math   # Math pipeline

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Watch mode
npm run dev

Architecture

swfme/
├── core/
│   ├── process.ts      # Process, AtomarProcess, OrchestratedProcess
│   └── parameters.ts   # Parameter, ParameterSet
├── monitoring/
│   ├── event-bus.ts    # EventBus for process events
│   └── metrics.ts      # MetricsCollector
└── registry/
    └── process-registry.ts  # ProcessRegistry

License

MIT

Author

Alex Popovic (Arkturian) - 2025

Modernized from the original sWFME C# implementation (2010).