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

@sanity-labs/workflow-engine-explore-test-client

v0.1.2

Published

An in-memory fake of `@sanity/client` for local testing. Implements the data-plane subset (queries, mutations, transactions) against a [groq-js](https://github.com/sanity-io/groq-js) evaluator and a closure-scoped document store. Created fresh per test —

Readme

@sanity-labs/workflow-engine-explore-test-client

An in-memory fake of @sanity/client for local testing. Implements the data-plane subset (queries, mutations, transactions) against a groq-js evaluator and a closure-scoped document store. Created fresh per test — no global state, no network.

Status: 0.x POC. Useful standalone for testing any code that takes a SanityClient-shaped dep, even outside the workflow engine.

npm install -D @sanity-labs/workflow-engine-explore-test-client

Quickstart

import { createTestClient } from "@sanity-labs/workflow-engine-explore-test-client";

const client = createTestClient({
  documents: [
    { _id: "article-1", _type: "article", title: "Hello", state: "draft" },
    { _id: "article-2", _type: "article", title: "World", state: "approved" },
  ],
});

// fetch — GROQ via groq-js against the in-memory store
const approved = await client.fetch<{ _id: string }[]>(
  `*[_type == "article" && state == $s]{_id}`,
  { s: "approved" },
);
// → [{ _id: "article-2" }]

// getDocument — single-doc lookup
const doc = await client.getDocument("article-1");

// patch + commit
await client.patch("article-1").set({ state: "approved" }).commit();

// createOrReplace — upsert
await client.createOrReplace({ _id: "article-3", _type: "article", title: "New" });

// transaction — atomic batch
await client.transaction()
  .patch("article-1", (p) => p.set({ reviewedBy: "alice" }))
  .patch("article-2", (p) => p.set({ reviewedBy: "alice" }))
  .commit();

What it implements

The methods relevant to anything that talks to the Sanity data plane match @sanity/client's signatures:

  • fetch(query, params?) — GROQ via groq-js
  • getDocument(id) / getDocuments(ids)
  • create(doc) / createOrReplace(doc) / createIfNotExists(doc)
  • delete(id)
  • patch(id) → chain of .set / .setIfMissing / .unset / .inc / .dec / .append / .prepend / .insert / etc. → .commit()
  • transaction() → fluent batch of operations → .commit() (atomic)
  • action({ actionType, … }) — supports a small subset (used by the engine's sanity.release.publish effect handler)

What it intentionally does not implement:

  • listen (real-time subscriptions)
  • Asset uploads
  • Project actions, agent actions
  • Perspectives (drafts, published, raw) — all docs are visible at all times
  • HTTP request() — the workflow engine's permission resolver short-circuits when this is absent (graceful skip of the ACL gate)

If you need one of the above for a real-looking test, vendor in a stub or use MSW for HTTP intercepts.


Design constraints

  • Closure-scoped isolation. createTestClient({ documents }) returns a client whose store is local to that closure. Two clients created in two tests do not see each other's writes. Pass the same client to two consumers if they need to share a store (e.g. multi-tenant scope tests in the engine bench).
  • Drop-in shape. The methods listed above accept the same arg shapes as @sanity/client, so any code typed against SanityClient (or a narrow subset) can take a TestClient without an adapter. Compatibility is structural, not nominal.
  • groq-js directly. Same GROQ evaluator the engine uses, against the in-memory document set. What groq-js supports, this supports. What it doesn't (some && short-circuit edge cases, custom functions), this doesn't either.

Reading the store directly

client.snapshot() returns the raw document array. Useful for assertions:

const docs = client.snapshot();
expect(docs.find((d) => d._id === "article-1")?.state).toBe("approved");

For workflow-engine tests specifically, prefer the bench read helpers (bench.getInstance, bench.currentStage, etc.) — they apply the engine's tag scoping. client.snapshot() does not.


License

UNLICENSED — internal Sanity labs exploration.