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/account-repository

v0.0.1

Published

This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.1.0.

Readme

AccountRepository

This project was generated using Angular CLI version 20.1.0.

Code scaffolding

Angular CLI includes powerful code scaffolding tools. To generate a new component, run:

ng generate component component-name

For a complete list of available schematics (such as components, directives, or pipes), run:

ng generate --help

Building

To build the library, run:

# AccountRepository — Librería de cuentas (CBM)

Este paquete contiene la implementación cliente para consumir los endpoints relacionados con cuentas contables del backend de CBM.

Está pensado para usarse como una librería Angular que exporta:

- `CbmAccountModule` — Módulo que expone el token de configuración `ACCOUNT_MODULE_CONFIG` y un `forRoot` para suministrar `baseUrl`.
- `CbmAccountService` — Servicio que realiza las llamadas HTTP a los endpoints de cuentas usando `HttpClient`.
- `CbmAccountRepository` — Repositorio que delega las llamadas al servicio y expone una interfaz tipada.
- Tipos y modelos en `CbmAccountModel`.

## Instalación y uso

1) Agrega la librería a tu proyecto (si la instalas desde el registro npm o la construyes y enlazas localmente).

2) Importa y configura el módulo en el módulo raíz de tu aplicación, pasando `baseUrl` que apunta al endpoint de cuentas en el backend:

```ts
import { CbmAccountModule } from 'mf-cbm-common/projects/account-repository';

@NgModule({
   imports: [
      CbmAccountModule.forRoot({ baseUrl: 'https://api.example.com/accounts' }),
   ],
})
export class AppModule {}

Nota: forRoot devuelve un Provider que expone el token ACCOUNT_MODULE_CONFIG con la propiedad baseUrl.

API pública (resumen)

Los métodos principales están disponibles en CbmAccountRepository y CbmAccountService:

  • list(params: ListParams): Observable

    • Obtiene una lista sencilla de cuentas.
    • Parámetros: account_group?, move?, filter?.
  • listPaginated(params: ListPaginatedParams): Observable

    • Obtiene una lista paginada.
    • Parámetros: size, page, account_group_id?, move?, filter?, enabled?, number_of_groups?.
  • getOne(id: string): Observable

    • Obtiene una cuenta por su _id.
  • getOneByCode(code: string): Observable

    • Obtiene una cuenta por su code.
  • save(data: SaveBody): Observable

    • Crea una nueva cuenta.
  • update(id: string, data: UpdateBody): Observable

    • Actualiza una cuenta existente.
  • changeStatus(id: string, data: ChangeStatusBody): Observable

    • Habilita/deshabilita una cuenta.
  • delete(id: string): Observable

    • Elimina una cuenta.
  • downloadExcelTemplate(): Observable

    • Descarga la plantilla Excel para importación.
  • importExcel(data: FormData): Observable

    • Importa cuentas desde un archivo Excel enviado como FormData.
  • downloadExcel(): Observable<HttpResponse>

    • Descarga un reporte Excel (retorna HttpResponse<Blob> para leer headers y el cuerpo).
  • updateCodes(id: string): Observable

    • Actualiza códigos relacionados con una cuenta.

Para detalles de tipos y estructuras de respuesta revisa src/lib/account.model.ts.

Modelos y tipos importantes

  • CbmAccountModel.ListParams — Parámetros para list.
  • CbmAccountModel.ListPaginatedParams — Parámetros para listPaginated (incluye size y page).
  • CbmAccountModel.SaveBody — Cuerpo para crear una cuenta (campos: group_countable_id, company_id, code, name, code_father, level, move, confidential, description).
  • CbmAccountModel.UpdateBody — Cuerpo parcial para actualizar.
  • CbmAccountModel.ConfirmResponse — Estructura estándar de confirmación del backend (success, message, data?).

Consulta projects/account-repository/src/lib/account.model.ts para la lista completa de campos y tipos retornados.

Ejemplos rápidos

  • Listado simple:
this.accountRepo.list({ filter: 'Caja' }).subscribe(res => {
   if (res.success) console.log(res.data);
});
  • Obtener paginación:
this.accountRepo.listPaginated({ size: 20, page: 1 }).subscribe(res => {
   if (res.success) console.log(res.items, res.total);
});
  • Subir Excel (import):
const form = new FormData();
form.append('file', file);
this.accountRepo.importExcel(form).subscribe(result => console.log(result));

Buenas prácticas

  • Proveer un baseUrl que termine sin / para evitar dobles barras al concatenar rutas.
  • Manejar las respuestas de descarga (Blob) leyendo responseType y observe cuando necesites headers.

Desarrollo y pruebas

Comandos útiles dentro del workspace (Angular CLI):

# Compilar la librería
ng build account-repository

# Ejecutar tests (si los hay)
ng test

Contribuir

Si vas a extender o modificar la librería: crea ramas con PRs, añade tests unitarios para los nuevos comportamientos y mantén la documentación actualizada.


Si quieres que agregue ejemplos de integración más detallados o que genere tests unitarios de ejemplo para CbmAccountService, dímelo y los añado.