Shared packages
Shared packages overview
Package catalogs, drains, enrichers, and framework integrations as reusable npm libraries — same scaffolding pattern for each, type-level discoverability flows transitively to consumers.
evlog's extension surfaces are pure TypeScript: any plugin, drain, enricher, or catalog you can write in your own project, you can also publish as an npm package and import it from another project. This is how you scale evlog across many apps in your organization without copy-pasting code.
Same pattern for every type:
- Define the artifact (catalog, drain, enricher, integration) in
src/ - Add a
declare module 'evlog'augmentation when type-level discoverability is useful - Build dual
.mjs+.d.mtswith tsdown (or any bundler that emits these) - List
evlogas apeerDependency
Pages here
| What | When | |
|---|---|---|
| Catalogs as packages | Publish a typed error / audit catalog | Several services share the same error vocabulary |
| Drains as packages | Publish a custom drain (a new provider, an internal API…) | You ship the same destination from many apps |
| Enrichers as packages | Publish a custom enricher (geo, tenant, deploy id…) | Multiple apps need the same derived context |
| Integration as package | Publish a custom framework integration (a new HTTP runtime, a queue worker…) | You support runtime X and want others to benefit |
Why bother
Three concrete wins :
- Single source of truth — one repo owns the artifact; consumers bump a version
- Type-level discoverability —
declare module 'evlog'propagates to consumers via the published.d.mts - Documented intent —
why,fix,severity, etc. ride along with the type, not in a wiki
Examples to ship
@my-org/evlog-stripe-errors— error catalog matching every Stripe API code@my-org/evlog-tenant-enricher— pullsx-tenant-idfrom headers on every event@my-org/evlog-fly-region— addsregion: process.env.FLY_REGIONto every event@my-org/evlog-internal-loki— drain that ships to your internal Loki instance@my-org/evlog-medusa— framework integration for Medusa.js
Cross-app error vocab
One `@my-org/evlog-errors` package every service depends on — same error codes, same `why` / `fix` strings, type-safe everywhere.
Catalogs as packages
Package an error catalog or audit catalog as a reusable npm module — `@my-org/evlog-stripe-errors`, `@my-org/evlog-aws-audit`, etc.