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

@dainamite/billing

v0.17.0

Published

Dainamite Billing — lightweight recurring-billing engine for Open Mercato (Bill Runs, one-time / recurring / usage items, draft invoices in core/sales with human approval).

Readme

@dainamite/billing

Lightweight recurring-billing engine for Open Mercato applications.

Collects items to charge (one_time, recurring, usage), runs a scheduled Bill Run that calculates totals and produces draft invoices in @open-mercato/core/sales, and waits for human approval before posting. It does not replace your accounting system — it prepares billing data and hands drafts to a human.

Status

Built — publishing soon. Schema, ACL, tenant setup, the Bill Run engine, usage rating, the full admin UI, and the @dainamite/cpq-billing-connector companion are all in place. The package is not yet on npm; until it publishes it is available inside the dainamite-core monorepo.

See specs/implementation/xd-249-billing-spec.md for the full implementation plan.

What's inside

  • Billing Items — the charge backlog (one_time, recurring, usage), each scoped to a Billing Account with a bill start/end window.
  • Bill Runs — a background worker (@open-mercato/queue) that, on a schedule or on demand, rates usage, sums the due items for the period, and writes draft invoices into @open-mercato/core/sales. Runs are idempotent and tenant-locked; stale runs are reaped by a worker.
  • Draft invoice approval — invoices land in draft; a human reviews and posts them (a guarded ACL action) before they leave draft.
  • Usage rating — metered items are rated at run time from ingested usage.
  • Admin UI under /backend/billing/* — Accounts, Items, Bill Runs, Invoices (list + detail pages).
  • Commands for every write (accounts / items / runs / invoices / usage), validated with Zod.

Installation

@dainamite/billing is an Open Mercato module. Install it and register it in your host app's src/modules.ts:

yarn mercato module add @dainamite/billing   # installs + registers (once published to npm)
# …or: yarn add @dainamite/billing  then add { id: 'billing', from: '@dainamite/billing' }
yarn generate
yarn mercato db migrate

Required Open Mercato modules

sales (draft invoices are written there), @open-mercato/queue (Bill Run worker), and @open-mercato/events (lifecycle events consumed by the connector). Engines: Node ≥ 24.

CPQ integration

To bill subscriptions sold through CPQ, add @dainamite/cpq-billing-connector — it subscribes to CPQ subscription lifecycle events and creates/updates Billing Accounts and Items automatically. Register it after both cpq and billing.

Distribution rules (per SPEC-001)

  • peerDependencies, never dependencies for @open-mercato/* and sibling @dainamite/* — one shared instance in node_modules.
  • No ORM relations across packages — cross-module references are FK strings; draft invoices are created through the sales service / events, not a direct relation.
  • Ships its own migrations under src/modules/billing/migrations/.
  • Ships src/ (types) + dist/ (runtime JS); no .d.ts emitted.

License

MIT.