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

@idevconn/monetization

v0.1.4

Published

Client SDK for the iSubscribe monetization platform — credit wallets, reservations, revenue, and entitlements.

Readme

@idevconn/monetization

Client SDK for the iSubscribe monetization platform — credit wallets, two-phase reservations, revenue wallets, pricing, and entitlements.

It is the client for the SaaS wallet APIs. It owns none of the money logic (that lives in the SaaS); it owns ergonomics, resilience, and lifecycle wiring so a customer app consumes the platform with minimal code.

Status

| Entry point | What | State | |-------------|------|-------| | @idevconn/monetization/core | transport-agnostic API client, types, cache, circuit breaker, WalletStore | ✅ shipped (hosted mode) | | @idevconn/monetization/nest | NestJS module, @ConsumesCredits decorator, interceptor, job-settlement | ✅ shipped | | @idevconn/monetization/react | provider, hooks, cards/ledger/gate + PlansWidget/BuyCreditsDialog | ✅ shipped |

/core

import { createMonetizationCore } from '@idevconn/monetization/core';

const { client, store } = createMonetizationCore({
  baseUrl: 'https://isubscribe.me/api/v1/public',
  apiKey: process.env.ISUBSCRIBE_API_KEY,   // server-to-server
  fallback: 'fail-closed',                  // or 'fail-open' for UX-first gating
  cache: { balanceTtlMs: 10_000 },
  circuitBreaker: { errorThresholdPercent: 50, openMs: 30_000 },
  retry: { maxRetries: 2 },
});

// Low-level typed client — one method per API endpoint
const reservation = await client.createReservation({ userId, operation: 'generate_voice' });
await client.commitReservation(reservation.reservationId, { actualUnits: 2 });

// Resilience-wrapped store — the interface /nest and /react consume
const res = await store.reserve(userId, 'generate_voice');
const balance = await store.getBalance(userId); // served from TTL cache when fresh

Two layers

  • client (MonetizationClient) — one method per endpoint (reservations, grant, balance, ledger, estimate, reconcile, pricing, revenue, entitlements). Handles auth headers, idempotency keys, retries, timeouts, and maps responses to typed errors.
  • store (HostedWalletStoreWalletStore) — the small interface the upper layers depend on. Adds the resilience contract: balance TTL cache, circuit breaker, and the configurable fallback policy. Swapping mode later (local / hybrid) swaps the implementation without changing consumers.

Errors

All failures are typed: InsufficientCreditsError (402), NotFoundError (404), IdempotencyConflictError (409), ReservationExpiredError (410), ApiError (other non-2xx), NetworkError, CircuitOpenError. Branch on instanceof.

Resilience

  • Cache — balances served from a short TTL cache; the stale value backs the fallback path when the SaaS is unreachable.
  • Circuit breaker — transport-level; trips on repeated server/network failures and rejects fast with CircuitOpenError until a half-open trial.
  • Fallbackfail-open mints an optimistic zero-hold reservation on outage (commit/void then no-op, settled by reconciliation); fail-closed rethrows.
  • Business answers (e.g. insufficient credits) never trigger fallback.

Develop

yarn install
yarn typecheck
yarn test
yarn build

Stack: TypeScript, tsup (ESM + CJS + .d.ts), Vitest. /core has no NestJS or React dependency.

License

MIT