Contents

API reference

The entry points: which import path holds what, each linked to its complete rendered surface on the generated reference.

A map of the import paths you reach the library through. Every path links to the full generated listing of what it exports.

Source package.jsonsrc/index.ts

The library ships a curated, faceted exports map: the main package carries the day-to-day surface, and each subpath is a focused entry point. Install it, then import from whichever one you need.

npm install @pwngh/economy-lab
import { createEconomy, topUp, toAmount } from '@pwngh/economy-lab';
import type { Store } from '@pwngh/economy-lab/ports';

Entry points

Each import path links to its complete rendered surface — every export, with its signature, contract, and examples — on the generated reference.

ImportWhat it holds
@pwngh/economy-labConstruction, operations, money, the ledger, outcomes, and the principal types.
@pwngh/economy-lab/portsThe port interfaces you implement to plug in your own infrastructure.
@pwngh/economy-lab/adaptersThe bundled in-memory and HTTP adapters, plus the runtime services.
@pwngh/economy-lab/adapters/redisThe Redis-backed Cache and RateLimiter; adapts an ioredis client you connect.
@pwngh/economy-lab/adapters/sqsThe SQS-backed Dispatcher; adapts an SQS client you connect.
@pwngh/economy-lab/engines/postgresThe Postgres Store (carries pg).
@pwngh/economy-lab/engines/mysqlThe MySQL Store and schema helpers (carries mysql2).
@pwngh/economy-lab/engines/mysql-mariadbThe pipelining-capable MySQL pool (carries mariadb); an opt-in behind the same store.
@pwngh/economy-lab/workerThe full background-worker surface: the sweeps, the relay and drain, and the feeds.
@pwngh/economy-lab/serverThe full HTTP surface: the server internals and the webhook intake.
@pwngh/economy-lab/nettingThe in-instance netting session.
@pwngh/economy-lab/opsThe in-process operations supervisor: signal capture, incident detectors, guarded remediations, and the audit trail.
@pwngh/economy-lab/store-kitThe primitives a custom Store implementation computes with.
@pwngh/economy-lab/testingThe conformance harness for testing your own adapters.

How the surface is split

The principal ports types are also re-exported from the main package; everything else lives only on its subpath. The driver-carrying entry points load a database driver, so they are imported only where that driver is installed: the engines carry pg, mysql2, and mariadb. The Redis and SQS adapters instead adapt an already-connected client you pass in, so they load with nothing installed.

The MariaDB entry point is an opt-in behind the same MysqlPool seam the MySQL store rides — same store, same schema, same SQL; only the wire protocol changes. See the storage port.

The worker and server constructors and their types are re-exported from the main entry; their subpaths add the internals — the sweep names and batch shapes, the wire codec and webhook intake.

The ops supervisor is an in-process library the core never imports; leaving it out of the composition is the off switch. It observes only through the meter and logger ports and remediates through host-provided levers under mandatory guardrails. Ops & runbooks owns the operational story.

store-kit and testing are a pair: the conformance suite is the public invitation to bring your own Store, and store-kit holds the primitives a conforming implementation computes with — the same chain hashes, balance deltas, orderings, and wire encodings the built-in engines compute.

See also