json-flow-cli

0.1.1 • Public • Published

JSON Flow CLI

Generate flow types from JSON streams without any schemas.

Installation

npm install json-flow-cli -g

Usage

cat some-json-file.json | json-flow-cli --name=SomeFlowTypeName
curl http://some-web-api/json-response | json-flow-cli --name=SomeFlowTypeName

Options:

--name={schema}      Used to generate the name of your flow types (required).
--help               Displays this help.

Example

Input

{
  "somePropA": {
    "somePropB": {
      "someOtherPropA": 1,
      "someOtherPropB": 2
    },
    "someOtherPropC": [
      {
        "somePropD": {
          "somePropE": {}
        }
      },
      {
        "somePropD": {
          "somePropF": {}
        }
      },
      {
        "somePropD": {
          "somePropG": {}
        }
      }
    ]
  }
}
 

Run json-flow-cli against the above input:

cat src/test-files/foo.json | json-flow-cli --name Simple > foo.output

Output

type Simple = {
  somePropA: SimpleSomePropA,
};
 
type SimpleSomePropA = {
  somePropB: SimpleSomePropASomePropB,
  SomeOtherPropC: Array<SimpleSomePropASomeOtherPropC>,
};
 
type SimpleSomePropASomePropB = {
  someOtherPropA: number,
  someOtherPropB: number,
};
 
type SimpleSomePropASomeOtherPropC = {
  somePropD: SimpleSomePropASomeOtherPropCSomePropD,
};
 
type SimpleSomePropASomeOtherPropCSomePropD = {
  somePropE: object,
};

Package Sidebar

Install

npm i json-flow-cli

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

11.2 kB

Total Files

14

Last publish

Collaborators

  • leudanielm