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

@saplings/adapters

v0.3.0

Published

Optional AWS, database, observability, cache, analytics and queue integrations

Readme

@saplings/adapters

Optional provider integrations under independent import paths. The root entry point does not load provider SDKs. Provider-specific imports load their required clients, which are declared as optional peers; install only the providers your application uses. The interfaces have been type-checked with Mixpanel 2.x, PostHog 1.x, BullMQ 5.x, amqplib 0.10.x, Redis 5.x, and Sentry SDK clients. The application creates and closes provider clients and owns credentials, consent, retries, and infrastructure.

Provider guides

Each integration has a dedicated guide with installation, usage and operational notes:

For AWS use @saplings/adapters/aws; for PostgreSQL use @saplings/adapters/database/drizzle. Install only the providers needed for those imports as listed in their guides. Existing consumers of the former standalone packages should switch their imports and install the relevant hub peers.

Install

npm install @saplings/adapters
# Install only the provider(s) you choose, for example:
npm install mixpanel-browser

Analytics

./analytics/mixpanel and ./analytics/posthog wrap an initialized browser SDK with the same track, identify, reset, and setConsent interface. Both start disabled and only forward events after explicit consent. Initialize each provider only after consent, configure its automatic collection and privacy settings, and do not send secrets or sensitive personal information.

import mixpanel from 'mixpanel-browser';
import { createMixpanelAdapter } from '@saplings/adapters/analytics/mixpanel';

// Called only after the user has consented:
mixpanel.init('project-token', { autocapture: false, track_pageview: false, record_sessions_percent: 0 });
const analytics = createMixpanelAdapter(mixpanel);
analytics.setConsent(true);
analytics.track('project_created', { source: 'dashboard' });
// On consent withdrawal:
analytics.setConsent(false);

PostHog uses createPostHogAdapter from @saplings/adapters/analytics/posthog with an initialized PostHog client. For example, after consent:

import posthog from 'posthog-js';
import { createPostHogAdapter } from '@saplings/adapters/analytics/posthog';

posthog.init('project-key', { api_host: 'https://us.i.posthog.com', autocapture: false, capture_pageview: false, disable_session_recording: true });
const analytics = createPostHogAdapter(posthog);
analytics.setConsent(true);
analytics.track('project_created', { source: 'dashboard' });

Use your project's actual PostHog host and review provider SDK defaults on each upgrade. These adapters do not replace Miner, automatically forward Miner events, or manage consent storage. After obtaining consent, applications can explicitly call analytics.track after a successful miner.track call. This is best-effort and is not an atomic or guaranteed cross-provider delivery; use a durable, privacy-reviewed outbox when guaranteed delivery is needed. Integrate them deliberately with your consent and Miner event flow; consult each provider's options to ensure automatic collection is disabled until consent. They do not initialize either SDK or send telemetry by themselves.

Queue publishing

The ./queues/bullmq and ./queues/rabbitmq subpaths expose the same publish({ id, type, payload }) shape. Supply a connected BullMQ Queue or an amqplib confirm channel. RabbitMQ queues must already be declared; RabbitMQ publishing uses persistent messages and publisher confirms.

import { Queue } from 'bullmq';
import { createBullMqPublisher } from '@saplings/adapters/queues/bullmq';

const queue = new Queue('reports', { connection: { host: 'localhost', port: 6379 } });
const publisher = createBullMqPublisher(queue);
await publisher.publish({ id: 'report_123', type: 'report.generate', payload: { reportId: '123' } });
await queue.close();
import amqp from 'amqplib';
import { createRabbitMqPublisher } from '@saplings/adapters/queues/rabbitmq';

const connection = await amqp.connect('amqp://localhost');
const channel = await connection.createConfirmChannel();
await channel.assertQueue('reports', { durable: true });
const publisher = createRabbitMqPublisher(channel, 'reports');
await publisher.publish({ id: 'report_123', type: 'report.generate', payload: { reportId: '123' } });
await channel.close();
await connection.close();

For BullMQ consumers, pass createBullMqProcessor(handler) to a BullMQ Worker; thrown errors are handled by its configured retry policy. For RabbitMQ, startRabbitMqConsumer(channel, queue, handler, onError) acknowledges after the handler succeeds and rejects failures without requeue. Configure a dead-letter exchange; its returned async function cancels the consumer. Drain in-flight work before closing the channel.

These integrations do not replace the SDK worker contract or implement a transactional outbox, tenant isolation, or exactly-once delivery. BullMQ job IDs deduplicate only according to BullMQ's job retention semantics; RabbitMQ messageId is metadata and does not deduplicate. Use idempotent consumers and an outbox for effects that must survive crashes. Configure broker authentication, TLS, queue permissions, backpressure, dead letters, and monitoring in your deployment.

Redis and Valkey public cache

Install redis and pass a connected node-redis-compatible client to RedisCache from @saplings/adapters/cache/redis. The adapter implements the CacheStore contract used by @saplings/middleware's publicJsonCache, applies server-side TTLs and supports explicit delete. It limits entries to 128 KiB and TTLs to one day. Use unique prefixes and cache only public data unless your application separately enforces authorization and tenant isolation. The host owns connection, TLS, authentication and shutdown.

import { createClient } from 'redis';
import { RedisCache } from '@saplings/adapters/cache/redis';
import { publicJsonCache } from '@saplings/middleware';

const client = createClient({ url: process.env.REDIS_URL });
await client.connect();
const cache = new RedisCache(client, 'my-service:public-cache:');
const middleware = publicJsonCache(cache, 30000, async () => ({ status: 'ok' }));
// Mount on an anonymous public GET route. Close the client at shutdown.

Sentry error reporting

Install @sentry/node or @sentry/react and pass the initialized SDK to createSentryReporter from @saplings/adapters/observability/sentry. The application owns initialization, consent, sampling, redaction and shutdown. This package does not transmit telemetry until its reporter is called.

import * as Sentry from '@sentry/node';
import { createSentryReporter } from '@saplings/adapters/observability/sentry';

Sentry.init({ dsn: process.env.SENTRY_DSN, tracesSampleRate: 0.05 });
const reporter = createSentryReporter(Sentry, { enabled: Boolean(process.env.SENTRY_DSN) });
try { await runTask(); } catch (error) { reporter.captureException(error); }

Pass the reporter to an application error boundary or error handler. enabled: false disables capture; shouldCapture(error) may exclude known errors. Configure SDK data scrubbing and obtain any required user consent.

Amazon SQS

createSqsPublisher from @saplings/adapters/queues/sqs accepts an application-created AWS SDK v3 SQS client. Use a trusted HTTPS queue URL and configure IAM, encryption and dead-letter queues externally. FIFO queues require an explicit group ID and use the message ID for deduplication. Standard queues and expired FIFO deduplication windows still require idempotent consumers. The adapter defaults to a 256 KiB envelope limit and does not implement consumer polling or retry policy.

EventBridge, KMS and Secrets Manager

Independent imports @saplings/adapters/aws/eventbridge, @saplings/adapters/aws/kms and @saplings/adapters/aws/secrets accept the corresponding application-created AWS SDK v3 aggregate clients. EventBridge checks individual entry acknowledgements, preserves application event IDs for downstream deduplication and does not retry ambiguous writes. KMS supports direct symmetric encryption for up to 4 KiB with tenant and purpose encryption context; the host must authorize those values and enforce IAM/key policy. Encryption context is not confidential. Secrets Manager reads only configured logical names from AWSCURRENT without caching; the host must restrict caller access and scope IAM to allowed secrets. Never log secret values. Live AWS, key rotation and cross-account tests remain required.

Shared gateway nonce claims

createRedisNonceClaim from @saplings/adapters/cache/nonce implements atomic SET NX EXAT replay claims for Harbor assertions. Use the same issuer/audience namespace across receiving replicas, a dedicated non-evicting security store, synchronized clocks, authenticated TLS, and a failover policy that preserves claims. Expiry includes a 60-second safety margin. Store errors propagate; never fall back to accepting an assertion. Live replica tests cover concurrent claims; failover and clock-skew drills remain required.