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

@comenchi/shop-sdk

v3.0.3

Published

SDK puro y liviano para la API de Vendure de Comenchi

Readme

@comenchi/shop-sdk

Version: 3.0.0-beta.11

SDK puro y liviano para interactuar con la API de Vendure de Comenchi. Este SDK maneja todas las operaciones GraphQL necesarias para e-commerce: productos, colecciones, órdenes, checkout, etc.

Características

  • ✅ SDK puro sin dependencias de UI frameworks
  • ✅ TypeScript con tipos generados automáticamente
  • ✅ Soporte para SSR y CSR
  • ✅ Manejo de autenticación y sesiones
  • ✅ APIs completas para e-commerce

Instalación

pnpm add @comenchi/shop-sdk

Uso Básico

1. Inicializar el SDK

import { ComenchiShop } from "@comenchi/shop-sdk";

const sdk = new ComenchiShop({
  apiUrl: "https://api.example.com/graphql",
  channelToken: "your-channel-token",
});

2. Usar con React (Provider)

import { ComenchiProvider } from "@comenchi/shop-sdk";

function App() {
  return (
    <ComenchiProvider value={sdk}>
      <YourApp />
    </ComenchiProvider>
  );
}

// En componentes hijos
import { useComenchiShop } from "@comenchi/shop-sdk";

function ProductList() {
  const sdk = useComenchiShop();

  // Usar el SDK
  const products = await sdk.products.list({ take: 10 });
}

APIs Disponibles

Collections API (sdk.collections)

// Listar colecciones
const collections = await sdk.collections.list({ take: 20 });

// Obtener colección por slug
const collection = await sdk.collections.getBySlug("electronics");

Products API (sdk.products)

// Listar productos
const products = await sdk.products.list({ take: 10, skip: 0 });

// Buscar productos
const searchResults = await sdk.products.search({ term: "laptop" });

// Obtener producto por slug
const product = await sdk.products.getBySlug("macbook-pro");

Order API (sdk.order)

// Obtener orden activa
const activeOrder = await sdk.order.active();

// Agregar item al carrito
await sdk.order.addItem({
  productVariantId: "123",
  quantity: 2,
});

// Aplicar cupón
await sdk.order.applyCouponCode("DESCUENTO10");

// Establecer dirección de envío
await sdk.order.setShippingAddress({
  fullName: "Juan Pérez",
  streetLine1: "Av. Principal 123",
  city: "Lima",
  countryCode: "PE",
});

// Agregar pago
await sdk.order.addPayment({
  method: "stripe",
  metadata: { paymentIntentId: "pi_xxx" },
});

// Transicionar orden
await sdk.order.transitionTo("ArrangingPayment");

Customer API (sdk.customer)

// Obtener cliente activo
const customer = await sdk.customer.active();

// Obtener direcciones
const addresses = await sdk.customer.addresses();

// Crear dirección
await sdk.customer.createAddress({
  fullName: "Juan Pérez",
  streetLine1: "Av. Principal 123",
  city: "Lima",
  countryCode: "PE",
});

Extras API (sdk.extras)

// Búsqueda de ubigeo (Perú)
const departments = await sdk.extras.ubigeo({
  type: "department",
});

const provinces = await sdk.extras.ubigeo({
  type: "province",
  departmentCode: "15",
});

Channel API (sdk.channel)

// Obtener información del canal activo
const channel = await sdk.channel.active();

Assets API (sdk.assets)

// Obtener assets
const assets = await sdk.assets.list({ take: 20 });

WhatsApp API (sdk.wts)

// Enviar mensaje por WhatsApp
await sdk.wts.sendMessage({
  to: "+51999999999",
  message: "Hola desde Comenchi",
});

TypeScript

El SDK incluye tipos completos generados desde el schema GraphQL:

import type { Product, Collection, Order, Customer } from "@comenchi/shop-sdk";

SSR (Server-Side Rendering)

El SDK funciona tanto en cliente como en servidor:

// En loader de React Router
export async function loader() {
  const sdk = new ComenchiShop({
    apiUrl: process.env.API_URL,
    channelToken: process.env.CHANNEL_TOKEN,
  });

  const products = await sdk.products.list({ take: 10 });

  return { products };
}

Configuración Avanzada

import { ComenchiShop, InMemoryPersist } from "@comenchi/shop-sdk";

const sdk = new ComenchiShop({
  apiUrl: "https://api.example.com/graphql",
  channelToken: "your-channel-token",

  // Persister personalizado (por defecto: InMemoryPersist)
  persister: new InMemoryPersist(),

  // Headers adicionales
  headers: {
    "X-Custom-Header": "value",
  },
});

// Cambiar channel token dinámicamente
sdk.setChannelToken("new-channel-token");

// Clonar SDK con opciones diferentes
const clonedSdk = ComenchiShop.clone(sdk, {
  channelToken: "another-token",
});

Contribución

Este SDK es parte del monorepo de Comenchi. Para contribuir, revisa la guía de contribución.

Licencia

ISC