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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@catalisaio/admin-sdk

v0.8.1

Published

Admin SDK for WhatsApp Multi-tenant Platform

Downloads

261

Readme

@wpp/admin-sdk

TypeScript SDK for WhatsApp Multi-tenant Platform Administration.

Features

  • ✅ Complete Admin API coverage
  • ✅ Framework-agnostic (React, Vue, Angular, Vanilla JS)
  • ✅ Full TypeScript support with comprehensive types
  • ✅ WhatsApp operations via composition (@wpp/sdk)
  • ✅ Comprehensive error handling
  • ✅ Examples for all resources

Installation

npm install @wpp/admin-sdk

Quick Start

import { AdminAPIClient } from '@wpp/admin-sdk';

// Create client instance
const admin = new AdminAPIClient({
  baseURL: 'http://localhost:3000',
  auth: {
    type: 'jwt',
    token: 'your-jwt-token',
  },
});

// Use admin resources
const users = await admin.users.list();
console.log('Users:', users);

const tenant = await admin.tenants.create({ name: 'Acme Corp' });
console.log('Created tenant:', tenant);

// Use WhatsApp operations via composition
await admin.whatsapp.whatsappAdmin.connect(tenant.id);
const qr = await admin.whatsapp.whatsappAdmin.getQR(tenant.id);
console.log('QR Code:', qr.qr);

Resources

The Admin SDK provides the following resources:

Admin Operations

  • users - User management (CRUD, roles)
  • tenants - Tenant management (CRUD, settings)
  • devices - Device management (connect, QR codes, status)
  • apiTokens - API token management (CRUD)
  • branding - Branding configuration (colors, logos, messages)
  • advancedWebhooks - Advanced webhooks (CRUD, logs, stats, filters)
  • dashboard - Dashboard statistics and metrics

WhatsApp Operations (via @wpp/sdk)

  • whatsapp - Full WhatsApp API access through composition

API Reference

Users

// List all users
const users = await admin.users.list();

// Get user by ID
const user = await admin.users.get('user-id');

// Create user
const newUser = await admin.users.create({
  email: '[email protected]',
  password: 'securepassword',
  role: 'user',
  tenantId: 'tenant-id', // optional
});

// Update user
await admin.users.update('user-id', {
  role: 'admin',
});

// Delete user
await admin.users.delete('user-id');

Tenants

// List all tenants
const tenants = await admin.tenants.list();

// Create tenant
const tenant = await admin.tenants.create({ name: 'New Tenant' });

// Update tenant settings
await admin.tenants.updateSettings(tenant.id, {
  webhookUrl: 'https://example.com/webhook',
  webhookSecret: 'secret',
});

Devices

// List all devices
const devices = await admin.devices.list();

// Get device status
const device = await admin.devices.get('tenant-id');

// Get QR code
const { qr, status } = await admin.devices.getQR('tenant-id');

// Connect device
await admin.devices.connect('tenant-id');

// Reconnect (with force option)
await admin.devices.reconnect('tenant-id', { force: true });

// Reset device
await admin.devices.reset('tenant-id');

Advanced Webhooks

// Create advanced webhook
const webhook = await admin.advancedWebhooks.create({
  name: 'Group Messages',
  urls: ['https://api.example.com/webhook'],
  eventTypes: ['messages.upsert'],
  filters: {
    remoteJid: '[email protected]',
    fromMe: false,
  },
  secret: 'webhook-secret',
  retryCount: 3,
}, 'tenant-id');

// Get delivery logs
const logs = await admin.advancedWebhooks.getLogs(webhook.id, {
  success: false,
  limit: 20,
});

// Get statistics
const stats = await admin.advancedWebhooks.getStats(webhook.id);
console.log('Success rate:', stats.successRate);

WhatsApp Integration

The Admin SDK uses @wpp/sdk internally for WhatsApp operations:

// Access WhatsApp operations
await admin.whatsapp.whatsappAdmin.sendMessage('tenant-id', {
  jid: '[email protected]',
  text: 'Hello from admin!',
});

// Create group
await admin.whatsapp.whatsappAdmin.createGroup('tenant-id', {
  subject: 'My Group',
  participants: ['[email protected]'],
});

// List groups
const groups = await admin.whatsapp.whatsappAdmin.listGroups('tenant-id');

Authentication

The SDK supports two authentication methods:

JWT Authentication

const admin = new AdminAPIClient({
  baseURL: 'http://localhost:3000',
  auth: {
    type: 'jwt',
    token: 'your-jwt-token',
  },
});

// Update token later
admin.setAuth('new-token', 'jwt');

// Clear auth
admin.clearAuth();

API Token Authentication

const admin = new AdminAPIClient({
  baseURL: 'http://localhost:3000',
  auth: {
    type: 'apiToken',
    token: 'your-api-token',
  },
});

Error Handling

The SDK provides comprehensive error classes:

import {
  APIError,
  AuthError,
  ValidationError,
  NotFoundError,
  RateLimitError,
  NetworkError,
} from '@wpp/admin-sdk';

try {
  await admin.users.get('invalid-id');
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('User not found');
  } else if (error instanceof AuthError) {
    console.log('Authentication failed');
  } else if (error instanceof ValidationError) {
    console.log('Validation error:', error.message);
  } else if (error instanceof APIError) {
    console.log('API error:', error.status, error.message);
  }
}

Advanced Configuration

const admin = new AdminAPIClient({
  baseURL: 'http://localhost:3000',
  timeout: 60000, // 60 seconds
  headers: {
    'X-Custom-Header': 'value',
  },
  onRequest: (config) => {
    console.log('Request:', config.method, config.url);
    return config;
  },
  onResponse: (response) => {
    console.log('Response:', response.status);
    return response;
  },
  onError: (error) => {
    console.error('Error:', error.message);
  },
});

Examples

See the examples/ directory for complete working examples:

  • basic-usage.ts - Basic CRUD operations
  • whatsapp-integration.ts - WhatsApp operations via composition
  • advanced-webhooks.ts - Advanced webhook management
  • react-usage.tsx - React integration example

TypeScript Support

The SDK is written in TypeScript and provides full type definitions:

import type {
  User,
  Tenant,
  Device,
  AdvancedWebhook,
  DashboardStats,
} from '@wpp/admin-sdk';

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

# Clean
npm run clean

License

MIT

Support

For issues and questions, visit the GitHub repository.