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

@adhd/apigen-base-logical

v0.1.1

Published

The **contract spine** for apigen's schema-driven, registry-based logical-type transcoding — one mechanism that round-trips every non-JSON-native value (well-known scalars like `Date`/`int64`/`decimal`/`bytes`/`UUID`, plus user classes and discriminated u

Downloads

2,126

Readme

@adhd/apigen-base-logical

The contract spine for apigen's schema-driven, registry-based logical-type transcoding — one mechanism that round-trips every non-JSON-native value (well-known scalars like Date/int64/decimal/bytes/UUID, plus user classes and discriminated unions) over the JSON wire, identically across host languages.

Status: contract spine only. This package currently exports interfaces (the codec/registry/transcoder contracts and the descriptor extension vocabulary). Codec bodies, the schema-walking transcoder, and per-host bindings are later plan states — see docs/plan/apigen-base-logical-types/DESIGN.md §4/§5/§11–§14.

  • Platform: shared (pure TypeScript — safe in a Node CLI and a browser).
  • Layer: logic.

Surface

| Export | What it is | | ------------------------------------------------------------------ | --------------------------------------------------------------------------------- | | LogicalTypeId, LogicalKind, Wire, SchemaNode | Core type aliases (DESIGN §4.2). | | TranscodeCtx, LogicalTypeCodec | The host-agnostic codec contract (DESIGN §4.2). | | LogicalTypeRegistry, createRegistry, CodecRegistryError | The registry contract + minimal dup-detecting stub (DESIGN §4.3). | | Transcoder | The schema-walking transcoder interface (impl is a later state, DESIGN §4.4). | | ENVELOPE_KEY, ApigenEnvelope | The self-describing envelope for schema-less positions (DESIGN §4.5). | | TemplateCell | Per-language codegen cell shape (DESIGN §13.1). | | X_APIGEN_*, LOGICAL_TYPE_VERSION, logicalKindOf, codecIdOf | Descriptor extension vocabulary + advisory hint readers (DESIGN §4.1). |

Invariant [inv:hints-advisory]

The x-apigen-* descriptor keys are optional dispatch accelerators — structure (format/$ref/oneOf) is authoritative. logicalKindOf and codecIdOf therefore return undefined (never throw) when a key is absent or malformed; correctness must never depend on a hint being present.

Schema example synthesis (shipped, unlike the contract-spine surface above)

synthesizeExample(schema) / renderExampleNote(schema) — generates a concrete, plausible example value from any JSON Schema: walks properties/ required, resolves $ref against the schema's own definitions/$defs, picks a oneOf/anyOf branch, merges allOf, and produces format-aware placeholders (date-time, uuid, email, decimal, int64, byte, etc.) that satisfy ajv-formats. Every synthesized shape round-trips through real AJV validation in this package's own tests.

This exists to solve a concrete discoverability problem: an apigen-mounted MCP tool's description/error used to only describe the shape of a valid call ("all domain parameters go inside a data envelope"), never a worked example with real field names — so callers repeatedly got the call shape wrong on the first try. renderExampleNote is consumed by:

  • @adhd/apigen-engine-runtime's buildToolDescription — appends a synthesized example to every apigen-mounted tool's description.
  • @adhd/apigen-engine-runtime's validate-Layer — appends the same synthesized example to AJV validation-failure error messages, so a rejected call comes back with both what was wrong and a working example.

Because synthesis is schema-driven (not hand-written per tool), it covers every current and future apigen-mounted MCP tool automatically, including mount-derived tools (e.g. apigen-plugin-batch's _batch/<kind> mounts) whose top-level shape differs from the {data:{...}} envelope regular extracted operations use — the synthesized example always reflects each tool's own real, advertised schema, never an assumed universal convention.

import { renderExampleNote } from '@adhd/apigen-base-logical';

renderExampleNote(someOperation.input);
// → 'Example: {"data":{"input":{"family":"<string>","title":"<string>","body":"<string>","repo":"<string>"}}}'