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

@adaptivekind/graph-schema

v0.1.11

Published

JSON schema for a graph along with TypeScript types

Readme

Graph Schema

TypeScript types and JSON schema for representing graphs with nodes and links.

Features

  • TypeScript-first: Strongly typed interfaces for graph structures
  • JSON Schema: Generated schema for validation
  • Flexible Metadata: Support for custom data, weights, and metadata on nodes and links

Installation

npm install

Usage

Basic Graph Structure

import { Graph, Node, Link } from "./src/index";

const graph: Graph = {
  id: "my-graph",
  label: "Sample Graph",
  nodes: {
    user1: {
      label: "Alice",
      type: "person",
      meta: {
        department: "engineering",
      },
      weights: {
        influence: 0.8,
      },
    },
    user2: {
      label: "Bob",
      type: "person",
    },
  },
  links: [
    {
      id: "connection1",
      source: "user1",
      target: "user2",
      type: "friendship",
      weights: {
        strength: 0.9,
      },
      meta: {
        since: "2023-01-15",
      },
    },
  ],
};

Node Interface

interface Node {
  label?: string; // Display name
  type?: string; // Node category/type
  aliases?: Array<string>; // Alternative names
  value?: number; // Numeric value
  weights?: Record<string, number>; // Named weights
  meta?: Record<string, string>; // String metadata
}

Link Interface

interface Link {
  id?: string; // Optional identifier
  source: string; // Source node ID (required)
  target: string; // Target node ID (required)
  type?: string; // Link category/type
  label?: string; // Display label
  value?: number; // Numeric value
  weights?: Record<string, number>; // Named weights
  meta?: Record<string, string>; // String metadata
}

Graph Interface

interface Graph {
  id?: string; // Graph identifier
  label?: string; // Graph label
  nodes: Record<string, Node>; // Nodes keyed by ID
  links: Link[]; // Array of links
}

JSON Schema

The project includes automatically generated JSON Schema for validation:

npm run generate-json-schema

This creates graph.schema.json which can be used with JSON Schema validators like AJV.

Development

Available Scripts

  • npm run build - Compile TypeScript to JavaScript
  • npm run dev - Watch mode compilation
  • npm run clean - Remove build artifacts
  • npm run lint - Run ESLint and Prettier
  • npm run lint:fix - Fix linting issues
  • npm run typecheck - Type check without emitting files
  • npm test - Run test suite
  • npm run test:watch - Run tests in watch mode
  • npm run generate-json-schema - Generate JSON schema from types

Testing

The project includes comprehensive tests that validate:

  • TypeScript interface compatibility
  • JSON schema validation with AJV
  • Round-trip serialization
  • Node and link structure validation
  • Reference integrity (all links point to existing nodes)

Design Decisions

Node Storage as Map

Nodes are stored as Record<string, Node> rather than Node[] for several benefits:

  • No duplicate IDs - object keys are naturally unique
  • No redundant ID storage - the map key serves as the node ID

Flexible Typing

Both nodes and links support:

  • Strong typing for required fields
  • Optional metadata through meta and weights properties
  • Custom types via the type field
  • Extensible design for domain-specific needs

License

MIT