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

@supermodel/cli

v0.48.1

Published

Supermodel command tool

Downloads

17

Readme

Supermodel CLI

The Supermodel CLI is used to manage and work with JSON Schema YAML models from the command line.

For more information about Supermodel visit https://supermodel.io.

Overview

CircleCI

Supermodel JSON Schema models are JSON schemas files written in YAML format. By convention on YAML file represents one model. It is also customary for all Supermodel models to include a model id (JSON Schema $id field). See Supermodel JSON Schema Model for more details.

Models can be freely arranged in the directory structure under the supermodel (precisely supermodel/<username>) directory. It is recommended that the directory structure reflects the application domains and subdomains to further ease the organization of models.

The Supermodel CLI then facilitates the creation of these models as well as working with them. Refer to Usage Examples for some examples of how can be the Supermodel CLI used.

Installation

$ npm i -g @supermodel/cli

or

$ yarn global add @supermodel/cli

Getting Started

After the installation, login into the Supermodel.io:

$ supermodel login
--> Logged as 'username'

Your account is need for two reasons. First, to make your model identifiers globally unique and second, to enable publishing your models at Supermodel.io. If you haven't created an account at Supermodel.io you can do so from the command line using the supermodel signup command.

When you are logged in, initialize the current directory and create your first model:

$ supermodel init MyApp
--> Created ./supermodel/<username>/MyApp

The first parameter (MyApp) of the init command should represent your application, team or domain. This, together with your Supermodel user name will be used as the base path for all the model identifiers created in the initialized supermodel directory.

After you have initialized the supermodel directory, step into it:

$ cd ./supermodel/<username>/MyApp

And go ahead and create your first model:

$ supermodel model create MyModel
--> Created model 'MyModel' as MyModel.yaml
$ open MyModel.yaml

You can open MyModel.yaml in an editor and edit it as necessary. When you are ready to create your next models simply use the supermodel model create <name> command again. You can also nest models in directories as long as they are nested under the initial supermodel/<username> directory.

Refer to Supermodel JSON Schema Model for more details about the Supermodel Model or learn about some usage examples

JSON Schema Functionality

This CLI tool currently supports the following JSON schema operations:

  • YAML to JSON Conversion

    Converts JSON Schema in YAML format to JSON format

    $ supermodel schema json <modelPath>
  • JSON Schema Validation

    Validates JSON Schema meta schema (read: validates that your JSON Schema is valid)

    $ supermodel schema validate <path>
  • JSON Schema Compilation

    Compiles multiple Supermodel JSON Schema model files into one

    $ supermodel schema compile <dir>
  • Resolve JSON Schema References

    Resolves all remote $refs in a Supermodel JSON Schema model file, transcluding the referenced definitions in the output schema file

    $ supermodel schema resolve <modelPath>
  • Conversion to OpenAPI Specification 2.0

    Converts Supermodel JSON Schema model to OpenAPI Specification definitions object

    $ supermodel schema oas2 <modelPath>
  • Conversion to GraphQL schema

    Converts Supermodel JSON Schema model to GraphQL schema

    $ supermodel schema graphql <modelPath>

Usage Examples

Validate Data Models in CI/CD Pipeline

Supermodel CLI is a CI/CD compliant CLI tool, that is it's schema validate command can be used as a part of CI testing, to validate the data models against its meta schema

$ supermodel schema validate <path>
$ echo $?
0

Convert Data Models into Self-contained OpenAPI Spec 2.0

Converts a model or set of models (via supermodel schema compile) if <path> is a directory into OAS2 definitions. If the -o parameter is provided it replaces the definitions section in the existing OAS2 document.

$ supermodel schema oas2 <pathToModel(s)> -o <pathToOAS2>

Supermodel JSON Schema Model

A Supermodel model (hereafter just "model") is a plain JSON Schema (draft 7) schema file in YAML format. It is customary that Supermodel model contains a top-level type definition, its title and it starts with the model ($id).

At minimum a Supermodel model file looks like:

$id: http://supermodel.io/username/MyModel

title: My Model
type: object

A Supermodel model might reference another model as defined in JSON Schema references with $ref:

$id: http://supermodel.io/username/MyModel

title: My Model
type: object

properties:
  modelProperty:
    $ref: http://supermodel.io/username/AnotherModel

If the referenced model http://supermodel.io/username/AnotherModel shares the same URI base with the $id of the referencing model (in this case http://supermodel.io/username/MyModel) a relative identifier might be used:

$id: http://supermodel.io/username/MyModel

title: My Model
type: object

properties:
  modelProperty:
    $ref: AnotherModel

See JSON Schema specification for more about JSON Schema references and JSON pointer.

A Good API Project

supermodel.io (http://supermodel.io), and supermodel CLI (https://github.com/supermodel/supermodel-cli) are Good API (http://goodapi.co) non-profit projects, aimed at promoting modern, reusable, and sustainable data modeling.