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

@mettlecast/domain-runtime

v0.2.54

Published

Type-safe runtime types, factory functions, and context interface for TIB Domain Module handlers. Zero AWS dependencies in the main export — all infrastructure concerns are delegated to the CDK packer.

Readme

@mettlecast/domain-runtime

Type-safe runtime types, factory functions, and context interface for TIB Domain Module handlers. Zero AWS dependencies in the main export — all infrastructure concerns are delegated to the CDK packer.

Install

npm install @mettlecast/domain-runtime

Quick Start

Define a domain with an API handler:

import {
  defineDomain,
  defineApi,
  defineEvent,
  type DomainContext,
} from '@mettlecast/domain-runtime';

const domain = defineDomain({
  name: 'payments',
  version: '1.0.0',
});

const paymentCreated = defineEvent({
  name: 'payment.created',
  schema: {
    type: 'object',
    properties: {
      paymentId: { type: 'string' },
      amount: { type: 'number' },
    },
  },
});

export const chargeHandler = defineApi({
  domain,
  path: '/charge',
  method: 'POST',
  handler: async (event, ctx: DomainContext) => {
    const amount = event.body.amount;
    
    // Use context surfaces
    await ctx.db.query('INSERT INTO charges ...');
    await ctx.publish(paymentCreated, { paymentId: '123', amount });
    await ctx.cache.set('last_charge', amount);
    
    return { statusCode: 200, body: { success: true } };
  },
});

Factory Functions

9 factory functions help you define domain primitives with schema validation and type safety:

| Function | Purpose | Produces | |---|---|---| | defineDomain() | Declare a domain and version | Domain metadata | | defineApi() | HTTP handler with route + method | API handler + EventBridge integration | | defineEvent() | Event type with schema | Typed event publisher | | defineWebhook() | Inbound GitHub webhook handler | Webhook + validation | | defineSubscriber() | Event subscriber handler | EventBridge rule + Lambda | | defineSchedule() | Cron-triggered handler | EventBridge Scheduler rule | | defineJob() | Async queue-based task | SQS queue + Lambda consumer | | defineAction() | Flow Designer action | Workspace-invoked handler | | defineIntegration() | External service integration | Async integration handler |

Context Surfaces

14 surfaces available in DomainContext:

| Surface | Purpose | |---|---| | ctx.db | PostgreSQL connection pool via drizzle-orm | | ctx.publish() | Publish an event to EventBridge | | ctx.actions | Invoke other domain actions | | ctx.integrations | Call external integrations | | ctx.jobs | Enqueue async tasks to SQS | | ctx.flows | Trigger TIB Flow Designer flows | | ctx.cache | In-memory or distributed cache (Redis) | | ctx.secrets | Fetch AWS Secrets Manager values | | ctx.fetch() | HTTP client with request/response tracing | | ctx.idempotency | Deduplication by request ID | | ctx.logger | Pino JSON logger | | ctx.tracer | AWS X-Ray tracing | | ctx.request | Original HTTP request object | | ctx.requestId | Unique request UUID |

Design Principles

This package is intentionally framework-agnostic. It exports types and factory functions only — all infrastructure (Lambdas, API Gateway, EventBridge, SQS, etc.) is provisioned by @mettlecast/domain-cdk-packer.

Exports by concern:

  • @mettlecast/domain-runtime — types, factories, DomainContext
  • @mettlecast/domain-runtime/primitives — factory functions only
  • @mettlecast/domain-runtime/ctx — context interfaces
  • @mettlecast/domain-runtime/types — TypeScript types
  • @mettlecast/domain-runtime/schema — Zod schema utilities

See wiki/how-it-works/domain-module.md for the full design.