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

@baukit/data-contracts-dexie

v0.3.0

Published

Dexie 4.x implementation of @baukit/data-contracts for web applications.

Downloads

141

Readme

@baukit/data-contracts-dexie

A product-neutral Dexie 4.x implementation of @baukit/data-contracts for web applications that need key/value data, ID-ordered records, portable schema metadata, and compound write transactions.

import { openDexieStore } from '@baukit/data-contracts-dexie';

interface CachedRecord {
  readonly id: string;
  readonly value: string;
}

const storage = await openDexieStore<CachedRecord>('product-cache');
await storage.withTransaction(async (transaction) => {
  await transaction.records.put({ id: 'record-1', value: 'local' });
  await transaction.keyValues.set('outbox:mutation-1', {
    entityId: 'record-1',
    operation: 'put',
  });
});
await storage.close();

The package owns three generic IndexedDB object stores. It does not define product tables, entity relationships, soft-delete behavior, revisions, sync protocols, or database naming policy.

Authenticated products should resolve an opaque name with @baukit/data-contracts before calling openDexieStore. The fake-IndexedDB and Chromium/WebKit suites run the shared offline E→F→E identity-transition cases in addition to the transaction contract.

Transaction model

Nested transactions explicitly join the ambient transaction when they are started through the callback's transaction-scoped context:

await storage.withTransaction((transaction) =>
  transaction.withTransaction((sameTransaction) => sameTransaction.records.put(record)),
);

Compose transactional repositories from that scoped context. A call on the root storage object is an independent transaction and is serialized behind transactions that already started. Transaction contexts must not be retained after their callback ends.

Prepare network, native, crypto, filesystem, or other external promise results before opening a write transaction. Dexie tracks its own promise zone, but an unrelated promise layer can let the browser's IndexedDB request queue drain and auto-commit early. Keep the callback limited to the complete local write set.

Do not blanket-ignore Dexie's PrematureCommitError. That error can mean the browser committed only an early subset of the intended writes. Treating it as success without proof can silently split a compound operation. Acceptance tests must observe every intended write, the matching outbox entry, and full rollback when any step fails.

Quota failures surface as StorageError with code storage_quota_exceeded. After close() resolves, operations fail with code storage_closed.

Verification

pnpm test uses fake-indexeddb and stays fast. The browser suite is a separate Chromium and WebKit gate. Install browsers into a repository-local cache and run it from the repository root:

PLAYWRIGHT_BROWSERS_PATH="$PWD/typescript/.playwright-browsers" \
  corepack pnpm --dir typescript --filter @baukit/data-contracts-dexie \
  exec playwright install --with-deps chromium webkit
PLAYWRIGHT_BROWSERS_PATH="$PWD/typescript/.playwright-browsers" \
  corepack pnpm --dir typescript --filter @baukit/data-contracts-dexie \
  run test:browser

Run corepack pnpm --dir typescript run check for the normal workspace gate. The package-local check script also includes the browser suite and therefore expects the two browser binaries to be installed. CI should add the same repository-local browser install and test:browser commands as a distinct step; the workspace's ordinary test task intentionally remains fast.