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 🙏

© 2024 – Pkg Stats / Ryan Hefner

json-schema-model-builder

v0.2.1

Published

Infrastructure components to easily build models directly from JSON Schema

Downloads

58

Readme

JSON Schema model builder

Infrastructure components to easily build models directly from JSON Schema

Status

Under development, but mostly complete. Use the classes as a base for your own infrastructure. See Building Blocks for more details

Please check the tests and markdown *.md documentation files for in-depth API documentation.

Quick start

  • npm: npm install json-schema-model-builder -S
  • yarn: yarn add json-schema-model-builder

Use

Something like this...

import { schema } from "./schemas/person.json";
import { config } from "./config";
import { createBuilder, createState } from "json-schema-model-builder";

const state = createState({ config });
const builder = createBuilder({ state, schema, config });
const built = builder.build();
const rendered = built.render();

// Render the darn thing!
console.log({ rendered });

Design & Architecture

This project is a result of multiple efforts trying to generate source code or derive models from JSON schemas. There is a need for a framework with a set of well tested, battle-tested building blocks to make this much easier. The goal is to achieve true declarative model driven development.

Your domain and action models across your stack should automatically be derived from the same underlying declarative model (project blueprint).

In the near future we will likely add interactive graph driven development to the mix, using an approach like d3-force-graph-editor

You could in the end simply draw your full application as a directed graph and then assign sufficient meta data to nodes and edges. Then as you draw, have an asortment of pluggable generators generate most (if not all!) of the app for you!

As you reconfigure your graph your app would be auto-coded/generated to reflect the graph in real time!!

Ideally you would then sync the state of the graph with other developers in real time, either using something like AppSync or GraphQL backend or perhaps something like automerge-graph or Immer

Addional projects/resources

Main concepts

Infrastructure delivered by library

  • Builder builds a set of entities identified by resolvers and dispatches events as needed
  • Dispatcher Dispatches select events to state for update of model
  • State builds collections of entities and a directed graph from incoming model events

Your concerns for output target

  • Model: target model to be built from state can either subscribe to the State or process the State when builder has finished
  • Renderer Rendering can be done when target model has been built

The following examples act to demonstrate how you might go about using this infrastructure to generate source code or models.

Examples

Note: As soon as we have a solid foundation and working examples we will move these into their own projects and publish them on npm

Testing

Uses jest for unit testing.

Please help add more/better test coverage :)

Run tests in watch mode

$ npm run test:watch

Run all tests

$ npm run test

TODO

  • State subscribers

Author

2018 Kristian Mandrup (CTO@Tecla5)

License

MIT