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

@render-lab/tasks-sanity

v0.1.2

Published

Durable Sanity tasks for Render Workflows: sanity.query/getDocument/createDocument/patchDocument/mutate/uploadAsset.

Readme

@render-lab/tasks-sanity

⚠️ Experimental: proof of concept. This package is part of the Render Tasks POC and is published for testing only. It is not fully tested or production ready. Task names, inputs, outputs, and behavior can change or break in any release. Pin exact versions and expect breaking changes.

Durable Sanity tasks for Render Workflows.

import {
  query,
  getDocument,
  getDocuments,
  createDocument,
  patchDocument,
  deleteDocument,
  deleteByQuery,
  mutate,
  uploadAsset,
  deleteAsset,
} from "@render-lab/tasks-sanity";

| Task | Input | Output | | ----------------------- | ----------------------------------------------------------- | ------------------- | | sanity.query | { query, params? } | { result } | | sanity.getDocument | { id } | SanityDocument \| null | | sanity.getDocuments | { ids } | { documents } | | sanity.createDocument | { document, mode? } | SanityDocument | | sanity.patchDocument | { id, set?, setIfMissing?, unset?, inc?, dec?, ifRevisionId? } | SanityDocument | | sanity.deleteDocument | { id } | { deletedIds } | | sanity.deleteByQuery | { query, params? } | { deletedIds } | | sanity.mutate | { mutations } | { transactionId, results } | | sanity.uploadAsset | { assetType, base64, contentType, filename? } | AssetDTO | | sanity.deleteAsset | { id } | { deletedIds } |

A SanityDocument is an open JSON object carrying at least _id and _type; other fields are your content model. AssetDTO is { _id, url, assetType, contentType, size, originalFilename }. Query and multi-get results are byte-bounded against the Render Workflows 4 MB task-result cap before they are returned.

query runs a GROQ query with named $params. getDocument/getDocuments read by id (multi-get preserves order, with null for absent ids). createDocument writes a document — mode is createOrReplace (default, idempotent), createIfNotExists (idempotent), or create (which requires a caller-supplied _id). patchDocument applies a targeted patch. deleteDocument/deleteByQuery remove documents. mutate submits a raw transaction of mutations atomically — the full-fidelity primitive the write tasks wrap. uploadAsset/deleteAsset manage image and file assets.

Idempotency & retries

Reads and idempotent writes (createOrReplace, createIfNotExists, set/setIfMissing/unset patches, deletes, hash-deduped asset uploads) run under SANITY_RETRY and converge on replay. A bare create requires a _id so the write stays identifiable, and inc/dec patches are not idempotent — pass ifRevisionId for optimistic locking where replay-safety matters. mutate inherits the retry-safety of whatever mutations you put in it.

Install

pnpm add @render-lab/tasks-sanity @renderinc/sdk

@renderinc/sdk is a peer dependency. @render-lab/triggers is an optional peer, needed only if you use the webhook adapter. The default port wraps @sanity/client with useCdn: false and maxRetries: 0 (the durable task retry owns retries, ADR-0005).

Environment contract

| Variable | Required | Purpose | | ---------------------- | -------- | ------------------------------------------------------------------------------ | | SANITY_PROJECT_ID | yes | Sanity project id. Read lazily on first API call, never at import. | | SANITY_DATASET | yes | Dataset name (e.g. production). Read lazily on first API call. | | SANITY_API_TOKEN | yes | Token with read+write access (writes and fresh/private reads). Read lazily. | | SANITY_API_VERSION | no | API version date (default v2025-02-19). | | SANITY_WEBHOOK_SECRET| no | Signing secret for the webhook adapter. Read lazily at verify time. |

A missing required var throws a clear error from the task that needs it (fail-close, ADR-0007). Any non-2xx response throws so the durable retry (SANITY_RETRY) is the single source of truth for retries (ADR-0005).

Webhooks

Sanity delivers GROQ-powered webhooks signed with HMAC-SHA256. The adapter lives at a registration-free subpath (ADR-0017) and never calls task() or constructs a client:

import { sanityAdapter } from "@render-lab/tasks-sanity/webhooks";

const adapter = sanityAdapter({
  // secret defaults to SANITY_WEBHOOK_SECRET
  onEvent: ({ payload }) =>
    payload._type === "post"
      ? { task: "content.enrich", args: [{ id: payload._id }] }
      : null,
});

verify checks the sanity-webhook-signature header (t=<ts>,v1=<base64url>, HMAC-SHA256 over `${t}.${rawBody}`) in constant time. map runs your onEvent routing over the projected payload — the body shape is whatever your webhook's GROQ projection emits.

Extending & testing

Every operation exports the wrapped task and its raw *Impl. The impls depend on a small SanityPort interface, so they unit-test without touching the network:

import { patchDocumentImpl, type SanityPort } from "@render-lab/tasks-sanity";

const sanity = { patch: async () => ({ _id: "post_1", _type: "post", title: "New" }) } as SanityPort;
await patchDocumentImpl({ id: "post_1", set: { title: "New" } }, { sanity });

Run the tests with pnpm -C packages/tasks-sanity test.