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 🙏

© 2024 – Pkg Stats / Ryan Hefner

arvo-core

v2.1.15

Published

This core package contains all the core classes and components of the Arvo Event Driven System

Downloads

2,113

Readme

SonarCloud Quality Gate Status

Arvo

In the landscape of event-driven systems, Arvo attempts to stand apart through its unique approach to complexity. Rather than prescribing rigid solutions, Arvo provides a thoughtful pattern language and methodology for building distributed systems. It achieves this by striking a careful balance between structure and freedom, offering strong conventions while remaining deliberately unopinionated about implementation details.

Core Philosophy

Arvo's fundamental principle is that distributed systems thrive on trust and clear contracts, yet must remain flexible in their technical implementation. While the framework ensures reliability and type safety across service boundaries through these contracts, it consciously avoids dictating how you should implement core functionalities like security, event brokerage, event handling, telemetry, or workflow orchestration. This approach enables seamless integration with your existing infrastructure and tools, whether you're using cloud providers like AWS and Azure or your own on-premise solutions. Understanding that teams shouldn't need to reinvent common patterns, Arvo provides thoughtfully designed tools to reduce implementation complexity. The Arvo suite includes libraries like arvo-xstate for workflow orchestration using state machines and arvo-event-handler for implementing contract-based event handlers. However, these tools remain entirely optional – they exist to accelerate development when they align with your needs, but Arvo fully supports teams who choose different approaches that better suit their specific requirements. This philosophy particularly benefits teams focusing on business logic who want to avoid rebuilding fundamental event-driven patterns. By providing essential building blocks for event creation, contract validation, state management, and telemetry, while maintaining cloud agnosticism and extensibility, Arvo reduces the complexity of distributed system development without constraining technical choices.

Design Goals

Arvo addresses the inherent complexity of distributed systems by establishing clear patterns for event handling, state management, and service communication. Instead of enforcing a rigid framework, it provides a flexible foundation that helps teams reduce cognitive load while preserving their ability to innovate and adapt. This approach ensures that whether you're building a small microservice or orchestrating a large-scale distributed system, Arvo's lightweight core and extensible architecture can grow alongside your needs, allowing you to progressively adopt more sophisticated patterns as your system evolves.

The Arvo Framework: Build at Your Own Pace

The Arvo framework provides a cohesive set of libraries for building event-driven systems. While designed to work together seamlessly, each component remains independent - adopt what serves your needs and integrate at your own pace.

| Scope | NPM | Github | Documentation | | ------------ | ------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- | | Orchestration | https://www.npmjs.com/package/arvo-xstate?activeTab=readme | https://github.com/SaadAhmad123/arvo-xstate | https://saadahmad123.github.io/arvo-xstate/index.html | | Core | https://www.npmjs.com/package/arvo-core?activeTab=readme | https://github.com/SaadAhmad123/arvo-core | https://saadahmad123.github.io/arvo-core/index.html | | Event Handling | https://www.npmjs.com/package/arvo-event-handler?activeTab=readme | https://github.com/SaadAhmad123/arvo-event-handler | https://saadahmad123.github.io/arvo-event-handler/index.html |

Arvo - Core

Arvo Core provides the foundational building blocks for creating robust event-driven systems. It implements industry standards while adding enterprise-grade features, enabling developers to build reliable distributed systems without sacrificing flexibility or introducing vendor lock-in.

Core Concepts

Understanding Arvo Core begins with its three fundamental components that work together to create a robust event-driven architecture:

1. Events (ArvoEvent)

ArvoEvent extends the CloudEvents specification to provide a standardized way to describe events in your system. Every event is an immutable, validated instance that includes:

import { createArvoEvent } from 'arvo-core';

const event = createArvoEvent({
  source: 'user-service',
  type: 'user.created',
  subject: 'user/123',
  data: {
    userId: 'usr_123',
    email: '[email protected]'
  }
});

2. Contracts (ArvoContract)

ArvoContract defines and enforces agreements between services, ensuring type safety and validation across your distributed system:

import { createArvoContract, z } from 'arvo-core';

const userContract = createArvoContract({
  uri: '#/contracts/user',
  type: 'user.created',
  versions: {
    '1.0.0': {
      accepts: z.object({
        userId: z.string(),
        email: z.string().email()
      }),
      emits: {
        'user.notification.sent': z.object({
          userId: z.string(),
          timestamp: z.date()
        })
      }
    }
  }
});

3. Event Factory (ArvoEventFactory)

ArvoEventFactory provides a type-safe way to create events that conform to your contracts. It handles validation, OpenTelemetry integration, and ensures events meet their contract specifications:

import { createArvoEventFactory } from 'arvo-core';

// Create a factory for a specific contract version
const factory = createArvoEventFactory(userContract.version('1.0.0'));

// Create an event that accepts input
const inputEvent = factory.accepts({
  source: 'api/users',
  subject: 'user/creation',
  data: {
    userId: 'usr_123',
    email: '[email protected]'
  }
});

// Create an event that emits output
const outputEvent = factory.emits({
  type: 'user.notification.sent',
  source: 'notification-service',
  subject: 'notification/sent',
  data: {
    userId: 'usr_123',
    timestamp: new Date()
  }
});

// Create a system error event
const errorEvent = factory.systemError({
  error: new Error('Validation failed'),
  source: 'validation-service',
  subject: 'validation/error'
});

Installation

# Using npm
npm install arvo-core

# Using yarn
yarn add arvo-core

Advanced Usage

Working with Contract Versions

The versioning system in ArvoContract allows you to evolve your APIs while maintaining compatibility:

const versionedContract = createArvoContract({
  uri: '#/contracts/order',
  type: 'order.process',
  versions: {
    '1.0.0': {
      accepts: z.object({ orderId: z.string() }),
      emits: { 
        'order.processed': z.object({ status: z.string() }) 
      }
    },
    '2.0.0': {
      accepts: z.object({ 
        orderId: z.string(),
        metadata: z.record(z.string()) 
      }),
      emits: { 
        'order.processed': z.object({ 
          status: z.string(),
          metrics: z.object({ duration: z.number() })
        }) 
      }
    }
  }
});

// Create version-specific factories
const v1Factory = createArvoEventFactory(versionedContract.version('1.0.0'));
const v2Factory = createArvoEventFactory(versionedContract.version('2.0.0'));

Integration with Other Arvo Components

Arvo Core works seamlessly with:

  • arvo-event-handler: For processing events
  • arvo-xstate: For orchestration and workflow management

Each component builds upon these core primitives while maintaining the same principles of flexibility and reliability.

Best Practices

  1. Use factories for event creation to ensure contract compliance
  2. Implement proper error handling using the standard error schema
  3. Enable distributed tracing in production systems
  4. Share contracts as separate packages or monorepo internals
  5. Utilize version-specific factories for different API versions

Resources

| Resource | Link | |--------------|-------------------------------------------------------------| | Documentation | https://saadahmad123.github.io/arvo-core/index.html | | GitHub | https://github.com/SaadAhmad123/arvo-core | | NPM Package | https://www.npmjs.com/package/arvo-core |

License

This package is available under the MIT License. For more details, refer to the LICENSE.md file in the project repository.

Change Logs

For a detailed list of changes and updates, please refer to the document file.

SonarCloud Metrics

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