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

@zvndev/powdb-sync

v0.28.0

Published

Embedded PowDB sync orchestration for local reads and primary-authoritative write-forward.

Readme

@zvndev/powdb-sync

Experimental embedded-sync orchestration for PowDB.

This package is the experimental V1 control-loop boundary for the Turso-style PowDB variant: local embedded reads, remote-primary writes, and sync-down retained WAL chunks.

It composes two lower-level packages:

  • @zvndev/powdb-embedded for local readonly queries,
  • @zvndev/powdb-client for authenticated primary sync frames and writes.

Both are optional peer dependencies, so installing this package alone gets you the control loop and nothing to run it against. Install all three, pinned to the same version:

npm install @zvndev/powdb-sync @zvndev/powdb-client @zvndev/powdb-embedded

This package is ESM only: it publishes an import condition and no CJS build, so require("@zvndev/powdb-sync") does not resolve. Use import, or await import(...) from CommonJS. @zvndev/powdb-client ships both.

The native retained-unit apply binding is exposed by @zvndev/powdb-embedded as Database.applyRetainedUnits(...). Pass that method through the local adapter. The native binding accepts the same databaseId forms as this package's SyncIdentity: a 32-character hex string or a 16-byte Uint8Array. The constructor validates that the local and remote adapters expose the required methods before any sync work starts.

import { PowDBSyncReplica, SUPPORTED_CATALOG_VERSION } from "@zvndev/powdb-sync";
import { Client } from "@zvndev/powdb-client";
import { Database } from "@zvndev/powdb-embedded";

const local = Database.open("./replica");
const remote = await Client.connect({
  host: "127.0.0.1",
  port: 5433,
  user: "replica",
  password: process.env.POWDB_PASSWORD,
});

const replica = new PowDBSyncReplica({
  replicaId: "device-1",
  identity: {
    databaseId: "00112233445566778899aabbccddeeff",
    primaryGeneration: 1n,
    walFormatVersion: 1,
    catalogVersion: SUPPORTED_CATALOG_VERSION,
    segmentFormatVersion: 1,
  },
  local: {
    queryReadonly: (query) => local.queryReadonly(query),
    applyRetainedUnits: (request) => local.applyRetainedUnits(request),
  },
  remote,
});

await replica.syncNow();
const syncLoop = replica.startBackgroundSync({
  intervalMs: 5_000,
  onError: (err) => console.warn("sync lag/error", err.code, err.message),
});
const rows = await replica.queryReadonly("User { .id, .name }");
syncLoop.stop();

V1 Contract

  • queryReadonly(...) reads the embedded replica and can be stale.
  • syncNow() pulls bounded retained-unit chunks from the primary, applies them locally, then acknowledges only after local apply succeeds.
  • startBackgroundSync(...) schedules syncNow() without overlapping runs. Use it for online catch-up; keep explicit syncNow() for deterministic read-after-sync points.
  • write(...) sends DML to the primary. It does not queue offline writes.
  • DDL through write(...) is rejected with ddl_not_supported.
  • If a remote write may have committed but the response was lost, write(...) throws commit_outcome_unknown. The package does not retry non-idempotent writes silently.
  • WriteResult.localVisible is true only when a local read is guaranteed to include the committed remote write. If local retained-unit apply succeeds but primary acknowledgement fails, localVisibility is applied_but_unacked and the result includes the applied and remote LSNs.

Status

This package is experimental. The four PowDB JS packages and the server are released together from one repository and share a version number, so pin @zvndev/powdb-sync, @zvndev/powdb-client, @zvndev/powdb-embedded, and the server to the same version while dogfooding. SUPPORTED_CATALOG_VERSION is the one compatibility number that is checked at runtime: a primary whose catalog format is newer than this package supports is rejected rather than silently mis-read.

The control loop is unit-tested with structural adapters, including background sync scheduling. test:native exercises PowDBSyncReplica.write(...) through the real @zvndev/powdb-embedded local adapter with a deterministic fake primary. test:e2e combines powdb-cli sync-enable, full backup, powdb-server, @zvndev/powdb-client, powdb-cli sync-bootstrap, native local readonly queries, and retained-unit apply in one flow. CI now runs the current JS sync vertical slice. Public beta still needs broader stale/rebootstrap, DDL-policy, crash/interruption, idempotency, metrics, and package release coverage.

Development

pnpm install
pnpm run build
pnpm test
# Requires the local embedded addon to be built first:
#   cd ../../bindings/node && npm run build
pnpm run test:native
pnpm run test:e2e

test:native and test:e2e resolve the embedded addon in this order: POWDB_SYNC_NATIVE_EMBEDDED_ENTRY, installed @zvndev/powdb-embedded, then the repo-local bindings/node build artifact. The repo-local fallback is used only when the package is not installed; an installed package that fails to load still fails the test.

Links

License

MIT