@contractspec/lib.metering
v3.7.17
Published
Usage metering and billing core module for ContractSpec applications
Downloads
6,838
Maintainers
Readme
@contractspec/lib.metering
Website: https://contractspec.io
Usage metering and billing core module for ContractSpec applications.
What It Provides
- Layer: lib.
- Consumers: bundles.
src/contracts/contains contract specs, operations, entities, and registry exports.src/docs/contains docblocks and documentation-facing exports.src/contracts/contains contract specs, operations, entities, and registry exports.src/docs/contains docblocks and documentation-facing exports.
Installation
npm install @contractspec/lib.metering
or
bun add @contractspec/lib.metering
Usage
Import the root entrypoint from @contractspec/lib.metering, or choose a documented subpath when you only need one part of the package surface.
Architecture
src/aggregationis part of the package's public or composition surface.src/analyticsis part of the package's public or composition surface.src/contracts/contains contract specs, operations, entities, and registry exports.src/docs/contains docblocks and documentation-facing exports.src/entities/contains domain entities and value objects.src/events.tsis package-level event definitions.src/index.tsis the root public barrel and package entrypoint.
Public Entry Points
- Export
.resolves through./src/index.ts. - Export
./aggregationresolves through./src/aggregation/index.ts. - Export
./analytics/posthog-meteringresolves through./src/analytics/posthog-metering.ts. - Export
./analytics/posthog-metering-readerresolves through./src/analytics/posthog-metering-reader.ts. - Export
./contractsresolves through./src/contracts/index.ts. - Export
./docsresolves through./src/docs/index.ts. - Export
./docs/metering.docblockresolves through./src/docs/metering.docblock.ts. - Export
./entitiesresolves through./src/entities/index.ts. - Export
./eventsresolves through./src/events.ts. - Export
./metering.capabilityresolves through./src/metering.capability.ts. - The package publishes 11 total export subpaths; keep docs aligned with
package.json.
Local Commands
bun run dev— contractspec-bun-build devbun run build— bun run prebuild && bun run build:bundle && bun run build:typesbun run lint— bun lint:fixbun run lint:check— biome check .bun run lint:fix— biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .bun run typecheck— tsc --noEmitbun run publish:pkg— bun publish --tolerate-republish --ignore-scripts --verbosebun run publish:pkg:canary— bun publish:pkg --tag canarybun run clean— rimraf dist .turbobun run build:bundle— contractspec-bun-build transpilebun run build:types— contractspec-bun-build typesbun run prebuild— contractspec-bun-build prebuild
Recent Updates
- Replace eslint+prettier by biomejs to optimize speed.
- Stability.
- Resolve lint, build, and type errors across nine packages.
- Add AI provider ranking system with ranking-driven model selection.
Notes
- Aggregation logic must stay deterministic — non-determinism causes billing discrepancies.
- Billing-related schemas are compliance-sensitive; changes require review.
- Capability contract (
metering.capability) is public API — treat as a breaking-change surface.
