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

@cbm-common/seller-repository

v0.0.1

Published

Documentación en español para la librería `@cbm-common/seller-repository`.

Readme

CbmSellerRepository

Documentación en español para la librería @cbm-common/seller-repository.

Esta librería contiene el módulo, servicio y repositorio para gestionar vendedores (sellers) contra un endpoint REST configurable.

Resumen rápido

  • Configuración: el módulo exporta CbmSellerModule.forRoot({ baseUrl }) y provee el token SELLER_MODULE_CONFIG.
  • Servicio: CbmSellerService usa HttpClient y la configuración inyectada para construir las URLs.
  • Repositorio: CbmSellerRepository expone una API tipada (list, getOne, save, update, changeStatus, delete, downloadExcelCarga, downloadExcelReport, restore).

Instalación y build

Desde la raíz del monorepo (o usando Angular CLI):

ng build seller-repository

Después de compilar, el artefacto estará en dist/seller-repository y podrá publicarse con npm publish si corresponde.

Configuración del módulo (forRoot)

La librería usa el patrón de configuración por token. En tu aplicación debes registrar el baseUrl del endpoint cuando importes el módulo:

Ejemplo en AppModule (no standalone):

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CbmSellerModule } from '@cbm-common/seller-repository';

@NgModule({
   imports: [
      BrowserModule,
      // registrar la configuración de la librería
      CbmSellerModule.forRoot({ baseUrl: '/api/sellers' }),
   ],
})
export class AppModule {}

Si usas componentes standalone, asegúrate de proporcionar el token en el providers del componente o de un bootstrap module.

Tipos principales (resumen)

Los tipos expuestos por CbmSellerModel cubren la forma de las peticiones y respuestas:

  • ListParams: filtros opcionales (filter_text, deleted, enabled, identification_number, seller_category_id).
  • ListResponse: { success: boolean; data: Array<...> } con los campos del vendedor (_id, full_name, identification_number, emails, enabled, deleted, etc.).
  • GetOneResponse: respuesta con data que contiene el vendedor completo.
  • SaveBody / UpdateBody: payloads para crear/actualizar vendedores.
  • ChangeStatusBody: { enabled: boolean; disabled_reason?: string }.
  • DownloadExcelReportParams: filtros para el reporte (enabled, seller_category_id, filter_text).

Consulta projects/seller-repository/src/lib/seller.model.ts para la definición completa de los campos.

API pública del repositorio

La clase CbmSellerRepository implementa la interfaz ICbmSellerRepository y ofrece los siguientes métodos:

  • list(params: ListParams): Observable
  • getOne(id: string): Observable
  • save(data: SaveBody): Observable
  • update(id: string, data: UpdateBody): Observable
  • changeStatus(id: string, data: ChangeStatusBody): Observable
  • delete(id: string): Observable
  • downloadExcelCarga(params): Observable<HttpResponse> — descarga un archivo con la template de carga.
  • downloadExcelReport(params): Observable<HttpResponse> — descarga el reporte filtrado.
  • restore(id: string): Observable — restaura un registro marcado como eliminado.

Todos los métodos están tipados y devuelven Observables de RxJS.

Ejemplos de uso

  1. Consumir el repositorio en un componente (inyección mediante constructor):
import { Component } from '@angular/core';
import { CbmSellerRepository } from '@cbm-common/seller-repository';

@Component({
   selector: 'app-seller-list',
   template: `<!-- ... -->`,
})
export class SellerListComponent {
   constructor(private repo: CbmSellerRepository) {}

   load() {
      this.repo.list({ filter_text: 'Acme' }).subscribe(res => {
         console.log(res.data);
      });
   }
}
  1. Descargar un reporte Excel (manejar Blob):
this.repo.downloadExcelReport({ filter_text: 'Acme' }).subscribe(response => {
   const blob = response.body as Blob;
   const url = window.URL.createObjectURL(blob);
   const a = document.createElement('a');
   a.href = url;
   a.download = 'reporte_vendedores.xlsx';
   a.click();
   window.URL.revokeObjectURL(url);
});
  1. Restaurar un vendedor borrado:
this.repo.restore('id-del-vendedor').subscribe(res => {
   if (res.success) {
      // actualizar UI
   }
});

Notas importantes

  • Base URL: todas las rutas se construyen a partir de la baseUrl que se inyecta con CbmSellerModule.forRoot({ baseUrl }).
  • Descargas: los métodos downloadExcelCarga y downloadExcelReport devuelven Observable<HttpResponse<Blob>>. Al usar HttpClient con responseType: 'blob', el body del HttpResponse será el Blob descargado.
  • Tipos: la librería exporta CbmSellerModel con las interfaces usadas por la API. Evita usar any en los consumidores y usa los tipos exportados.
  • Compatibilidad: versiones antiguas de esta librería podían registrar un SellerHttpService o interceptores a nivel de módulo; la versión actual usa HttpClient y la configuración via SELLER_MODULE_CONFIG. Si tu aplicación depende de proveedores personalizados (interceptores o adaptadores HTTP), registra esos proveedores en el AppModule o reintroduce los providers necesarios en la llamada a forRoot según tu política interna.

Pruebas

Usa los comandos habituales del monorepo para ejecutar tests o lint si están configurados:

ng test
ng lint

Contribución

  1. Crea un branch con tu cambio.
  2. Añade tests que cubran la nueva funcionalidad o fixes.
  3. Abre un PR describiendo la motivación.

Licencia

Consulta la política de tu organización para la licencia de esta librería.


Si necesitas que añada ejemplos adicionales (por ejemplo, cómo integrar interceptores o usar forRoot desde un componente standalone), lo hago en la siguiente iteración.