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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cbm-common/email-settings-repository

v0.0.2

Published

Esta librería proporciona un cliente HTTP para manejar las configuraciones de correo (email settings) del backend. Está pensada para integrarse en aplicaciones Angular del monorepo y ofrece operaciones comunes: listado, creación, obtención por id, actuali

Readme

Email Settings Repository

Esta librería proporciona un cliente HTTP para manejar las configuraciones de correo (email settings) del backend. Está pensada para integrarse en aplicaciones Angular del monorepo y ofrece operaciones comunes: listado, creación, obtención por id, actualización, eliminación y creación masiva.

Contenido principal

  • CbmEmailModule — token de configuración EMAIL_MODULE_CONFIG que permite inyectar la URL base mediante forRoot.
  • CbmEmailSettingsService — servicio que expone los métodos para consumir la API (usa HttpClient internamente y la baseUrl inyectada).
  • email-settings.model.ts — definición de los tipos/contratos (parámetros y respuestas) que utiliza el servicio.

Requisitos

  • Angular 20.x
  • HttpClientModule disponible en la aplicación consumidora

Construcción e instalación

  • Para compilar la librería desde la raíz del workspace:
ng build email-settings-repository
  • Para publicar (opcional):
cd dist/email-settings-repository
npm publish

Configuración del módulo (inyección de baseUrl)

La librería expone el token EMAIL_MODULE_CONFIG y un helper CbmEmailModule.forRoot(config) que devuelve un proveedor para inyectar la configuración. Registra el proveedor en tu AppModule así:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CbmEmailModule } from 'email-settings-repository';

@NgModule({
  imports: [BrowserModule],
  providers: [
    CbmEmailModule.forRoot({ baseUrl: 'https://api.example.com/email-settings' })
  ],
})
export class AppModule {}

Nota: la librería sigue el patrón de inyección por token; la configuración se registra como proveedor y el servicio la inyecta mediante EMAIL_MODULE_CONFIG.

Uso del servicio

Importa y usa CbmEmailSettingsService desde la librería (sin prefijo) en tus componentes o servicios. Ejemplo básico:

import { Component, OnInit } from '@angular/core';
import { CbmEmailSettingsService } from 'email-settings-repository';
import { CbmEmailSettingsModel } from 'email-settings-repository';

@Component({ /* ... */ })
export class ExampleComponent implements OnInit {
  constructor(private readonly service: CbmEmailSettingsService) {}

  ngOnInit() {
    // Usa los tipos desde la librería, no "any"
    const params: CbmEmailSettingsModel.ListParams = { /* llenar según modelo */ };
    this.service.list(params).subscribe(res => console.log(res));
  }

  create() {
    const body: CbmEmailSettingsModel.SaveOneBody = { /* ... */ };
    this.service.saveOne(body).subscribe();
  }
}

Resumen de API expuesta por CbmEmailSettingsService

  • list(params: ListParams): Observable<ListResponse> — listado/paginado.
  • saveOne(body: SaveOneBody): Observable<ConfirmResponse> — crear un registro.
  • getOne(id: string): Observable<GetOneResponse> — obtener un registro por id.
  • update(id: string, body: UpdateBody): Observable<ConfirmResponse> — actualizar.
  • delete(id: string): Observable<ConfirmResponse> — eliminar.
  • saveMany(data: SaveManyBody[]): Observable<ConfirmResponse> — crear varios registros de forma masiva.

Modelos y tipos

  • Revisa projects/email-settings-repository/src/lib/email-settings.model.ts para ver las interfaces exactas (ListParams, ListResponse, SaveOneBody, UpdateBody, SaveManyBody, ConfirmResponse, etc.). Usar estos tipos evita any y mejora la seguridad de tipos en tu código.

Notas de integración y buenas prácticas

  • Importa HttpClientModule en el AppModule o en el módulo donde vayas a usar CbmEmailSettingsService.
  • El servicio está declarado con providedIn: 'root' (librería), por lo que no es necesario añadirlo manualmente a providers.
  • Si tu aplicación requiere interceptores o un EmailHttpService personalizado, regístralos en la app que consume la librería o solicita que la librería los exponga explícitamente.

Pruebas y validación

  • Ejecutar tests unitarios del workspace:
ng test
  • Compilar la librería para validar cambios:
ng build email-settings-repository

Preguntas frecuentes

  • ¿Dónde configuro la URL base? — Usa CbmEmailModule.forRoot({ baseUrl: '...' }) en providers del AppModule.
  • ¿Cómo evito any? — Importa los tipos desde email-settings-repository/src/lib/email-settings.model.ts y úsalos en tus componentes/servicios.

Contribuciones

  • Para contribuir, abre un PR en el repositorio del monorepo y sigue las convenciones del proyecto (lint, tests, formateo).

Más información

  • Revisa los archivos fuente en projects/email-settings-repository/src/lib para comprender comportamiento y tipos.

Documentación actualizada y localizada al español.