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

@zerosls/clm-sdk

v2.2.4

Published

SDK for ZeroCLM API

Readme

CLM SDK

Cliente TypeScript para consumir la API de ZeroCLM.

Instalación

npm install @zero/clm-sdk

Uso básico

import { ClmSdk } from '@zero/clm-sdk';

// Crear instancia del SDK
const sdk = new ClmSdk({
  baseUrl: 'https://api.clm-app.com/api',  // URL base de la API
  organization: 'mi-organizacion',        // ID de organización
  token: 'jwt-token-opcional'             // Token JWT (opcional)
});

// Login
async function login() {
  try {
    const response = await sdk.auth.login({
      email: '[email protected]',
      password: 'contraseña'
    });
    
    console.log('Usuario logueado:', response.user);
    // El token se establece automáticamente para futuras peticiones
  } catch (error) {
    console.error('Error de login:', error);
  }
}

// Obtener configuraciones
async function getSettings() {
  try {
    const settings = await sdk.settings.getAll({
      group: 'general',
      enabled: true
    });
    
    console.log('Configuraciones:', settings);
  } catch (error) {
    console.error('Error al obtener configuraciones:', error);
  }
}

Módulos disponibles

Auth

Gestión de autenticación y tokens:

// Login
const loginResponse = await sdk.auth.login({ email, password });

// Refresh token
const refreshResponse = await sdk.auth.refreshToken({ refreshToken });

// Logout
await sdk.auth.logout();

// Verificar si está autenticado
const isAuthenticated = sdk.auth.isAuthenticated();

Settings

Gestión de configuraciones:

// Obtener todas las configuraciones
const settings = await sdk.settings.getAll();

// Obtener configuración por ID
const setting = await sdk.settings.getById('config-id');

// Obtener por grupo y nombre
const appName = await sdk.settings.getByName('general', 'app_name');

// Crear configuración
const newSetting = await sdk.settings.create({
  group_name: 'app',
  name: 'theme',
  value: 'dark',
  data_type: 'string',
  description: 'Tema de la aplicación'
});

// Actualizar configuración
await sdk.settings.update('config-id', { value: 'nuevo-valor' });

// Activar/desactivar configuración
await sdk.settings.toggleEnabled('config-id', true);

// Eliminar configuración
await sdk.settings.delete('config-id');

Manejo de errores

El SDK incluye un sistema de manejo de errores personalizado:

import { ApiError, ErrorType } from '@zero/clm-sdk';

try {
  await sdk.settings.getById('id-inexistente');
} catch (error) {
  if (error instanceof ApiError) {
    console.log('Código de estado:', error.statusCode);
    console.log('Tipo de error:', error.type);
    console.log('Es error de autenticación:', error.isAuthenticationError);
    console.log('Detalles:', error.details);
  }
}

Eventos

El SDK emite eventos que puedes escuchar:

// Escuchar cambios de token
const subscription = sdk.on('tokenChanged', (token) => {
  console.log('Token cambiado:', token);
});

// Escuchar errores de autenticación
sdk.on('authError', (error) => {
  console.log('Error de autenticación:', error);
  // Redirigir a login, etc.
});

// Cancelar suscripción cuando ya no sea necesaria
subscription.unsubscribe();

Caché

El SDK incluye un sistema de caché para optimizar peticiones:

// Limpiar toda la caché
sdk.cache.clear();

// Limpiar sólo caché de settings
sdk.cache.clearByPrefix('/settings');

Configuración avanzada

const sdk = new ClmSdk({
  baseUrl: 'https://api.clm-app.com/api',
  organization: 'mi-organizacion',
  cache: {
    enabled: true,    // Activar/desactivar caché
    ttl: 60000        // Tiempo de vida en ms (default: 1 minuto)
  },
  debug: true         // Activar logs de depuración
});

Desarrollo

Instalación de dependencias

npm install

Ejecutar tests

npm test               # Ejecutar tests
npm run test:watch     # Ejecutar tests en modo watch
npm run test:coverage  # Generar reporte de cobertura

Compilación

npm run build          # Compilar a JavaScript
npm run dev            # Compilar en modo watch

Lint

npm run lint

Licencia

MIT