[ CONVEX COMPONENT · STABLE · MIT ]
@vllnt/convex-metering
Metered usage records — idempotent usage events rolled up per billing period
STABLE 0.1.0 · 2 GitHub stars
Package details
Install
The untagged install gets the latest stable version (0.1.0). The canary tag tracks main (0.1.1-canary.8b4806c).
pnpm add @vllnt/convex-metering
pnpm add @vllnt/convex-metering@canaryRegister the component
Add it to your app’s convex/convex.config.ts, then run npx convex dev to generate the references.
import { defineApp } from "convex/server";
import metering from "@vllnt/convex-metering/convex.config";
const app = defineApp();
app.use(metering);
export default app;Use it
Usage, options and examples are in the package README.
Downloads
- Last 7 days
- 42
- Since first publish
- 3,598
Downloads per week since 17 June 2026, oldest on the left. Weeks count back from 23 November 2026, so the first one may be shorter than seven days.
42 downloads in the last 7 days. 3,598 downloads since 17 June 2026. Source: npm, counted through 23 November 2026.
Show downloads per week as a table
| Week | Downloads |
|---|---|
| 17 June 2026 to 22 June 2026 | 418 |
| 23 June 2026 to 29 June 2026 | 15 |
| 30 June 2026 to 6 July 2026 | 84 |
| 7 July 2026 to 13 July 2026 | 45 |
| 14 July 2026 to 20 July 2026 | 19 |
| 21 July 2026 to 27 July 2026 | 8 |
| 28 July 2026 to 3 August 2026 | 12 |
| 4 August 2026 to 10 August 2026 | 23 |
| 11 August 2026 to 17 August 2026 | 132 |
| 18 August 2026 to 24 August 2026 | 58 |
| 25 August 2026 to 31 August 2026 | 394 |
| 1 September 2026 to 7 September 2026 | 480 |
| 8 September 2026 to 14 September 2026 | 242 |
| 15 September 2026 to 21 September 2026 | 257 |
| 22 September 2026 to 28 September 2026 | 640 |
| 29 September 2026 to 5 October 2026 | 44 |
| 6 October 2026 to 12 October 2026 | 48 |
| 13 October 2026 to 19 October 2026 | 25 |
| 20 October 2026 to 26 October 2026 | 288 |
| 27 October 2026 to 2 November 2026 | 173 |
| 3 November 2026 to 9 November 2026 | 95 |
| 10 November 2026 to 16 November 2026 | 56 |
| 17 November 2026 to 23 November 2026 | 42 |
Release history
Every release on a timeline, oldest on the left. A tall mark with its version is a stable release; a short mark is a canary build. The time axis is the one of the downloads chart, so a release stands above the week it shipped in.
1 stable release and 9 canary builds since 17 June 2026. Latest stable: 0.1.0 on 1 September 2026.
Show every release as a table
| Version | Kind | Published |
|---|---|---|
| 0.1.1-canary.8b4806c | canary | 31 October 2026 |
| 0.1.0 | stable | 1 September 2026 |
| 0.1.0-canary.12576b5 | canary | 1 September 2026 |
| 0.1.0-canary.4c0f067 | canary | 31 August 2026 |
| 0.1.0-canary.d30a2d9 | canary | 31 August 2026 |
| 0.1.0-canary.86ece96 | canary | 31 August 2026 |
| 0.1.0-canary.0c63a9f | canary | 17 June 2026 |
| 0.1.0-canary.1748317 | canary | 17 June 2026 |
| 0.1.0-canary.f3d0963 | canary | 17 June 2026 |
| 0.1.0-canary.a0e1e08 | canary | 17 June 2026 |
Changelog
The newest stable releases of @vllnt/convex-metering, with the notes from its changelog.
0.1.0
Added
- First release of
@vllnt/convex-metering. defineMeterregisters a meter with a per-meter aggregation rule (sum|max|last) and a display unit;recordwrites a usage event and folds it into the(meter, subject, period)rollup on write.- Idempotent recording: passing an
idempotencyKeymakes a retriedrecorda safe no-op ({ recorded: false, reason: "duplicate" }), so at-least-once delivery never double-counts. - Records + rollups split: raw
recordsare the append-only audit trail and idempotency source;rollupsare the O(1) per-period read for billing and limit checks (the billable truth, never pruned). usage/listUsageread a subject's rollups;resetclears one(meter, subject, period).pruneRecordsdeletes raw records older than a requiredbeforecutoff (no default-to-now footgun), bounded and self-rescheduling; rollups are untouched.periodis a host-supplied opaque string — the component never parses dates, keeping it locale- and calendar-agnostic. Scopes namespace meters per tenant; server-sourced timestamps throughout.- Fully typed end to end — quantities, periods, units, and refs are concrete types; no
v.any(). recordrejects a negative or non-finitequantitywithINVALID_QUANTITY, and an undefined meter withMETER_NOT_FOUND.- Optional
@vllnt/convex-metering/reactentry —useUsage(a live usage meter derivingremaining/fraction/exceededfrom an optionallimit) anduseUsageList. ThinuseQuerywrappers over the host's re-exported refs;reactis an optional peer dep; render-tested in jsdom at 100%. adjust— signed corrections (refund/credit/void) onsummeters; appends a reversing record, keeps the rollup equal to the sum of records and never negative (ADJUST_BELOW_ZERO).recordWithLimit— atomic check-and-record against alimit(closes the read-then-write overage race); returnslimit_exceededwithout recording when it would cross.closePeriod+closedon the usage reads — freeze a billed period so a late event can't restate it (record/adjust/recordWithLimitthen throwPERIOD_CLOSED).eraseSubject(GDPR, across all meters/periods),listMeters,listSubjectUsage, andverify(reconcile the rollup against surviving records).resetis now bounded + self-rescheduling (returns a count) andpruneSeenprunes the idempotency ledger. OptionalactorRefon records.
Changed
- Idempotency dedup moved to a dedicated
seentable. A meter's aggregation is now locked once usage exists (AGGREGATION_LOCKED), and anidempotencyKeyon a non-sumgauge is rejected (IDEMPOTENCY_NOT_SUPPORTED). - Treat Convex
_generatedoutput as CLI-owned and expose a dedicated codegen script. - Require
convex@^1.45.0.
Fixed
- Prune-vs-dedup double-count. Dedup previously read the
recordstable thatpruneRecordsdeletes, so a redelivered event after a prune re-counted the billable rollup. Dedup now lives in the separateseenledger (pruned independently viapruneSeen), so pruning audit rows never re-opens a duplicate. The earlier docs ("retried record is a safe no-op", "rollups never touched") implied prune was consequence-free; corrected. - Return
duplicatebefore quota projection for retried limited records, even when later usage would now exceed the supplied limit. - Reject negative or non-finite quota limits and unsafe maintenance batch/cutoff values, preventing stalled self-scheduling loops and oversized transactions.
- First release of
Licence
Released under the MIT licence. The full text is in the source repository.
[ PACKAGE ]
- Stable
- 0.1.0
- Canary
- 0.1.1-canary.8b4806c
- GitHub stars
- 2 GitHub stars
- Licence
- MIT
- Issues
- Open an issue