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

@farthershore/business

v5.3.0

Published

Farther Shore Business-as-Code SDK — declare your software business in TypeScript

Readme

@farthershore/business

Status: 5.3.0

Declare a business in TypeScript with immutable, authentic references. The SDK compiles declarations into deterministic Manifest IR. Billing commerce uses schemaVersion 2: plans compose offerings, usage pricing, funding, and an optional recurring fee. The package version is managed separately by the release process.

pnpm add @farthershore/business
import * as fs from "@farthershore/business";

const usd = fs.usageUnit.usd();
const requests = fs.requests();
const input = fs.measure("input_tokens");
const output = fs.measure("output_tokens");
const tokens = fs.meter("tokens", { measures: [input, output] });
const chat = fs.offering("chat", {
  meter: tokens,
  work: {
    kind: "operation",
    delivered: [input, output],
    outcome: "per_unit",
    lifetimeMs: 120_000,
    actor: "personal",
    cost: "reported",
    unit: usd,
  },
});
const pricing = fs.pricing("model_pricing", {
  offering: chat,
  disclosure: fs.disclosure.transparent,
  source: { kind: "free" },
});
const pack = fs.topUp("add_10_dollars", {
  price: fs.money.usd("10"),
  grants: fs.credits(usd, "10"),
  usage: [chat],
});
const product = fs.plan("pay_as_you_go", {
  grants: [chat],
  usagePricing: [pricing],
  funding: { topUps: [pack] },
  limits: [requests.perMinute(600)],
});
const api = fs.backend("api");
const route = fs.route("POST /v1/chat", { offering: chat, backend: api });
fs.meterRoutes("chat_usage", route, { reports: [tokens] });
export default fs.business({
  billing: { mode: "credits_only", usageUnit: usd },
  plans: [product],
});

Declare the usage unit once: usageUnit.usd() or usageUnit.credits("ai_credits"). A credit unit may declare the name customers see, usageUnit.credits("ai_credits", { display: "AI credits" }); the key stays the unit, so changing only display never changes a balance. Single costs, grants and top-ups accept at most nine whole and nine fractional digits (maximum 999999999.999999999), keeping each stored amount within int8 sub-units. Rates and grants use exact decimal amounts created with credits(unit, "100"); money.usd is reserved for plan and top-up prices. Numeric money inputs must be safe integers; decimal prices use strings.

A plan grants offerings and/or frontend integration refs, in any order. Frontend integration grants provide access only: they have no usage, charges, pricing, funding, or membership requirement. Each granted metered offering needs exactly one pricing family. A family uses a catalog with timing: "billing_period", or explicit source: { kind: "free" }. Free families have no timing. Usage paid call by call from a balance, stopping at zero, is the offering's work.cost: declared (cost: credits(unit, "2")) or reported (cost: "reported", unit, with the backend reporting unitsConsumed). The platform never derives a call's cost from catalog rates; an admission-timed catalog is refused (ADMISSION_PRICING_REQUIRES_OFFERING_COST). A costed offering needs included grants or top-ups, and its family is free: a plan that also prices it with a billing_period catalog would charge it twice and is refused (OFFERING_PRICED_TWICE). rate.graduated is the tiered pricing form.

billing.mode is explicit: periodic allows recurring fees and billing-period usage, while credits_only has no recurring fee, billing-period usage, trial, or membership-period grants. An omitted price means no fee. Whether a plan has a billing period is decided per plan: a Free plan is monthly in either mode, and a no-fee plan whose usage is paid through per-call costs has none in either mode. lifecycle.trialDays defers the recurring fee and therefore requires one.

Use included(amount, { cadence: "membership_period", usage: [offering] }) for an allowance, or cadence once for a one-time grant. A top-up uses grants and usage; purchased funds have fixed terms. There are no authored monetary caps, reservation estimates, reporting-grace knobs, or overage policies.

Metering remains measure / dimension / meter → meterRoutes → pricing → plan grants. Every route names its offering with route(path, { offering, backend }), including routes for pure access. Use meterRoutes to attach metering and bounds; the route offering must name the same commercial meter. Backends report measurements through ctx.report. Work requires lifetimeMs between 1 and 21,600,000, inclusive.

Declare all components before default-exporting fs.business(). It seals the registry. Forged references, cross-registry references, duplicate stable keys, and late declarations reject. The same unchanged program lowers and hashes identically across runs. canonicalIrJson and hashIr expose that wire boundary. ManifestIssue reports code, dotted path, message, and correction.

Complete programs and canonical fixture artifacts live under docs/superpowers/specs/fixtures/billing-components-golden/ in the monorepo.

Pass plans: [yourPlan] to business() to check literal plan, pricing, and usage-unit compatibility in TypeScript. Dynamic configuration and plans discovered through the registry receive the same checks at runtime.