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

@mocko/sdk

v0.1.0

Published

TypeScript SDK for integrating Mocko into test automations.

Readme

@mocko/sdk

TypeScript SDK for using Mocko from automated tests.

The SDK currently focuses on Mocko flags: shared state that tests and Mocko templates can read and write through mocko-core.

Installation

npm install @mocko/sdk

Requires Node.js 20 or newer.

Setup

Create one client for the Mocko core instance used by your test environment:

import { MockoClient } from '@mocko/sdk';

export const mocko = new MockoClient('http://localhost:8080');

The URL must point to mocko-core, not mocko-control.

Raw Flags

Use raw flags for ad-hoc state:

await mocko.setFlag('users:123:status', 'active');

const status = await mocko.getFlag<string>('users:123:status');

await mocko.deleteFlag('users:123:status');

Values are serialized as JSON, so strings, numbers, booleans, arrays, and objects are supported:

await mocko.setFlag('users:123:profile', {
  status: 'active',
  roles: ['admin', 'reviewer'],
});

getFlag(...) returns undefined when the flag does not exist.

Typed Flag Definitions

Define reusable typed flags once and use them across tests:

const userStatus = mocko
  .defineFlag<string>('User status')
  .pattern('users:{id}:status');

await userStatus.set('123', 'active');

expect(await userStatus.get('123')).toBe('active');
expect(userStatus.key('123')).toBe('users:123:status');

await userStatus.delete('123');

Patterns with no placeholders use no key arguments:

const checkoutEnabled = mocko
  .defineFlag<boolean>('Checkout enabled')
  .pattern('features:checkout');

await checkoutEnabled.set(true);
expect(await checkoutEnabled.get()).toBe(true);

Patterns with one placeholder use one positional string:

const userPlan = mocko
  .defineFlag<string>('User plan')
  .pattern('users:{id}:plan');

await userPlan.set('123', 'pro');

Patterns with two or more placeholders use a params object:

const userPreference = mocko
  .defineFlag<string>('User preference')
  .pattern('users:{id}:preferences:{preference}');

await userPreference.set({ id: '123', preference: 'language' }, 'en');

TTL

Flags written through the SDK use a default TTL of 300 seconds.

Override the client default:

const mocko = new MockoClient('http://localhost:8080', {
  defaultFlagTtl: 60,
});

Override one raw write:

await mocko.setFlag('users:123:status', 'active', 30);

Override a typed flag definition:

const shortLivedStatus = userStatus.ttl(30);

await shortLivedStatus.set('123', 'active');

Auth

By default, Mocko uses MANAGEMENT_AUTH_MODE=deploy. In that mode, flag endpoints are open and the SDK does not need a secret.

When mocko-core runs with MANAGEMENT_AUTH_MODE=all, pass the deploy secret:

const mocko = new MockoClient('http://localhost:8080', {
  secret: process.env.MOCKO_SECRET,
});

The SDK sends Authorization: Bearer <secret> on flag requests when secret is provided.

Mock Template Interop

SDK-written flags are available to Mocko templates:

mock "GET /users/{id}" {
  body = <<-EOF
    {{= $statusKey (append 'users:' request.params.id ':status')}}
    {{getFlag $statusKey}}
  EOF
}

Flags written by templates with setFlag are readable through the SDK.