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

@plankton.mobi/mds-sdk

v2.0.0

Published

Plankton MDS SDK - Client library for the Master Data Service API

Readme

@plankton.mobi/mds-sdk

Official TypeScript SDK for the Plankton MDS (Master Data Service) API.

Installation

npm install @plankton.mobi/mds-sdk

Quick Start

import { init } from '@plankton.mobi/mds-sdk';

// Initialize the SDK
const mds = init({
  apiUrl: 'https://mds-api-189707367818.africa-south1.run.app',
  getToken: async () => {
    // Return a valid Firebase/Itsumi token
    const user = auth.currentUser;
    return user ? await user.getIdToken() : '';
  },
});

// Query entities
const { data: characters } = await mds.getEntities({ type: 'character' });
console.log(characters);

// Register a managed object
const object = await mds.register({
  type: 'collectible',
  name: 'Simba Digital Card',
  description: 'A collectible digital card featuring Simba the Lion',
  tags: ['character', 'big5', 'lion'],
  rule_sets: [
    {
      type: 'commerce',
      config: {
        sku: 'CARD-SIMBA-001',
        price_cents: 999,
        currency: 'ZAR',
        channels: ['app', 'web'],
      },
    },
    {
      type: 'entitlement',
      config: {
        access_type: 'unlimited',
        binding: 'user',
        transferable: false,
      },
    },
  ],
});

console.log('Created object:', object.id);

Usage Patterns

Pattern 1: Singleton (Recommended)

Initialize once, use everywhere:

// In your app initialization
import { init } from '@plankton.mobi/mds-sdk';

init({
  apiUrl: process.env.MDS_API_URL!,
  getToken: () => getAuthToken(),
});

// Anywhere else in your app
import { getEntities, register, resolve } from '@plankton.mobi/mds-sdk';

const entities = await getEntities({ type: 'park' });

Pattern 2: Direct Client Instance

For more control or multiple clients:

import { MDSClient } from '@plankton.mobi/mds-sdk';

const client = new MDSClient({
  apiUrl: 'https://mds-api.plankton.mobi',
  getToken: () => getAuthToken(),
  timeout: 60000, // 60 second timeout
});

const entities = await client.getEntities({ type: 'park' });

API Reference

Objects

// Register a new object
const obj = await mds.register({
  type: 'collectible',
  name: 'My Object',
  description: 'Description here',
  tags: ['tag1', 'tag2'],
});

// Get an object
const obj = await mds.get('uuid-here');

// Update an object
await mds.update('uuid-here', {
  name: 'New Name',
  description: 'Updated description',
});

// Query objects
const { data, total, has_more } = await mds.query({
  type: 'collectible',
  status: 'published',
  search: 'simba',
  limit: 20,
});

// Publish an object
await mds.publish('uuid-here');

// Add a rule set
await mds.addRuleSet('uuid-here', {
  type: 'commerce',
  config: {
    sku: 'SKU-001',
    price_cents: 1000,
    currency: 'ZAR',
    channels: ['app'],
  },
});

Resolution (QR/Token)

// Resolve a QR code
const result = await mds.resolve({
  token_code: 'ABC123',
  location: { lat: -33.9, lng: 18.4 },
  device_id: 'device-uuid',
});

if (result.success) {
  console.log('Content URI:', result.storage_uri);
}

// Convenience method
const result = await mds.resolveToken('ABC123', {
  location: { lat: -33.9, lng: 18.4 },
});

Events

// Emit an event
const event = await mds.emit({
  event_type: 'content_accessed',
  target_object_id: 'uuid-here',
  payload: {
    custom_data: 'value',
  },
});

Catalog

// Get available products
const { data: products } = await mds.getCatalog({
  channel: 'app',
  territory: 'ZA',
  type: 'collectible',
});

Entitlements

// Get current user's entitlements
const { entitlements } = await mds.getMyEntitlements();

// Check if user has access
const { has_entitlement } = await mds.checkEntitlement('user-id', 'object-id');

// Grant entitlement
await mds.grantEntitlement({
  holder_id: 'user-id',
  managed_object_id: 'object-id',
  grant_type: 'purchase',
  access_type: 'unlimited',
});

Entities (Ontology)

// Get all characters
const { data: characters } = await mds.getEntities({ type: 'character' });

// Get all parks
const { data: parks } = await mds.getEntities({ type: 'park' });

// Search entities
const { data: results } = await mds.getEntities({
  type: 'character',
  search: 'simba',
});

Types

All types are exported for use in your TypeScript code:

import type {
  ManagedObject,
  ManagedObjectType,
  ObjectStatus,
  RuleSet,
  RuleType,
  Entity,
  EntityType,
  Entitlement,
  CatalogItem,
  // Request/Response types
  RegisterObjectRequest,
  QueryObjectsRequest,
  ResolveRequest,
  EmitEventRequest,
  // Rule configs
  CommerceConfig,
  EntitlementConfig,
  GovernanceConfig,
  ResolutionConfig,
} from '@plankton.mobi/mds-sdk';

Error Handling

import { MDSApiError } from '@plankton.mobi/mds-sdk';

try {
  await mds.get('non-existent-id');
} catch (error) {
  if (error instanceof MDSApiError) {
    console.log('Status:', error.status); // 404
    console.log('Code:', error.code); // 'not_found'
    console.log('Message:', error.message);
  }
}

Configuration Options

| Option | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | apiUrl | string | Yes | - | Base URL of the MDS API | | getToken | () => Promise<string> \| string | Yes | - | Function that returns auth token | | tenantCode | string | No | - | Override tenant code | | timeout | number | No | 30000 | Request timeout in ms |

License

MIT