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

arvo-event-handler

v3.0.25

Published

A complete set of orthogonal event handler and orchestration primitives for Arvo based applications, featuring declarative state machines (XState), imperative resumables for agentic workflows, contract-based routing, OpenTelemetry observability, and in-me

Readme

SonarCloud Quality Gate Status

Arvo - A toolkit for event driven applications (arvo-event-handler)

The orchestration and event processing foundation for Arvo, providing everything from simple event handlers to complex workflow orchestration with state machines and imperative resumables.

This package provides three core handler patterns and essential infrastructure for building reliable event-driven systems:

ArvoEventHandler - Stateless event processors that transform contract-defined events. Perfect for microservices, API endpoints, and simple request-response patterns.

ArvoOrchestrator - Declarative state machine-based workflow orchestration using XState. Ideal for complex business processes with clear states, transitions, and parallel execution.

ArvoResumable - Imperative workflow handlers with explicit state management. Best for dynamic workflows, AI-driven decision logic, and teams preferring traditional programming patterns.

Installation

npm install arvo-event-handler arvo-core xstate@5 zod@3

Quick Start

Simple Event Handler

import { createArvoEventHandler } from 'arvo-event-handler';
import { createArvoContract } from 'arvo-core';
import { z } from 'zod';

const contract = createArvoContract({
  uri: '#/contracts/user',
  type: 'user.validate',
  versions: {
    '1.0.0': {
      accepts: z.object({ email: z.string().email() }),
      emits: {
        'evt.user.validate.success': z.object({ valid: z.boolean() })
      }
    }
  }
});

const handler = createArvoEventHandler({
  contract,
  executionunits: 0,
  handler: {
    '1.0.0': async ({ event }) => ({
      type: 'evt.user.validate.success',
      data: { valid: true }
    })
  }
});

State Machine Orchestrator

import { createArvoOrchestrator, setupArvoMachine } from 'arvo-event-handler';
import { createArvoOrchestratorContract } from 'arvo-core';

const orchestratorContract = createArvoOrchestratorContract({
  uri: '#/orchestrator/workflow',
  name: 'workflow',
  versions: {
    '1.0.0': {
      init: z.object({ userId: z.string() }),
      complete: z.object({ result: z.string() })
    }
  }
});

const machine = setupArvoMachine({
  contracts: {
    self: orchestratorContract.version('1.0.0'),
    services: { /* service contracts */ }
  }
}).createMachine({
  // XState machine definition
});

const orchestrator = createArvoOrchestrator({
  machines: [machine],
  memory, // IMachineMemory implementation
  executionunits: 0
});

Imperative Resumable

import { createArvoResumable } from 'arvo-event-handler';

const resumable = createArvoResumable({
  contracts: {
    self: orchestratorContract,
    services: { /* service contracts */ }
  },
  memory,
  executionunits: 0,
  handler: {
    '1.0.0': async ({ input, service, context }) => {
      if (input) {
        return {
          context: { userId: input.data.userId },
          services: [{ type: 'user.validate', data: { /* ... */ } }]
        };
      }
      // Handle service responses and return output
    }
  }
});

Additional Core Components

IMachineMemory - State persistence interface with optimistic locking for distributed workflow coordination. Includes SimpleMachineMemory for local development.

Error Handling - Three-tier system: business logic failures as contract events, transient errors as system events, and violations for critical failures requiring immediate intervention.

SimpleEventBroker - Local in-memory FIFO queue-based event broker for testing and development without external message infrastructure. Also suitable for production deployments with limited scale (≤1000 users).

SimpleMachineMemory - Local in-memory hash map based storage for testing and development without external database infrastructure.

All handlers implement the same interface IArvoEventHandler regardless of complexity, enabling consistent patterns across your entire system. Contract-first development ensures type safety and validation at every boundary. Built-in OpenTelemetry integration provides complete observability. State management through pluggable interfaces supports any storage backend from memory to distributed databases.

The same handler code works locally with in-memory brokers during development and in production with distributed message systems and persistent state stores.

What is arvo-event-handler?

The arvo-event-handler is one of the two foundational packages in the Arvo ecosystem, alongside arvo-core. Together, they provide the complete foundation for building event-driven applications that are distributed system-compliant. Explore additional tools and integrations in the @arvo-tools namespace.

Learn more at the official Arvo website: https://www.arvo.land/

Documentation

Complete guides, API reference, and tutorials at https://www.arvo.land/

License

MIT - See LICENSE.md


SonarCloud Metrics

Quality Gate Status Bugs Code Smells Coverage Duplicated Lines (%) Lines of Code Reliability Rating Security Rating Technical Debt Maintainability Rating Vulnerabilities