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

@santati/node

v0.3.0

Published

Official TypeScript SDK for the Santati audit-log API

Readme

@santati/node

The official TypeScript SDK for the Santati audit-log API: emit events (one or a batch) with generated idempotency keys and retries, and read them back with cursor pagination. Node 22+, ESM only, no runtime dependencies.

Install

npm install @santati/node

Quickstart

import { Santati } from "@santati/node";

const santati = new Santati({
  apiKey: process.env.SANTATI_API_KEY!, // sat_sk_…
  trail: "billing", // default trail for emits; never applied to reads
});

// One event. The wire names are snake_case; the inputs here are camelCase.
const { event, duplicate, idempotencyKey } = await santati.events.emit({
  event: "invoice.voided",
  organizationId: "org_acme",
  actor: { type: "user", id: "usr_123" },
  targets: [{ type: "invoice", id: "inv_555" }],
  data: { amount_cents: 4200 },
});
console.log(event?.id, duplicate, idempotencyKey); // `event` is null only for a queued emit

// A batch: one request, one result per item (`207` is a result, not an error).
const batch = await santati.events.emitBatch([
  { event: "invoice.paid", idempotencyKey: "evt-1" },
  { event: "invoice.sent" },
]);
console.log(batch.accepted, batch.rejected, batch.results);

// One page…
const page = await santati.events.list({ trail: "billing", eventPrefix: "invoice.", limit: 100 });
console.log(page.results, page.nextCursor);

// …or every page, one request at a time.
for await (const read of santati.events.iterate({ trail: "billing" })) {
  console.log(read.id, read.event);
}

// Pin an emit to one published schema version of its action.
await santati.events.emit({ event: "invoice.voided", organizationId: "org_acme", schemaVersion: 2 });

// Manage event definitions and their JSON Schema versions.
await santati.schemas.createDefinition({ action: "invoice.voided", allowedTargetTypes: ["invoice"] });
const draft = await santati.schemas.createVersion("invoice.voided", { type: "object" });
await santati.schemas.updateVersion("invoice.voided", draft.schemaVersion.version, { type: "object" }, {
  ifMatch: draft.etag ?? undefined,
});
await santati.schemas.publishVersion("invoice.voided", draft.schemaVersion.version);

Outbox

Without an outbox, events.emit sends the event and resolves with the stored one. With one, emit is fire-and-forget: it validates locally, stores the event in the outbox and resolves at once with queued: true, event: null and the idempotency key, without making a request. A background worker (every flushIntervalMs) sends the outbox in batches of batchSize through events.emitBatch; close() stops it and flushes what is left.

const santati = new Santati({
  apiKey: process.env.SANTATI_API_KEY!,
  trail: "billing",
  outbox: new MemoryOutbox(),
  postSend: (event, outcome) => console.log(event.event, outcome.status),
});

const { queued, idempotencyKey } = await santati.events.emit({
  event: "invoice.voided",
  organizationId: "org_acme",
});
await santati.close(); // sends anything still pending

MemoryOutbox is a bounded in-memory store (10000 events, lost on exit). close() sends each batch once; if the endpoint is down, what it could not send stays in the store and, in memory, is lost with the process. For a durable outbox shared across processes, install the optional ioredis peer dependency and pass a RedisOutbox (a Redis stream with the consumer group santati):

npm install ioredis
import { Redis } from "ioredis";
import { RedisOutbox } from "@santati/node/redis";

const santati = new Santati({
  apiKey: process.env.SANTATI_API_KEY!,
  trail: "billing",
  outbox: new RedisOutbox(new Redis(process.env.REDIS_URL!)),
});

preSend(event) may return a modified event, or null to drop it; postSend(event, outcome) sees every attempt's accepted, duplicate, rejected or failed outcome. Store failures raise OutboxError (outbox_full, store_unavailable, closed); a preSend that throws, or whose result makes the send throw a non-SDK error, is a failed outcome with OutboxError hook_failed.

Options

| option | default | meaning | | ------------------ | ------------------------ | ---------------------------------------------- | | apiKey | required, non-empty | team API key (sat_sk_…) | | baseUrl | https://api.santati.io | trailing / ignored; a path prefix is kept | | trail | none | default trail for emits | | timeoutMs | 10000 | per attempt | | maxRetries | 2 | retries after the first attempt | | initialBackoffMs | 250 | backoff base | | maxBackoffMs | 8000 | backoff cap, and the largest Retry-After | | headers | none | extra headers on every request | | outbox | none | when set, emit queues here | | batchSize | 100 | envelopes per outbox request, 1..500 | | flushIntervalMs | 1000 | the worker's tick, > 0 | | preSend | none | per-event hook before the request | | postSend | none | per-event hook with the outcome |

A 401/403/404/429/5xx/transport failure and any 400/413/422 are raised as AuthError, NotFoundError, RateLimitedError, ServerError, TransportError and ValidationError respectively — all of them SantatiErrors carrying status, code, field and retryAfter. A 400/413/422 whose code is schema_validation_failed (the event broke the action's schema, named a disallowed target type, or pinned an unusable schemaVersion) is a SchemaValidationError, a subclass of ValidationError. The client retries transport failures, 500/502/503/504 and 429 (unless the code is quota_exceeded), re-sending the identical request, and never follows a redirect; schemas.createVersion is sent once, because a repeat would create a second draft.

License

Apache-2.0.