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

@fluojs/persistence

v0.1.0

Published

Portable transaction boundary contracts and composable persistence policy primitives for Fluo.

Readme

@fluojs/persistence

ORM-independent transaction boundary contracts and composable policy primitives. This package does not create connections, sessions, ALS, or native transactions. The transaction context contract owns shared transaction semantics.

Installation

pnpm add @fluojs/persistence

There are no core, runtime, HTTP, diagnostics, ORM, or driver dependencies or eager Node builtins. These portable primitives declare no package-wide engines.node and do not broaden concrete ORM host or driver support.

Public API

| Export | Contract | | --- | --- | | AfterCommitCallback | Post-commit work typed as () => void \| Promise<void> | | TransactionBoundaryOptions<T> | Optional requireAfterCommit and application-owned shouldRollback(value) | | AfterCommitCapabilityError, AfterCommitError | Missing native commit capability and post-commit hook failure; the latter preserves committed=true and all FIFO results | | TransactionRollbackCapabilityError, TransactionRollbackOnlyError, TransactionRollbackUnconfirmedError | Missing capability, the first nested failure's result, and missing positive native rollback confirmation | | TransactionRollbackObservation, TransactionRollbackObserver | Positive confirmRollback(), run(callback), and beginAttempt(transaction, connection?) | | RequestAbortContext, ActiveRequestTransaction, ActiveRequestTransactionHandle | Caller signal forwarding and owner-local active-work settlement | | createRequestAbortContext, trackActiveRequestTransaction, untrackActiveRequestTransaction | Abort forwarding preserving reason identity, listener cleanup, set registration/removal and promise settlement |

@fluojs/persistence/internal provides ResultBoundary, RollbackOwner, evaluateResult, observeRollback, and settleAfterCommitCallbacks for first-party ORM composition. Application transaction execution APIs remain in each ORM package.

Usage example

This service fragment assumes an existing Prisma wrapper. Follow the Prisma API for concrete client and rollback observer registration.

import type { TransactionBoundaryOptions } from '@fluojs/persistence';

type PublishResult = { readonly ok: boolean };
const boundary: TransactionBoundaryOptions<PublishResult> = {
  requireAfterCommit: true,
  shouldRollback: (result) => !result.ok,
};

This boundary is the last Prisma/Drizzle argument. Mongoose accepts transaction(fn, boundary) or requestTransaction(fn, signal, boundary) without a native-options argument. Callback/return typing and native option positions do not change.

Defaults and ownership

Both options are omitted by default. Failure-shaped values never imply rollback. When a predicate rejects a value, the nested owner keeps its first failure sticky rollback-only. Recovering a root failure requires both its exact owner signal and positive native rollback confirmation. Native commit, rollback, and cleanup errors propagate with their original identity.

After-commit registration is synchronous within the same open native callback scope. After successful outer commit and associated cleanup settlement, every hook is awaited FIFO outside ended ALS. Rollback, failed commit, and discarded retry attempts never run their hooks. Hook failures do not undo commit or trigger native retry.

ORM packages own native observers, callback attempt lifetimes, connections/sessions, shutdown admission and drain. The Mongoose observer's connection? supplies session-owning connection context; AfterCommitCleanupError remains a Mongoose-owned direct AggregateError subclass. Drizzle status activity lifetime stays separate from shutdown settlement. No new savepoints, retry, durability, outbox, exactly-once, or DB+Redis atomicity is provided.

Existing import compatibility

Existing core and ORM root common errors and boundary types directly re-export this package's originals. Constructor equality and instanceof remain intact for the same dependency instance. Runtime root request-transaction helpers remain re-exported. The migration guide describes an optional canonical import transition. Compatible-copy recognition does not merge wrapper transaction state.

Verification evidence

src/result-rollback.test.ts, src/request-transaction.test.ts, and src/after-commit.test.ts exercise shared primitives. tooling/governance/after-commit-contract.test.ts compares canonical and existing root constructor identity. The native fixture owns real database observations. Listing targets or commands is not a claim of passing execution; inspect each run's logs and receipt.