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

@dcsv-io/d2-request-context-abstractions

v0.1.2

Published

<!-- Copyright (c) DCSV. Licensed under the Apache License, Version 2.0. -->

Readme

@dcsv-io/d2-request-context-abstractions

IRequestContext interface (extends IAuthContext) + IPropagatedContext cross-hop subset + PropagatedContextSerializer round-trip helper. Emitted from contracts/request-context/IRequestContext.spec.json via the request-context spec (sources committed). Mirrors DcsvIo.D2.Context.Abstractions (.NET).

Install

pnpm add @dcsv-io/d2-request-context-abstractions

Public API

Generated artifacts (committed to git):

| Export | Source | | ----------------------------- | -------------------------------------------------------------------- | | IRequestContext | IRequestContext.g.ts | | IRequestContextRedactPaths | IRequestContext.g.ts (PII paths from spec redact: true) | | IPropagatedContext | IPropagatedContext.g.ts (cross-hop subset, propagate: true only) | | PropagatedContextSerializer | PropagatedContextSerializer.g.ts (serialize + tryDecode) |

Plus all @dcsv-io/d2-auth-context-abstractions exports re-exported transitively.

Codegen workflow

prebuild runs the request-context-emit.ts script before tsc -b, so pnpm -r build regenerates transparently. The emitter reuses the emitAuthContext core for the interface + emits the additional propagated artifacts.

The emitter honors the spec's extends field: when set (as it is for IRequestContext.spec.json:6 "extends": "DcsvIo.D2.AuthContext.Abstractions.IAuthContext"), the generated IRequestContext.g.ts declares export interface IRequestContext extends IAuthContext { ... } and emits a import type { IAuthContext } from "@dcsv-io/d2-auth-context-abstractions"; line at the top. Consumers see the unified IRequestContext shape as a single import — IAuthContext properties are inherited transitively.

Dependencies

  • @dcsv-io/d2-auth-context-abstractionsIAuthContext + supporting enums.

Usage example

import {
  PropagatedContextSerializer,
  IRequestContextRedactPaths,
} from "@dcsv-io/d2-request-context-abstractions";
import { setupLogger } from "@dcsv-io/d2-logging";

// Encode envelope for cross-hop propagation.
const envelope = PropagatedContextSerializer.serialize(propagatedCtx);
amqpHeaders["x-d2-context"] = envelope;

// Decode incoming envelope (returns undefined on tamper / oversize).
const decoded = PropagatedContextSerializer.tryDecode(headers["x-d2-context"]);

// Wire PII paths into Pino redaction.
const log = setupLogger({
  serviceName: "edge",
  redactPaths: [IRequestContextRedactPaths],
});

Parity with .NET

Mirrors DcsvIo.D2.Context.Abstractions:

  • IRequestContext ↔ same property set, camelCased.
  • PropagatedContextSerializer ↔ 1:1 type-named class with Serialize/Deserialize.
  • IPropagatedContext ↔ same propagated subset.

Nullability convention

Canonical nullability rule (same as @dcsv-io/d2-auth-context-abstractions): IRequestContext extends IAuthContext and inherits the same spec-driven T | null emission for spec-emitted property types (the spec's ? suffix on a type entry — e.g. "string?" in IRequestContext.spec.json — triggers the | null emission).

Edge cases

  • tryDecode enforces per-field maxLength caps from the spec — a forged envelope with any cap exceeded is dropped wholesale (returns undefined). Propagation is opportunistic, never required.
  • tryDecode type-checks numeric / boolean fields and rejects on shape mismatch.
  • null values survive serialize → deserialize without becoming the string "null".
  • Generated files (*.g.ts) are committed to git.