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

@orditjs/contracts

v0.2.1-beta.5

Published

Contratos publicos de Ordit: envelopes, metadata, outcomes portables y semantica comun para eventos, colas y pub/sub.

Downloads

869

Readme

@orditjs/contracts

Portable TypeScript contracts for Ordit.

Use this package when you need the shared language of Ordit without pulling in the framework runtime: envelopes, messages, handler types, binding definitions, execution records, ports and workflow contracts.

Install

npm install @orditjs/contracts

What is inside

  • Message primitives: ICommand, IEvent, IEnvelope.
  • Factories: createCommand, createEvent, createEnvelope.
  • Handler contracts: HandlerFunction, HandlerConfig, HandlerOutcome.
  • Binding contracts: BindingDefinition, triggers, transport definitions, sandbox, retry, outputs and publish permissions.
  • Runtime contracts: RuntimeEnvelope, RuntimeAddress, execution records and logs.
  • Runtime ports: SandboxRunner, Publisher, ExecutionLedger, IdempotencyStore, RetryEngine, ReplayEngine, BindingConsumer, HandlerLoader.
  • Workflow contracts used by the lower-level runtime package.

Basic usage

import { createEnvelope, createEvent } from '@orditjs/contracts'

const event = createEvent('user.created', {
  userId: 'u-123',
})

const envelope = createEnvelope(event, {
  messageId: 'msg-1',
  correlationId: 'corr-1',
  occurredAt: new Date().toISOString(),
  metadata: {
    source: 'example',
  },
})

console.log(envelope.message.type)

Defining a binding

import type { BindingDefinitionDraft } from '@orditjs/contracts'

const draft: BindingDefinitionDraft = {
  name: 'normalize-user',
  triggers: [
    {
      type: 'event',
      key: 'event.user.created',
      event: 'user.created',
    },
  ],
}

For validation and defaults, pass drafts to NormalizeBindingDefinition from @orditjs/core.

Binding triggers and transports

Bindings separate the trigger shape from the transport implementation. This keeps handlers portable across local compose, service hosts and future serverless adapters.

Generic trigger types:

  • file.changed
  • http
  • event
  • queue
  • cron
  • object.storage
  • custom

Concrete transport providers:

  • generic: explicit address and optional protocol for custom adapters.
  • rabbitmq: queue/exchange/routing-key oriented AMQP bindings.
  • sqs: AWS SQS queue URL/name oriented bindings.
  • redis: Redis pubsub, stream or list bindings.
  • s3: S3-compatible object storage bindings.
  • custom: user-owned adapter source and options.

Example:

import type { BindingDefinitionDraft } from '@orditjs/contracts'

const draft: BindingDefinitionDraft = {
  name: 'normalize-order',
  triggers: [
    {
      type: 'queue',
      key: 'rabbitmq.orders',
      queue: 'orders.created',
      transport: {
        provider: 'rabbitmq',
        connectionRef: 'env:RABBITMQ_URL',
        exchange: 'orders',
        routingKey: 'orders.created',
        queue: 'orders.created',
        prefetch: 10,
      },
    },
    {
      type: 'object.storage',
      key: 's3.inbox',
      bucket: 'orders-inbox',
      eventType: 'object.created',
      transport: {
        provider: 's3',
        connectionRef: 'env:AWS_PROFILE',
        bucket: 'orders-inbox',
        prefix: 'incoming/',
      },
    },
  ],
  outputs: [
    {
      event: 'order.normalized',
      target: {
        kind: 'queue',
        id: 'orders-normalized',
      },
      transport: {
        provider: 'sqs',
        queueName: 'orders-normalized',
        region: 'us-east-1',
      },
    },
  ],
}

Transport contracts are serializable descriptions only. SDK clients, credentials, polling loops and broker-specific delivery behavior belong in framework or platform adapters, not in @orditjs/contracts.

Implementing a port

import type { Publisher } from '@orditjs/contracts'

export class ConsolePublisher implements Publisher {
  async publish(request) {
    return {
      status: 'ok',
      items: request.outputs.map((output) => ({
        eventType: output.message.type,
        status: 'published',
        target: 'console',
      })),
    }
  }
}

Package boundary

@orditjs/contracts contains types and portable factories only. It should not own framework discovery, filesystem access, HTTP servers, broker SDKs or runtime composition.