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

shex

v1.0.0-alpha.33

Published

Shape Expressions meta package

Readme

npm version CI Coverage Status ShapeExpressions Gitter chat https://gitter.im/shapeExpressions/Lobby DOI

shex

shex is the meta-package for the shex.js javascript implementation of Shape Expressions (try online). Installing it gives you the whole toolkit in one dependency: the parser/validator library, the command-line tools, the ShExMap data-mapping extension and the web app. If you only need one piece, each is published separately as an @shexjs/ package.

install

npm install shex

validation library

require("shex") exposes the main @shexjs/ entry points:

const ShEx = require("shex");

const shexc = "http://shex.io/examples/IssueSchema";  // schema location
const data = "http://shex.io/examples/Issue1";        // data location
const node = "http://shex.io/examples/Issue1#Issue1"; // node in that data

const N3 = require("n3");
const ShExLoader = ShEx.Loader({                      // initialize with:
  fetch: globalThis.fetch,                       //   fetch implementation
  rdfjs: N3,                                          //   RdfJs Turtle parser
});

ShExLoader.load({shexc: [shexc]}, {turtle: [data]})
  .then(function (loaded) {
    const db = ShEx.RdfJsDb(loaded.data);
    const validator = new ShEx.Validator.ShExValidator(loaded.schema, db, { results: "api" });
    const smap = [                                // array of node/shape pairs
      {node: node,                                //   JSON-LD @id for node
       shape: ShEx.Validator.ShExValidator.Start} //   schema's start shape
    ];
    const result = validator.validateShapeMap(smap); // conformant if no "errors"
    console.log(JSON.stringify(result, null, 2));
  });

The exposed properties are Parser, Writer, Validator, RdfJsDb, Loader, NodeLoader (adds file: URL support), Term, Util, Visitor and ShapeMap. The rest of the suite is there too, loaded on first use: Engines (Simple1Err, ThreadedNErr), ValidatorApi, NeighborhoodApi, Neighborhoods (RdfJs, Sparql, Wikibase), Extensions (Map, Eval, Test, Reduce, ReduceJs, Wasi, WasiTest), EditorServices, SemActOverlay and ShapePathQuery -- so new ShEx.Validator.ShExValidator(schema, ShEx.Neighborhoods.Sparql.fromParams({endpoint})) asks a query service, and ShEx.Extensions.Test.register(validator, ShEx) installs a semantic-action handler.

command line tools

The executables come from @shexjs/cli (pulled in by this package) and land in node_modules/.bin/, so npx finds them:

Validate something in HTTP-land:

npx shex-validate \
    -x http://shex.io/examples/IssueSchema \
    -d http://shex.io/examples/Issue1 \
    -s http://shex.io/examples/IssueSchema#IssueShape \
    -n http://shex.io/examples/Issue1#Issue1

That validates node …Issue1#Issue1 in the data …Issue1 against shape …IssueSchema#IssueShape in the schema …IssueSchema. The result is a JSON structure which tells you exactly how the data matched the schema; a result with "errors" tells you the data was invalid with respect to the schema. See the ShExJ primer for a description of ShEx validation and the ShExJ specification for more details about the results format.

shex-validate's -n and -s arguments are evaluated as IRIs relative to the (first) data and schema sources respectively, so the above can be written -s '#IssueShape' -n '#Issue1'.

Convert between the ShEx compact syntax (ShExC) and its JSON representation (ShExJ):

npx shex-to-json http://shex.io/examples/IssueSchema > IssueSchema.json
npx json-to-shex IssueSchema.json

Command line arguments which don't start with http:// or https:// are assumed to be file paths, so the JSON version works offline:

npx shex-validate \
    -j IssueSchema.json \
    -d http://shex.io/examples/Issue1 \
    -s http://shex.io/examples/IssueSchema#IssueShape \
    -n http://shex.io/examples/Issue1#Issue1

materialize

shexmap-materialize (from @shexjs/extension-map) transforms data from a source schema to a target schema after validation:

npx shexmap-materialize -t <target schema> | -h  [-j <JSON Vars File>] [-r <RDF root IRI>]

It reads the output of shex-validate --extension from STDIN and maps it to the specified target schema (--extension takes a package name or file glob):

npx shex-validate -x source_schema.shex -d data.ttl -s ProblemShape -n prob1 \
    --extension @shexjs/extension-map \
  | npx shexmap-materialize -t target_schema.shex -j vars.json

If supplied, a JSON vars file fills in constant values not bound from the source data, e.g.

{
  "urn:local:Demographics:constSys": "System"
}

The RDF root IRI (-r, default tag:[email protected]/2016/root) names the node from which the materialized graph descends.

the @shexjs/ packages

Happy validating!