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/client-category-repository

v0.0.1

Published

Documentación en español de la librería `client-category-repository`.

Downloads

10

Readme

@cbm-common/client-category-repository

Documentación en español de la librería client-category-repository.

Resumen

  • Paquete: @cbm-common/client-category-repository
  • Versión: 0.0.1 (ver package.json)
  • Compatibilidad: Angular 20.x (declared en peerDependencies)

Descripción

Esta librería expone modelos TypeScript, un servicio HTTP y un repositorio para interactuar con la API de categorías de cliente (Client Category). Está pensada para usarse desde la aplicación del monorepo o desde otros proyectos que consuman el paquete.

Contenido principal

  • CbmClientCategoryModule — Módulo con un InjectionToken (CLIENT_CATEGORY_MODULE_CONFIG) que acepta la configuración { baseUrl: string } mediante forRoot.
  • CbmClientCategoryService — Servicio que usa HttpClient y la configuración del módulo para llamar a los endpoints (list, save, update, getOne, changeStatus, delete, validateAccount).
  • CbmClientCategoryRepository — Repositorio que implementa una interfaz (ICbmClientCategoryRepository) y delega en el servicio. Registrado como provider (providedIn: 'root').
  • client-category.model.ts — Tipos e interfaces para parámetros y respuestas (ej. ListParams, ListResponse, SaveBody, UpdateBody, ConfirmResponse).

Instalación y configuración

En el contexto del monorepo, importa y configura el módulo en el AppModule o en un módulo compartido:

import { CbmClientCategoryModule } from '@cbm-common/client-category-repository';

@NgModule({
  imports: [
    CbmClientCategoryModule.forRoot({ baseUrl: 'https://api.tu-dominio.com/client-category' }),
  ],
})
export class AppModule {}

El objeto de configuración esperado es:

interface ICbmClientCategoryModuleConfig { baseUrl: string }

API pública (resumen)

Tipos clave (resumen desde client-category.model.ts):

  • ListParams — { enabled?: boolean; name?: string; group_id?: string }
  • ListResponse — { success: boolean; data: Array<{ _id: string; name: string; company_id: string; group_id: string; receivable_account_id: string; advanced_account_id: string; enabled: boolean; created_user: string; created_at: number; updated_at: number; updated_user: string }> }
  • SaveBody / UpdateBody — campos para crear/actualizar (nota: el modelo contiene advanced_acount_id en algunos lugares, revisar backend si eso es un typo)
  • ConfirmResponse — { success: boolean; message: string; data?: any }

Clases y métodos principales

  • CbmClientCategoryRepository (uso recomendado desde componentes):
    • list(params: ListParams): Observable<ListResponse> — Lista las categorías según filtros.
    • save(data: SaveBody): Observable<ConfirmResponse> — Crea una categoría.
    • update(id: string, data: UpdateBody): Observable<ConfirmResponse> — Actualiza una categoría.
    • getOne(id: string): Observable<GetOneResponse> — Obtiene los detalles de una categoría.
    • changeStatus(id: string, data: ChangeStatusBody): Observable<ConfirmResponse> — Cambia estado habilitado/deshabilitado.
    • delete(id: string): Observable<ConfirmResponse> — Elimina una categoría.
    • validateAccount(id: string): Observable<ValidateAccountResponse> — Valida alguna cuenta asociada (según implementación backend).

Ejemplos de uso

Suscripción básica:

constructor(private repo: CbmClientCategoryRepository) {}

ngOnInit() {
  this.repo.list({ name: 'Retail', enabled: true }).subscribe(res => {
    if (res.success) console.log(res.data);
  });
}

Uso con firstValueFrom:

import { firstValueFrom } from 'rxjs';

const res = await firstValueFrom(this.repo.list({}));
console.log(res.data);

Crear registro:

this.repo.save({
  group_id: 'G1',
  name: 'Minorista',
  receivable_account_id: 'AC-001',
  advanced_acount_id: 'AC-002'
}).subscribe(resp => console.log(resp));

Notas técnicas y recomendaciones

  • Mantén los tipos definidos en client-category.model.ts cuando consumas la API — evita any.
  • El campo advanced_acount_id aparece en los modelos; verifica con el backend si debe ser advanced_account_id y, de ser necesario, actualiza el modelo y los consumidores.
  • Si necesitas interceptores HTTP o un HttpService especializado, puedes registrarlo en el forRoot del módulo o proporcionar los providers en un módulo compartido.

Build y publicación

Para compilar la librería dentro del monorepo:

ng build client-category-repository

Los artefactos se generarán en dist/client-category-repository. Para publicar (opcional):

cd dist/client-category-repository
npm publish

Tests

Ejecuta los tests del workspace con:

ng test

Dependencias y compatibilidad

  • Revisa package.json para peerDependencies (Angular 20.x) y dependencies.

Contribuciones

  • Añade tests unitarios cuando modifiques comportamiento público.
  • Documenta cambios incompatibles en CHANGELOG.md.

Soporte y siguientes pasos sugeridos

Si quieres, puedo:

  • Añadir ejemplos en EXAMPLES.md con snippets de componentes que consumen la librería.
  • Proponer y aplicar la corrección de advanced_acount_id si confirmas que es un error tipográfico.