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

@idiolect-dev/schema

v0.7.0

Published

Runtime validators, types, and NSIDs for the dev.idiolect.* Lexicon family.

Downloads

1,468

Readme

@idiolect-dev/schema

TypeScript validators, record types, and NSID constants for the dev.idiolect.* lexicon family.

Overview

The TypeScript twin of idiolect-records, generated from the same lexicons under lexicons/dev/idiolect/. CI rejects drift between the two packages. Three shipped surfaces:

  • TypesEncounter, Correction, Bounty, … per record kind, plus shared types from defs.
  • NSID constantsNSID.encounter"dev.idiolect.encounter", for switching on a record's collection at runtime.
  • ValidatorsvalidateRecord, isRecord, classifyRecord, tagRecord for runtime structural checks and typed unions.

Architecture

flowchart LR
    LEX["lexicons/dev/idiolect/*.json"]
    CG["idiolect-codegen<br/>(Rust binary)"]

    subgraph pkg["@idiolect-dev/schema"]
        GEN["src/generated/<br/>(types · validators · NSID)"]
        API["isRecord · classifyRecord<br/>tagRecord · validateRecord"]
        FIX["EXAMPLES (fixtures)"]
        LEXDOCS["defaultLexicons()<br/>loadLexiconDocs()"]
    end

    ATLEX["@atproto/lexicon"]
    CONS["TypeScript consumers<br/>(appviews · clients)"]

    LEX --> CG --> GEN
    GEN --> API
    GEN --> FIX
    LEX --> LEXDOCS
    ATLEX --> API
    API --> CONS
    LEXDOCS --> CONS

Install

bun add @idiolect-dev/schema
# or
npm install @idiolect-dev/schema

Usage

import {
  NSID,
  isRecord,
  classifyRecord,
  type Encounter,
  type AnyRecord,
} from "@idiolect-dev/schema";

// Narrow an unknown payload to a typed record.
const payload: unknown = await fetch(recordUrl).then(r => r.json());
if (isRecord(NSID.encounter, payload)) {
  const e: Encounter = payload;
  console.log(e.kind);
}

// Identify the nsid of an unknown record.
const nsid = classifyRecord(payload); // returns the matching nsid or null

// Wrap a strongly-typed record into a tagged AnyRecord for buffering.
import { tagRecord } from "@idiolect-dev/schema";
const tagged: AnyRecord = tagRecord(NSID.encounter, e);

What ships

  • Every record type (one per lexicon under lexicons/dev/idiolect/) plus shared types from defs.
  • NSID — a typed constants object with every shipped nsid.
  • AnyRecord — discriminated union keyed on $nsid.
  • isKind / per-record is<Kind> type guards.
  • validateRecord(nsid, value) — atproto-level structural validation via @atproto/lexicon.
  • classifyRecord(value) — returns the matching nsid or null.
  • tagRecord(nsid, record) — lift a typed record into the tagged union.
  • EXAMPLES and per-record *_EXAMPLE constants — bundled minimally-valid fixtures from lexicons/dev/idiolect/examples/.
  • loadLexiconDocs() / defaultLexicons() — re-exported lexicon JSON plus a Lexicons instance for consumers that extend the validator set.

Design notes

  • The generated TypeScript under src/generated/ is emitted by idiolect-codegen. CI runs cargo run -p idiolect-codegen -- check and fails the build if the committed output differs from what the current lexicons would produce. Hand-edits to src/generated/ never merge.

Stability

idiolect is pre-1.0. Releases in the 0.x series may include arbitrary breaking changes between minor versions — TypeScript exports, lexicon shapes, wire formats, and the validator surface are all in scope. Pin to an exact version if you depend on this package, and read CHANGELOG.md before bumping.

Related