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

cms-web-apis

v1.0.0

Published

Biblioteca de APIs para CMS Web - Conjunto completo de funciones para interactuar con APIs de gestión de contenido

Readme

CMS Web APIs

Una biblioteca completa de TypeScript para interactuar con APIs de gestión de contenido (CMS). Esta biblioteca proporciona funciones tipadas para todas las operaciones relacionadas con productos, atributos, imágenes, categorías y más.

🚀 Características

  • Completamente tipado con TypeScript
  • Soporte para ESM y CommonJS
  • Manejo de errores robusto
  • Funciones de utilidad incluidas
  • Documentación completa de tipos

📦 Instalación

npm install cms-web-apis

🔧 Configuración

Antes de usar la biblioteca, configura las variables de entorno:

# .env
VITE_ERP_BASE_URL=https://tu-api-base-url.com
API_BASE_URL=https://tu-api-base-url.com

📖 Uso Básico

Importación

// Importar funciones específicas
import { unidadesMedida, getCategoriasProducto, getAtributos } from 'cms-web-apis';

// Importar tipos
import type { UnidadMedida, CategoriaProducto, Atributo } from 'cms-web-apis';

Ejemplo de Uso

import { unidadesMedida, getCategoriasProducto } from 'cms-web-apis';

async function ejemploUso() {
  try {
    // Obtener unidades de medida
    const unidades = await unidadesMedida();
    console.log('Unidades de medida:', unidades);

    // Obtener categorías de producto
    const categorias = await getCategoriasProducto();
    console.log('Categorías:', categorias);
  } catch (error) {
    console.error('Error:', error);
  }
}

🛠️ APIs Disponibles

Productos y Categorías

  • getCategoriasProducto() - Obtener categorías de productos
  • getTiposProducto() - Obtener tipos de productos
  • getMarcasProducto() - Obtener marcas de productos
  • getSegmentos() - Obtener segmentos
  • getMotorizacionesProducto() - Obtener motorizaciones

Atributos y Validaciones

  • getAtributos() - Obtener atributos
  • editarAtributo() - Editar atributo
  • reglaValidacionAtributo() - Reglas de validación
  • getReglasValidacion() - Obtener reglas de validación

Imágenes y Medios

  • getImagenesProducto() - Obtener imágenes de productos
  • getImagenesMarca() - Obtener imágenes de marcas
  • getImagenesGrupoProducto() - Obtener imágenes de grupos
  • getImagenesOtrosContenidos() - Obtener otros contenidos

Configuración y Utilidades

  • getPreLoginInfo() - Información de pre-login
  • getTiposArchivo() - Obtener tipos de archivo
  • getContentSettings() - Configuraciones de contenido
  • unidadesMedida() - Obtener unidades de medida

Importación y Exportación

  • importarAtributosPorProducto() - Importar atributos
  • getExportarProducto() - Exportar productos
  • getInformeActualizacionProductos() - Informes de actualización

🔍 Tipos Principales

// Unidades de Medida
interface UnidadMedida {
  id: number;
  nombre: string;
  descripcion?: string;
  simbolo?: string;
  activo: boolean;
  fechaCreacion: string;
  fechaActualizacion?: string;
}

// Categorías de Producto
interface CategoriaProducto {
  id: number;
  nombre: string;
  descripcion?: string;
  activo: boolean;
  fechaCreacion: string;
  fechaActualizacion?: string;
}

// Atributos
interface Atributo {
  id: number;
  nombre: string;
  descripcion?: string;
  activo: boolean;
  fechaCreacion: string;
  fechaActualizacion?: string;
}

🏗️ Desarrollo

Construir la biblioteca

# Instalar dependencias
npm install

# Construir para producción
npm run build

# Construir solo CommonJS
npm run build:cjs

# Construir solo ESM
npm run build:esm

Estructura del proyecto

src/
├── index.tsx              # Punto de entrada principal
├── api.ts                 # Utilidades de API
├── api*.ts                # Funciones de API específicas
├── api*.type.ts           # Tipos TypeScript
└── ...

📝 Ejemplos Avanzados

Manejo de Errores

import { getCategoriasProducto } from 'cms-web-apis';

async function manejoErrores() {
  try {
    const categorias = await getCategoriasProducto();
    return categorias;
  } catch (error) {
    if (error instanceof Error) {
      console.error('Error específico:', error.message);
    }
    throw error;
  }
}

Uso con React

import { useState, useEffect } from 'react';
import { getCategoriasProducto, type CategoriaProducto } from 'cms-web-apis';

function CategoriasComponent() {
  const [categorias, setCategorias] = useState<CategoriaProducto[]>([]);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    async function cargarCategorias() {
      try {
        const data = await getCategoriasProducto();
        setCategorias(data);
      } catch (error) {
        console.error('Error cargando categorías:', error);
      } finally {
        setLoading(false);
      }
    }

    cargarCategorias();
  }, []);

  if (loading) return <div>Cargando...</div>;

  return (
    <div>
      {categorias.map(categoria => (
        <div key={categoria.id}>{categoria.nombre}</div>
      ))}
    </div>
  );
}

🤝 Contribuir

  1. Fork el proyecto
  2. Crea una rama para tu feature (git checkout -b feature/AmazingFeature)
  3. Commit tus cambios (git commit -m 'Add some AmazingFeature')
  4. Push a la rama (git push origin feature/AmazingFeature)
  5. Abre un Pull Request

📄 Licencia

Este proyecto está bajo la Licencia MIT. Ver el archivo LICENSE para más detalles.

🆘 Soporte

Si tienes problemas o preguntas:

  1. Revisa la documentación
  2. Busca en los issues existentes
  3. Crea un nuevo issue con detalles del problema

Desarrollado con ❤️ para simplificar la gestión de APIs de CMS