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

@pegma/spine

v0.1.2

Published

Shared identity, time, logging, and event contracts for Pegma components.

Readme

Spine

CI License: MIT

The small, stable contracts every Pegma component shares.

[!IMPORTANT] Spine is in early 0.x development. @pegma/spine is published on npm, but its public API is not stable and it is not ready for production use.

Why it exists

Pegma components are independent packages that a host application composes: storage, authorization, a support desk, a blog. They must agree on a handful of things or they cannot be assembled — what a principal identifier is, how time is read, where a log line goes, what an event looks like.

Spine is the one package everything peers on. It is deliberately tiny and close to frozen: the more it changes, the more the ecosystem churns.

Everything else belongs in the component that owns it. Storage semantics live in @pegma/storage-core. Permission semantics live in @pegma/authorization-core.

What is in it

| Export | Purpose | | ------------------------------------ | ------------------------------------------- | | PrincipalId, IsoTimestamp | Shared identity and time types | | Clock, systemClock, fixedClock | Time as an injected input, fixable in tests | | Logger, noopLogger | One-method structured logging port | | defineEvent, EventDefinition | Typed event declarations | | EventBus, createEventBus | Best-effort in-process notification bus |

Events come in two tiers

Notifications — this package. In-process, best effort. Cache invalidation, metrics, coordination inside one request. A notification that is lost costs nothing.

Durable events — not this package. Anything that must survive a crash (outbound mail, entitlement changes, webhook deliveries) is written to an outbox in the same operation as the state change and delivered by a dispatcher. That belongs to @pegma/storage-core, because it needs persistence to be correct.

The two are separate APIs on purpose. An in-process bus is perfectly reliable on a developer's machine and silently lossy in production, so the choice between tiers should be visible in the code rather than left to memory.

Example

import { createEventBus, defineEvent, type PrincipalId } from "@pegma/spine";

interface AccountCreated {
  readonly principalId: PrincipalId;
  readonly email: string;
}

// Declared in a component's contracts package and exported as a constant, so
// publishers and subscribers are checked against the same type.
const AccountCreated = defineEvent<AccountCreated>("account.created");

// Wired once at the host's composition root.
const bus = createEventBus();

bus.subscribe(AccountCreated, (envelope) => {
  welcomeCache.invalidate(envelope.payload.principalId);
});

await bus.publish(AccountCreated, {
  principalId: "account_123",
  email: "[email protected]",
});

Handlers run in subscription order, one at a time, and publish resolves once they have settled. A handler that throws is reported to the logger and does not stop the handlers after it; publish never rejects.

Design principles

  • Small and stable: Every addition here is a change every component inherits. Prefer letting a component own a type until a second component genuinely needs it.
  • Ports, not implementations: Spine defines what a clock, logger, and bus are. Hosts supply real ones.
  • Explicit wiring: Subscriptions are registered at a composition root, not discovered by convention. The wiring file is the map of the system.
  • No dynamic event names: Events are typed constants, so a single search finds every publisher and subscriber.
  • No dependencies: Spine has no runtime dependencies and never will.

Not here yet

A shared error taxonomy is deliberately deferred. @pegma/storage-core will be the first package to need conflict and not-found semantics, and its real requirements should shape the contract rather than a guess made in advance.

Development

Spine requires Node.js 22 or newer.

npm ci
npm run check
npm test
npm run format:check

License

MIT © 2026 RetireGolden, LLC