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

@pathscale/payment-charter-dsl

v0.1.1

Published

TypeScript types, JSON Schema and canonical-text emitter for the Payment Charter DSL

Readme

payment-charter-dsl-ts

TypeScript types, the JSON Schema, and the canonical-text emitter for the Payment Charter DSL.

import { emit, type Charter } from "@pathscale/payment-charter-dsl";

const text = emit(charter);   // the canonical text form, byte-exact (spec §1.2)

Zero runtime dependencies, and none are coming

  • No date library. Dates are YYYY-MM-DD strings and timezones are UTC±HH:MM strings (§2.9). There are no IANA zone names and no daylight saving, so there is nothing for Temporal or date-fns to do.
  • No bignum. Money is a decimal string carrying the digits the author wrote, at the asset's scale, so emission is padding rather than arithmetic. No BigInt, no Number, and no opportunity for a floating-point answer in the one field where a silently wrong value is a wrong payment.
  • No validator. The backend parses what this emits, so it is already the validator. ajv in the browser would duplicate it and disagree with it.
  • No parser. See below.

Why money is a string

§2.6 caps assets at nine decimals, which keeps money inside u64 — and not inside 2^53. A nine-decimal asset crosses 9007199254740992 minor units at about nine million tokens, which is a limit somebody will write. JSON numbers are IEEE-754 doubles wherever JavaScript reads them, and JCS (RFC 8785), which §12 signs over, defines number serialisation in exactly those terms.

As a number the rule would be "a JSON number, except above nine million tokens of a nine-decimal asset, or nine billion of a six-decimal one". As a string it is one sentence.

What is here and what is not

Emitter. The browser builds a typed charter object and has to render it as text so a controller can read, download and diff the thing they are about to authorise. A charter that can only be inspected as JSON is a charter nobody reviews.

No parser, deliberately. Emitting is mechanical; parsing carries the whole error catalogue (E1xx–E5xx), the overlap analysis and the resolver checks — a second full implementation of the expensive half. Pasted charter text goes to the backend, and a controller pastes one rarely. It comes last and only if it is measured cheap; if it is not, it does not get built, and that is not a gap.

No WASM. Considered and rejected. It would have deleted the drift risk by having one emitter, but once money became a string the emitter needed no arithmetic and no dependencies — a few hundred lines of sorting and string building against 150–400KB of wasm and a bundler integration. Revisit only if the parser is wanted in-browser.

How it is verified

The emitter has no conformance suite of its own. It round-trips through the Rust parser instead:

bun test          # unit tests, plus tests/roundtrip.test.ts against payment-charter-dsl-rs

roundtrip.test.ts emits each fixture and feeds it to charter-parse from the Rust repo. Two independent implementations of one language drift unless something compares them; that file is the something. It skips loudly rather than quietly when the Rust binary is absent, because a cross-implementation test that silently becomes a no-op still reports green.

Consuming it

Built for pays.online — SolidJS, rsbuild, bun. charter.schema.json is the shared normative artifact; generate types from it with json-schema-to-typescript (already in that project's toolchain) rather than hand-maintaining a second description of the wire format.

Licence

Dual Apache-2.0 / MIT, at your option.