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

erp-core-next

v0.2.0

Published

Núcleo standalone, sin NgModules y basado en signals para apps Angular: stores reactivos, capa HTTP funcional, guards y dos modos de arranque (gestor/consumer).

Readme

erp-core-next

Núcleo standalone, sin NgModules y basado en signals para apps Angular 20+ del ERP Visorus. Reemplaza a la lib legacy erp-core (Angular 7→17) con stores reactivos, una capa HTTP funcional y dos modos de arranque: gestor (provideErpCore) y consumer (provideErpCoreConsumer), pensados para coexistir sin big-bang (patrón strangler fig).

Documentación completa (arquitectura, modelos, stores, HTTP, providers, migración) en docs/erp-core-next/.


Instalación

Construye la lib y empaquétala:

npm run pack:lib                          # → dist/erp-core-next/erp-core-next-<version>.tgz

En el host instálala desde el tarball (o desde tu registry):

npm install [email protected]   # o desde el tarball: ../erp-core-next/dist/erp-core-next/erp-core-next-0.2.0.tgz

Peer dependencies: @angular/common, @angular/core y @angular/router ^20.0.0 || ^21.0.0, más rxjs ^7.8.


Uso básico

Modo GESTOR — provideErpCore(config, options?)

Para el host principal. Recibe la configuración del backend y, opcionalmente, opciones (p. ej. coexistMode para convivir con la lib vieja registrando solo authInterceptor).

// app.config.ts
import { ApplicationConfig } from '@angular/core';
import {
  provideErpCore,
  NOTIFICATION_SERVICE,
  LOGIN_PROMPT_PORT,
  type NotificationPort,
} from 'erp-core-next';

const notifications: NotificationPort = {
  success: (m, t) => console.log('[notify] success', t ?? '', m),
  info:    (m, t) => console.log('[notify] info',    t ?? '', m),
  warning: (m, t) => console.log('[notify] warning', t ?? '', m),
  error:   (p, t) => console.log('[notify] error',   t ?? '', p),
};

export const appConfig: ApplicationConfig = {
  providers: [
    // coexistMode: true → sólo authInterceptor (loading/error/response siguen siendo del host viejo)
    provideErpCore({ apiUrl: 'https://api.midominio.com' }, { coexistMode: true }),
    { provide: NOTIFICATION_SERVICE, useValue: notifications },
    { provide: LOGIN_PROMPT_PORT,    useValue: { prompt: () => console.log('[login] prompt') } },
  ],
};

AppConfig: { apiUrl: string; assetsUrl?: string; storageKey?: string; host?: string }. ErpCoreOptions: { extraInterceptors?; enableSuccessNotifications?; storage?; coexistMode? }.

Modo CONSUMER — provideErpCoreConsumer(options?)

Para subproyectos del ERP que consumen la sesión que dejó el lanzador (no gestionan login/empresa/módulo). Lee assets/config.json al arranque y localStorage('usuario') (vía LegacyTokenStorage, solo lectura: el lanzador es dueño de la sesión).

import { provideErpCoreConsumer, NOTIFICATION_SERVICE, LOGIN_PROMPT_PORT } from 'erp-core-next';

export const appConfig: ApplicationConfig = {
  providers: [
    provideErpCoreConsumer({
      coexistMode: true,                    // solo authInterceptor (lib vieja viva)
      enableSuccessNotifications: true,     // toast «Exito» por body.success
      configSource: 'launcher-first',       // localStorage('config') primero (L4)
      hydrateProfile: true,                 // loadProfile() al arranque si hay token
    }),
    { provide: NOTIFICATION_SERVICE, useValue: notifications },
    { provide: LOGIN_PROMPT_PORT,    useValue: { prompt: () => console.log('[login] prompt') } },
  ],
};

ErpCoreConsumerOptions: { extraInterceptors?; coexistMode?; enableSuccessNotifications?; hydrateProfile?; configSource?: 'assets-first' | 'launcher-first' } (default: cadena completa, sin toasts de éxito, hidrata perfil, assets-first).

Desde 0.2.0, en modo consumer el token no queda congelado al arrancar (L1): authorizationHeader() relee localStorage('usuario') en cada petición — un relogin del lanzador en otra pestaña o un 401 transitorio no dejan a los servicios migrados sin header. El ciclo de carga del perfil se publica en AuthStore.profileStatus ('idle' | 'loading' | 'loaded' | 'error', L3) para que el host replique la política de «si falla el perfil → volver al lanzador».

import { provideErpCoreConsumer, NOTIFICATION_SERVICE, LOGIN_PROMPT_PORT } from 'erp-core-next';

export const appConfig: ApplicationConfig = {
  providers: [
    provideErpCoreConsumer(),
    { provide: NOTIFICATION_SERVICE, useValue: notifications },
    { provide: LOGIN_PROMPT_PORT,    useValue: { prompt: () => console.log('[login] prompt') } },
  ],
};

public/assets/config.json (servido en /assets/config.json):

{ "url": "https://erpb.visorus.com/api", "host": "https://erp.visorus.com" }

CRUD en el host — BaseApiService<T>

El host crea sus servicios extendiendo BaseApiService<T>:

import { Injectable } from '@angular/core';
import { BaseApiService, type Empresa } from 'erp-core-next';

@Injectable({ providedIn: 'root' })
export class EmpresasService extends BaseApiService<Empresa> {
  protected readonly resource = 'empresas';   // → GET {apiUrl}/empresas
}
// métodos: getAll, getPage, get, create, update, remove

API pública (exports)

| Grupo | Símbolos | |---|---| | Providers | provideErpCore, provideErpCoreConsumer, ErpCoreOptions, ErpCoreConsumerOptions · testing: provideErpCoreTesting (entry secundario erp-core-next/testing) | | Stores | ConfigStore, AuthStore (incl. profileStatus, ProfileStatus), LoadingStore, AccessControlStore | | HTTP | BaseApiService, authInterceptor, loadingInterceptor, responseInterceptor, errorInterceptor, SKIP_AUTH, SUPPRESS_LOADING, normalizeError | | Guards | authGuard, consumerAuthGuard (sin sesión → redirectToHost), roleGuard | | Tokens / Puertos | APP_CONFIG, CLOCK, NOTIFICATION_SERVICE (NotificationPort), LOGIN_PROMPT_PORT (LoginPromptPort), ERP_CONSUMER_MODE | | Storage | TokenStorage (abstracta), LocalStorageTokenStorage, InMemoryTokenStorage, LegacyTokenStorage | | Consumer utils | loadAppConfig, readLauncherConfig, setResolvedConfig, appConfigFactory, redirectToHost, AppConfig | | Auth models | AuthToken, AuthTokenDto, toAuthToken, isTokenExpired, toAuthorizationHeader, LoginRequest, User, UserDetails, Role, Authority, Empresa, ModuloAcceso, LegacyUsuarioDto, normalizeLegacyRoles | | Common models | ID, Page, PageRequest, ApiResponse, ApiError, NormalizedError, HttpErrorCode, isApiError | | Domain models | PersonaFisica, PersonaMoral, DatoContacto, DatoDireccion, createPersonaMoral |


Coexistencia con la lib vieja (coexistMode)

Durante la migración, coexistMode: true hace que el core registre solo authInterceptor (loading/error/response siguen siendo del host viejo), evitando dobles spinners y toasts. El authInterceptor respeta una cabecera Authorization preexistente (no la duplica), lo que permite que CrudService viejo y servicios nuevos convivan. Ver MIGRATION-CHECKLIST.md Fase 1.


Supuestos del backend aún sin confirmar

De HTTP-ADVANCED.md §"Supuestos". Mientras no se confirmen, estas features quedan desactivadas (enableRefresh: false, retryPolicy: undefined).

  1. [CONFIRMAR] Endpoint de refresh: se asume POST {apiUrl}/token/refresh con body { refresh_token }, retornando un AuthTokenDto (mismo contrato que /login). Ajustar refreshEndpoint.
  2. [CONFIRMAR] Rotación del refresh token: se asume que cada refresh devuelve un nuevo refresh_token. Si no rota, el refresh sigue funcionando (reutiliza el mismo).
  3. [CONFIRMAR] Semántica del 401: se asume que 401 = "access token expirado/inválido y refrescable". Si el backend distingue "refresh token inválido" con un código/sub-código, añadir ese check para ir directo a logout.
  4. [CONFIRMAR] Idempotencia: se asume GET/HEAD/OPTIONS como seguros para retry. Ajustar si el backend tiene endpoints POST idempotentes explícitos.

Desarrollo

ng build erp-core-next   # verde obligatorio tras cada cambio
ng test erp-core-next    # Vitest (@angular/build:unit-test)