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

temporalio-graphs

v0.3.1

Published

Generate workflow graphs for Temporal by running workflows in mocked-execution mode

Downloads

6

Readme

temporalio-graphs

Generate workflow graphs for Temporal by running workflows in mocked-execution mode.

TypeScript port of Temporalio.Graphs by Oleg Shilo

The original .NET library provides an elegant approach to visualizing Temporal workflows by executing them in a mocked environment and capturing the execution graph. This TypeScript implementation brings the same capabilities to the Node.js ecosystem.

Workflow Viewer

Features

  • Generate complete workflow DAGs without running actual activities
  • Capture all decision branches via automatic permutation
  • Output Mermaid flowchart syntax
  • Interactive HTML viewer with pan/zoom and step-by-step animation
  • Support for child workflow visualization

Installation

npm install temporalio-graphs

Quick Start

1. Define Your Activities with Decision Points

Use the @Decision decorator to mark activities that represent branching decisions:

import { Decision } from 'temporalio-graphs';

export class MyActivities {
  @Decision({ positiveLabel: 'high', negativeLabel: 'low' })
  async isHighValue(amount: number): Promise<boolean> {
    return amount > 10000;
  }

  async processPayment(amount: number): Promise<void> {
    // Process payment logic
  }
}

2. Build the Graph

Create a build script that uses createMockActivities to mock your activities during graph generation:

import { buildGraph, generateViewerHtml, createMockActivities } from 'temporalio-graphs';
import { MyActivities } from './activities';
import * as fs from 'fs';

// Create mock activities for graph building
const activitiesInstance = new MyActivities();
const activities = createMockActivities<MyActivities>({
  activitiesClass: activitiesInstance,
});

// Define workflow using mock activities
async function myWorkflow(input: { amount: number }): Promise<void> {
  if (await activities.isHighValue(input.amount)) {
    // High value path
  }
  await activities.processPayment(input.amount);
}

// Build the graph
const result = await buildGraph(myWorkflow, {
  workflowArgs: [{ amount: 5000 }],
  splitNamesByWords: true,
});

// Output Mermaid syntax
console.log(result.mermaid);

// Generate interactive HTML viewer
const html = generateViewerHtml(result.mermaid, 'My Workflow');
fs.writeFileSync('workflow.html', html);

Output Example

flowchart LR
s((Start)) --> isHighValue{isHighValue}
isHighValue -- high --> processPayment --> e((End))
isHighValue -- low --> processPayment

Using with Temporal Runtime

For use within actual Temporal workers, export the interceptors from your workflows file:

import { createGraphBuildingInterceptors } from 'temporalio-graphs';

export const interceptors = createGraphBuildingInterceptors();

API Reference

buildGraph(workflow, options)

Builds a workflow graph by running the workflow in mocked-execution mode.

Options:

  • workflowArgs: Arguments to pass to the workflow
  • maxDecisions: Maximum decision points to explore (default: 10)
  • splitNamesByWords: Split camelCase names for readability

Returns: GraphResult with paths, edges, mermaid, pathDescriptions

createMockActivities<T>(options?)

Creates mock activity proxies for graph building mode. This is the key function for generating graphs outside the Temporal runtime.

Options:

  • activitiesClass: Instance of your activities class (used to detect @Decision decorators)

@Decision(options?)

Decorator to mark an activity as a decision point.

Options:

  • positiveLabel: Label for true branch (default: 'yes')
  • negativeLabel: Label for false branch (default: 'no')

toDecision(condition, label, options?)

Wrapper for inline boolean conditions in workflows.

generateViewerHtml(mermaid, title?)

Generates an interactive HTML viewer for the workflow graph.

createGraphBuildingInterceptors()

Creates workflow interceptors for graph building mode (for use with Temporal runtime).

Design Decisions

Decision Point Marking

We use @Decision decorator + toDecision() wrapper (matching the .NET implementation) because:

  1. Parity with .NET - Familiar patterns for Temporalio.Graphs users
  2. Explicit over implicit - Decision points are architectural choices
  3. Covers both use cases - Activities and inline conditions
  4. Type-safe - Full TypeScript support
  5. No magic - Clear developer intent

Examples

See the examples/ directory:

  • money-transfer/ - Port of the original .NET example
  • fintech-pipeline/ - Simplified daily pipeline example

To run an example:

cd examples/money-transfer
npm install
npm run graph
open workflow.html

License

MIT - Based on Temporalio.Graphs by Oleg Shilo.