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

@astami/temporal-functions

v0.3.1

Published

A lightweight TypeScript framework providing lambda-like DX on top of Temporal's durable execution engine

Downloads

25

Readme

Temporal Functions

A lightweight TypeScript framework that provides a lambda-like developer experience on top of Temporal's durable execution engine.

Write only function bodies and trigger bindings — the framework handles all Temporal boilerplate (workers, activities, workflows, serialization).

Why Temporal Functions?

| Aspect | Lambda/Serverless | Raw Temporal | Temporal Functions | |--------|-------------------|--------------|-------------------| | Function definition | Simple | Verbose | Simple | | Durable execution | No | Yes | Yes | | Retries/timeouts | Limited | Powerful | Powerful | | Worker management | Managed | Manual | Abstracted | | Type safety | Varies | Yes | Yes |

Quick Example

import { tfn } from 'temporal-functions';

// Define functions (activities)
export const validateOrder = tfn.fn('validateOrder', async (order: Order) => {
  // validation logic
});

export const chargePayment = tfn.fn('chargePayment', async (order: ValidatedOrder) => {
  // payment logic
});

// Define workflow
export const processOrder = tfn.workflow('processOrder', async (ctx, order: Order) => {
  const validated = await ctx.run(validateOrder, order);
  const paid = await ctx.run(chargePayment, validated);
  return { orderId: paid.id, status: 'complete' };
});

That's it. No worker setup, no activity proxies, no boilerplate.

Key Principles

  1. Lambda-like DX — Write functions, not infrastructure
  2. Temporal underneath — Get durability, retries, exactly-once semantics for free
  3. TypeScript native — Full type safety, great IDE support
  4. Client-Worker separation — Scale triggers and executors independently
  5. Minimal abstraction — Thin layer, not a new platform

Installation

npm install temporal-functions

Usage

Define Functions

import { tfn } from 'temporal-functions';

export const sendEmail = tfn.fn(
  'sendEmail',
  async (params: EmailParams): Promise<EmailResult> => {
    return await emailService.send(params);
  },
  {
    timeout: '30s',
    retries: 3,
  }
);

Define Workflows

export const processOrder = tfn.workflow(
  'processOrder',
  async (ctx, order: Order) => {
    const validated = await ctx.run(validateOrder, order);

    // Parallel execution
    const [inventory, pricing] = await Promise.all([
      ctx.run(checkInventory, validated.items),
      ctx.run(calculatePricing, validated.items),
    ]);

    // Durable sleep
    await ctx.sleep('5 minutes');

    const payment = await ctx.run(processPayment, {
      amount: pricing.total,
      orderId: order.id,
    });

    return { orderId: order.id, status: 'complete' };
  }
);

Client (Trigger Workflows)

import { tfn } from 'temporal-functions/client';
import { processOrder } from '@myproject/functions';

const client = tfn.client({
  temporal: {
    address: 'localhost:7233',
    namespace: 'default',
  },
  taskQueue: 'orders',
});

// Fire and wait
const result = await client.invoke(processOrder, order);

// Fire and forget
const handle = await client.start(processOrder, order, {
  workflowId: `order-${order.id}`,
});

Worker (Execute Functions)

import { tfn } from 'temporal-functions/worker';
import { validateOrder, chargePayment, processOrder } from '@myproject/functions';

const worker = tfn.worker({
  temporal: {
    address: 'localhost:7233',
    namespace: 'default',
  },
  taskQueue: 'orders',
});

worker.register(validateOrder);
worker.register(chargePayment);
worker.register(processOrder);

await worker.start();

Triggers

// HTTP
tfn.http('POST', '/api/orders', processOrder);

// Cron
tfn.cron('0 9 * * *', dailyReport);

// Signal
tfn.signal('order.cancel', handleCancellation);

Project Structure

my-project/
├── packages/
│   ├── functions/          # Shared function definitions
│   │   └── src/
│   │       ├── orders/
│   │       └── notifications/
│   ├── worker/             # Worker service
│   │   └── src/index.ts
│   └── api/                # API/Client service
│       └── src/index.ts
└── package.json

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    TEMPORAL FUNCTIONS                        │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│   SHARED: Function Definitions                               │
│   tfn.fn()    tfn.workflow()    Types & Interfaces          │
│                                                              │
│        │                              │                      │
│        ▼                              ▼                      │
│   ┌──────────────┐            ┌──────────────┐              │
│   │    CLIENT    │            │    WORKER    │              │
│   │  Lightweight │            │   Full SDK   │              │
│   │    ~20KB     │            │    ~2MB      │              │
│   │              │            │              │              │
│   │  • start()   │            │  • register()│              │
│   │  • invoke()  │            │  • start()   │              │
│   │  • signal()  │            │              │              │
│   └──────┬───────┘            └──────┬───────┘              │
│          │                           │                       │
│          └───────────┬───────────────┘                       │
│                      ▼                                       │
│            ┌─────────────────┐                               │
│            │ TEMPORAL CLUSTER │                               │
│            └─────────────────┘                               │
│                                                              │
└─────────────────────────────────────────────────────────────┘

Documentation

See docs/ARCHITECTURE.md for the full architecture document.

Status

Design Phase — This project is currently in the design and early implementation phase.

License

MIT