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

schema-fabricator

v1.0.2

Published

Schema-driven JSON document generator with coverage-aware generation and a local designer GUI.

Readme

Schema Fabricator

Schema Fabricator generates JSON documents from composable class, enum, union, function, and state definitions. It supports nested structures, multilevel class inheritance, optional fields, recursive schemas, stateful functions, and coverage-aware generation.

Install

npm install schema-fabricator

For command-line use without adding it to a project:

npx schema-fabricator --help

Requires Node.js 20 or later.

Command line

After a global install, use the short sf command to create and operate a project:

npm install -g schema-fabricator
mkdir my-schema-project && cd my-schema-project
sf init
sf generate --yes
sf stats
sf gui

sf init creates sf-config.json, the definitions/ directory tree, and an empty Root class. It never overwrites an existing config or root class. sf stats reports definition counts, recursion status, possible-document count when finite, generated-document count and size, coverage-branch occurrences, and aggregate enum-value distribution. Occurrence statistics are saved with each sf generate run.

sf gui starts the local schema designer for the current project. It prints the local URL (normally http://localhost:4173); stop it with Ctrl+C.

Run the generator from a directory containing config.json and definitions/:

schema-fabricator --yes

When working from a Schema Fabricator project checkout, the equivalent npm script is:

npm run generate -- --yes
schema-fabricator [options]

  -c, --config <file>           Configuration file (default: config.json)
  -d, --definitions <directory> Definitions directory (default: definitions)
  -o, --output <directory>      Generated-document directory (default: generated)
  -y, --yes                     Generate without an interactive confirmation
  -h, --help                    Show help

The output directory is cleared only after confirmation (or --yes). Recursive schemas report that total-document estimation is skipped and are bounded by maxDepth.

Launch the local schema designer for the current project with:

schema-fabricator-gui

Set SCHEMA_FABRICATOR_PROJECT_ROOT to target a different project directory.

Project layout

config.json
definitions/
  classes/
    Article.class.json
    Article.class/
      Seo.class.json
  enums/
    Visibility.enum.json
  unions/
    Content.union.json
  functions/
    makeSlug.function.js
  state/
    Counters.state.json

Nested class files inherit their parent class. For example, Article.class/Seo.class.json inherits Article.class.json.

Configuration

{
  "root": "<class:Article>",
  "maxDepth": 4,
  "maxArrayLength": 3,
  "minOccurances": 1
}

minOccurances deliberately retains its existing spelling for compatibility with schema projects.

Definition syntax

Classes and nested objects use JSON object fields. A key ending in ? is optional.

{
  "title": "<String>",
  "visibility": "<enum:Visibility>",
  "related?": "[<union:Content>]",
  "metadata": {
    "featured": "<Boolean>"
  }
}

Supported values:

  • Primitive tokens: <String>, <Number>, <Boolean>, <Null>
  • References: <class:Name>, <enum:Name>, <union:Name>
  • Functions: <function:name> or <function:name schema.class.Article>
  • Array notation: "[<class:Name>]" or JSON arrays with one item
  • Tuple notation: JSON arrays with multiple items
  • Nested JSON objects and literal strings, numbers, booleans, and null

Enums and unions are JSON arrays:

["public", "private"]
["<class:Article>", "<class:Video>"]

Function files export (or declare) a function with the same name as the file. State files are mutable JSON objects shared by functions during one generation run.

Library API

const { Fabricator, generate, generateToDirectory } = require("schema-fabricator");

const fabricator = new Fabricator("./definitions", {
  maxDepth: 4,
  maxArrayLength: 3,
  minOccurances: 1,
});

const documents = fabricator.generate("<class:Article>");

// Or use config.json, definitions/, and generated/ in the current directory.
const documentsFromProject = generate();
generateToDirectory();

The root export also exposes DefinitionLoader, readJson, and parser helpers for advanced integrations.

Publishing this repository

Choose an npm package name you control, update the name field if necessary, then run:

npm login
npm run pack:check
npm publish

For a scoped public package, use npm publish --access public.

License

ISC