@triplebooks/ledger-packs
v0.9.1
Published
Open-source TripleBooks ledger posting rule packs (DSL) and content-hashed manifest
Readme
@triplebooks/ledger-packs
Open-source TripleBooks ledger posting rule packs — DSL posting rules, content hashing, and a committed manifest.
This package is data + hashing only. It does not apply rules to a database or evaluate the DSL. The TripleBooks platform (and any other host) loads pack dslSource strings and evaluates them with its own ledger engine against a chart-of-accounts role map.
Install
npm install @triplebooks/ledger-packs
# or
pnpm add @triplebooks/ledger-packsWhat's included
| Layer | Examples |
| ----- | -------- |
| KERNEL | Core plumbing |
| STANDARD | GAAP accrual, tax cash, management, fund events, personal finance, trust |
| INDUSTRY | Real estate, construction, retail, manufacturing, SaaS, healthcare, … |
| MODULE | Inventory, projects, manufacturing WIP, fleet, cap table, lending, … |
Each pack exports a stable slug and rules[] (LedgerRuleSeed). getLedgerPackDefinitions() attaches a deterministic contentHash per pack. The committed ledger-packs.json hashes the ordered pack set for apply idempotency.
Quick use
import {
getLedgerPackDefinitions,
loadBundledLedgerPacksManifest,
hashPackDefinition,
} from "@triplebooks/ledger-packs";
const packs = getLedgerPackDefinitions();
const manifest = loadBundledLedgerPacksManifest();
// Apply `packs` + `manifest` with your own persistence layer.Pack format
type LedgerRuleSeed = {
name: string;
eventType: string;
basis?: string | null;
priority?: number;
postingTemplate: Record<string, unknown>;
dslSource: string; // Ledger DSL `rule "…" { on "event" … post { … } }`
};DSL account("role.path") references chart-of-accounts roles (not GL account IDs). Hosts must resolve roles to accounts before posting. Event type slugs and payload keys are a de facto contract — bump pack versions when they change.
Develop
pnpm install
pnpm test
pnpm build:manifest # regenerate ledger-packs.json + history/
pnpm check:manifest # CI gateAfter editing any file under src/packs/, src/registry.ts, or src/pack-meta.ts, run pnpm build:manifest and commit ledger-packs.json (and history/ if a new snapshot was written).
License
Apache License 2.0 — see LICENSE.
Relationship to TripleBooks platform
In the TripleBooks monorepo, @triplebooks/ledger-bundle (private) depends on this package, adds private platform-only packs (e.g. SaaS billing), and applies the shipped bundle into tenant databases. This public package intentionally has no database or control-plane dependencies.
