Shared primitives and flow helpers for transaction-oriented services (transaction-manager, payment-orchestrator, settlement).
What’s inside#
TransactionStatusconstants and a guardnextStateto enforce valid transitions.buildTransactionId(prefix?)to generate idempotent-friendly IDs.validateTransferRequestto flag missing transfer fields (from,to,amount).
Usage#
js
const { TransactionStatus, nextState, buildTransactionId } = require('@lilith/transaction-core');
const id = buildTransactionId('payment');
let state = TransactionStatus.PENDING;
state = nextState(state, TransactionStatus.PREPARING);
Notes#
- Keep helpers small and composable; this library is a convenience layer, not a framework.
- Extend with additional validators or metrics wrappers as other transaction services converge on shared patterns.