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

v0.0.1

Published

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

Downloads

4

Readme

ServiceRepository

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

Resumen

  • Propósito: Proveer una capa para consumir y gestionar recursos de "servicio" (service) vía HTTP.
  • Paquete: @cbm-common/service-repository (ver package.json).
  • Requisitos: @angular/core y @angular/common v20.1.5 y HttpClientModule en la app consumidora.

Qué exporta

  • Exports públicos: index, service.model, service.module, service.repository, service.service (ver src/public-api.ts).

Configuración del módulo

El módulo principal expone CbmServiceModule.forRoot(config) para inyectar la configuración de base URL.

  • Interfaz de configuración: ICbmServiceModuleConfig { baseUrl: string }.
  • Token de inyección: SERVICE_MODULE_CONFIG (InjectionToken).

Ejemplo de registro en la app consumidora:

import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { CbmServiceModule } from '@cbm-common/service-repository';

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

Servicio y repositorio

  • CbmServiceService: servicio que implementa las llamadas HTTP.
  • CbmServiceRepository: repositorio inyectable que delega en CbmServiceService y expone la API para la aplicación.

Comportamiento del servicio (CbmServiceService)

  • Construye las rutas a partir de config.baseUrl y elimina slashes finales.
  • Endpoints y métodos disponibles:
    • list(params: ListParams): GET ${baseUrl} -> devuelve CbmServiceModel.ListResponse.
    • getOne(id: string): GET ${baseUrl}/{id} -> GetOneResponse.
    • getOneByCode(code: string): GET ${baseUrl}/code/{code} -> GetOneResponse.
    • save(data: SaveBody): POST ${baseUrl} -> ConfirmResponse.
    • update(id, data): PUT ${baseUrl}/{id} -> ConfirmResponse.
    • changeStatus(id, data): PUT ${baseUrl}/change-status/{id} -> ConfirmResponse.
    • restore(id, data): PUT ${baseUrl}/restore/{id} -> ConfirmResponse.
    • delete(id): DELETE ${baseUrl}/{id} -> ConfirmResponse.
    • downloadExcel(params): GET ${baseUrl}/download/excel (blob response).
    • downloadExcelCreateTemplate(): GET ${baseUrl}/download/excel/carga (blob response).
    • importExcelCreate(formData): POST ${baseUrl}/upload/service (multipart form-data).
    • downloadIndividualPdf(id): GET ${baseUrl}/download/pdf/individual/{id} (blob response).

Tipos y modelos (CbmServiceModel)

Los modelos están definidos en src/lib/service.model.ts. Resumen de los tipos más relevantes:

  • ListParams: parámetros de paginación y filtros (page, size, company_branch_id, category_id, name, enabled, deleted, etc.).
  • ListResponse: respuesta paginada con items que contienen campos como _id, code, name, iva, tax_ice, price_lists, etc.
  • GetOneResponse: datos detallados del servicio (price_list_service, detail_provider_service, tax_iva, etc.).
  • SaveBody / UpdateBody: payloads para crear/actualizar servicios (category_id, tax_iva_id, cost, code, name, iva, price lists, provider services, etc.).
  • DownloadExcelParams: filtros para generar reportes en Excel.
  • ChangeStatusBody: { enabled: boolean; disabled_reason?: string }.
  • ConfirmResponse: { success: boolean; message: string; data?: any }.

Ejemplo de uso (inyección y llamada)

import { Component, OnInit } from '@angular/core';
import { CbmServiceRepository, CbmServiceModel } from '@cbm-common/service-repository';

@Component({ selector: 'app-demo', template: '' })
export class DemoComponent implements OnInit {
   constructor(private repo: CbmServiceRepository) {}

   ngOnInit() {
      this.repo.list({ page: 1, size: 20 }).subscribe(res => console.log(res.items));
   }
}

Notas de implementación

  • El módulo ahora exporta SERVICE_MODULE_CONFIG igual que otras librerías del mono-repo. Se resolvió el uso directo de HttpClient y la construcción de rutas con config.baseUrl.
  • CbmServiceRepository simplemente delega en CbmServiceService manteniendo contratos tipados definidos en CbmServiceModel.

Build y publicación

Desde la raíz del workspace, compilar la librería:

ng build service-repository

Los artefactos se generarán en dist/service-repository. Para publicar (si procede):

cd dist/service-repository
npm publish

Tests

  • Ejecutar tests unitarios en el workspace con ng test si están configurados.

Notas finales y siguientes pasos sugeridos

  • Verificar proyectos consumidores que usen CbmServiceModule.forRoot({...}) y actualizar la configuración si es necesario.
  • Añadir pruebas unitarias para CbmServiceService (mock de HttpClient) y para CbmServiceRepository.
  • Documentar errores HTTP comunes y recomendaciones para el manejo de errores en la capa de repositorio.

Estado: README.md actualizado con documentación en español y ejemplos basados en los archivos fuente actuales.

ServiceRepository

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:

ng build service-repository

This command will compile your project, and the build artifacts will be placed in the dist/ directory.

Publishing the Library

Once the project is built, you can publish your library by following these steps:

  1. Navigate to the dist directory:

    cd dist/service-repository
  2. Run the npm publish command to publish your library to the npm registry:

    npm publish

Running unit tests

To execute unit tests with the Karma test runner, use the following command:

ng test

Running end-to-end tests

For end-to-end (e2e) testing, run:

ng e2e

Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.

Additional Resources

For more information on using the Angular CLI, including detailed command references, visit the Angular CLI Overview and Command Reference page.