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

@nodii/usage

v0.5.0

Published

STOP check, metering and one usage-metered event payload for every Nodii service that calls a paid provider (S08-39). Generated from usage-kinds.json. Polyglot ship: TS + Python + Go.

Readme

@nodii/usage

The STOP check, the meter and the one usage-metered payload (S08-39). A producer never holds a price and never names a payer.

const usage = defineUsage({ sourceService, topicPrefix, outboxTable, platformTenantId, pool, sliceKeys, projectionReady });

const stop = await usage.checkStop(tenantId, "geo.geocode_lookup.google");
if (stop.status !== "allowed") return refuse(stop);

await usage.meter(tx, {
  usageKey: "geo.geocode_lookup.google",
  tenantId,
  provider: "google",
  quantity: 1,
  idempotencyId: lookupId,
  occurredAt,
});
  • checkStop returns allowed, stopped or unavailable. Treat unavailable as a refusal: retry a transactional send later and suppress a broadcast (NOT-OPS-5).
  • sliceKeys lists the keys this service spends on. Asking about any other key returns unavailable.
  • projectionReady must be true only after the snapshot has drained. A tenant with no row was never denied, but only a drained projection can say so.
  • applyUsageDenial is the one apply function. Pass the SetUsageControl RPC through it; defineUsageDenialReplica passes the event and the snapshot through it. The highest source version wins (NOT-OPS-6).
  • meter names the provider actually used (S08-20). A message unit takes its kind, sender and channel, and its payer and charge class follow from them. Any other unit is free only when it names a registered free rule (S08-19).
  • platformTenantId is required, and defineUsage throws missing_fact unless it is PLATFORM_TENANT_ID (ENTA-37). A unit with no message object whose tenantId is the Platform tenant meters with payer platform, charge class free:platform_own and ₹0 (S08-2.1), whatever its key, even if it names a free rule. A unit with a message object keeps the payer and charge class from @nodii/notify (S08-2). checkStop treats the Platform tenant like any other. No caller can name that class: platform_own is not a registered free rule.
  • A free unit carries amount_minor: 0. A billable unit carries no money: only tenant-service rates (S08-21).

Run getUsageMigrationSQL() in the service's migrations. Usage keys come from registries/usage-kinds.json, which holds keys and never prices (S08-41).

Known limit: widening the slice

The projection stores only the denials inside the service's slice, and one version of a tenant's denials is applied once. A service that adds a key to its slice therefore reads that key as allowed, for a tenant already denied on it, until tenant-service emits that tenant's next version. A redelivery or a snapshot of the same version does not rewrite the row. Because the digest covers only the slice (so the SetUsageControl RPC, which carries only the target's slice, and the event, which carries every denial, agree at one version), a same-version redelivery that the wider slice now sees more of is read as a payload mismatch and quarantined, and so is every later replay of that version; the row is unchanged, and the tenant's next version applies normally. The fix is an open question on STANDARDIZATIONS-AUDIT-19.

Upgrading from 0.2.0

Rows written before this release hold a digest of the whole message, while this release digests only the slice. Run the one-time repair once, as its own migration, after the rollout: getUsageDigestRepairSQL() returns an idempotent UPDATE that rewrites every row's digest from its stored denials (P-16). Without it, a tenant whose stored row came from a message with a denial outside the slice has every same-version replay quarantined as a payload mismatch until its next version; the stored denials stay correct either way. The repair rebuilds each digest from the row's stored denials, which are the slice the service used when the row was written. It assumes the slice has not changed since: if the service has narrowed its slice, a same-version replay still mismatches and is quarantined until the tenant's next version. Run it once the rollout has finished and no 0.2.0 consumer is still applying (a 0.2.0 pod that writes after the repair puts a whole-message digest back; the repair is idempotent, so re-running it after the rollout is safe). Run it as the table owner or nodii_owner, as migrations are: the projection has RLS, and a service role with no tenant set sees no rows, so the UPDATE would touch nothing. Check that the affected row count equals the table's row count.