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

@affordance/pg

v0.6.0

Published

Postgres storage and transactional execution for Affordance.

Readme

@affordance/pg

Postgres storage for Case references, optional observed diffs, launched execution ownership/status, correlations and event delivery bookkeeping. The application owns domain tables and all business transactions.

import { createEngine, createBackgroundRuntime } from '@affordance/core'
import { bootstrap, createPgStorage } from '@affordance/pg'

await bootstrap(pool) // Fresh framework schema; does not migrate or reset old data.
const storage = createPgStorage({ db: { pool } })
const binding = storage.bindCase(definition, {
  load: (q, reference) => purchases(q).loadCaseState(reference),
})
const runtime = createBackgroundRuntime()
const engine = createEngine({
  storage, caseTypes: [binding], launch: { runtime, leaseMs: 60_000 },
})
const current = await engine.attachCase(definition.name, { reference: purchaseId })

Bindings supply only an authoritative loader. Reads use a short consistent snapshot. No framework transaction or connection remains open during a handler's business work. Handlers close over the application's services and may use withTransaction themselves. To create and attach in one application transaction, call storage.attachCase(tx, binding, reference).

Launch claims use a partial unique index on Case identity. Running and unresolved records retain ownership; expiration never removes that index entry. Framework transitions lock the selected execution row, then check clock_timestamp() and identity. Completion and resolution release only the selected execution's block. These transactions do not include domain writes. Ordinary runs and other writers are outside this coordination protocol.

Journal writes use execution identity for deduplication. Core passes the remaining journal budget to the adapter, including connection acquisition. Queued attempts skip their write after the budget expires. Journal SQL uses a transaction-local statement_timeout: a blocked write rolls back and releases its connection so launch finalization can proceed, including with a one-connection pool or dedicated client. The previous connection timeout is restored after the transaction.

A write committed near the deadline may still appear after core reports timeout. It never changes launch status. A journal failure can coexist with completed status; a lost status acknowledgment remains uncertain until lookup/reconciliation. Neither implies that business code can be replayed safely.

The app owns pool/client lifetime. withTransaction exposes CommitOutcomeUnknownError when a commit acknowledgment is lost and TransactionRolledBackError when PostgreSQL acknowledges a rollback. The app must reconcile its own domain transaction. registerCorrelation(q, registration) lets an app explicitly include routing metadata in its own transaction.

This breaking beta requires a fresh v6 framework schema. Bootstrap rejects older schemas and never drops data. No journal or lease data conversion is supplied. deleteCase removes framework records only. See the storage contract.