Giter VIP home page Giter VIP logo

shapeshifter's Introduction

Shapeshifter (DEPRECATED)

This project is no longer being maintained!

Build Status npm version npm deps

Shapeshifter is a command line tool for generating ECMAScript (ES) compatible files that export PropTypes, Flow aliases, and TypeScript interfaces, as well as relation schema classes from JS, JSON, GraphQL, or YAML schematic files. Schematics can represent database tables, API endpoints, data structures, resources, internal shapes, and more.

Requirements

  • Node 10.10+
  • PropTypes 15+ / Flow 0.60+ / TypeScript 2.4+
  • IE 11+

Documentation

https://github.com/milesj/shapeshifter/tree/master/docs

shapeshifter's People

Contributors

brieb avatar dependabot[bot] avatar milesj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shapeshifter's Issues

Support magic import path for "generated" schemas

The generated shapeshifter file (usually an index.js file) encounters a ton of churn any time a schema changes. This can cause merge conflicts when 2 separate branches generate a new output file.

Perhaps support a magic import path, like import { SomeShape } from 'shapeshifter/schemas';, which will automatically generate the shapeshifter file during a build process (webpack), instead of including the generated file in the source code.

Pros:

  • No build command needs to be run
  • No file committed to source
  • No possibility of conflicts

Cons:

  • Breaks IDE/editor import lookups and references
  • Not apparent whether a schema/type/constant is supported (unless looking for the JSON files)

Unsupported GraphQL definition

I am using a custom directive, that looks like this:

enum AuthRole {
  VERIFIED
  PAID
  ADMIN
  DEV
}
directive @auth(role: AuthRole, roles: [AuthRole]) on FIELD | FIELD_DEFINITION

I have this defined in my graphql file.

When I run shapeshifter with shapeshifter-parser-graphql, I get this error:

shapeshifter --prop-types src/generated/data-server.graphql > src/generated/data-server.props.js

Unsupported GraphQL definition "auth".

Is there a way to ignore directives?

Graphql

Any way to support it? Also, any chance to support migrations or depreciations since types change over time?

Rename

Should be renamed to burnside.

Use PropTypes.any for polyfill

Otherwise TS errors with:

src/schemas/lantern.ts:110:34 - error TS2345: Argument of type 'Requireable<any> | (() => void)' is not assignable to parameter of type 'Validator<any>'.
  Type '() => void' is not assignable to type 'Validator<any>'.
    Type 'void' is not assignable to type 'Error | null'.

110   attachments: PropTypes.arrayOf(TicketAttachmentShape),

Add Schema#define()

Add a basic define method to map relations using GQL syntax.

schema.define({
  user: UserSchema,
  posts: [PostSchema],
});

Local reference shapes

Allow shapes to be defined as references within the JSON file, so that they can be reused without having to declare external JSON files.

{
  "name": "string",
  "references": {
    "Foo": {
      "a": "string",
      "b": "bool",
      "c": "number",
    }
  },
  "attributes": {
    "bar": {
      "type": "reference",
      "reference": "Foo"
    }
  }
}

Renderer#renderSchema() doesn't handle self references correctly

It fails on this line:

references[definition.valueType.config.reference].name

Can be changed to something like:

const name = definition.valueType.config.self
  ? this.reader.name
  : references[definition.valueType.config.reference].name;

We also need to change the output from this:

export const PaymentSchema = new Schema('payments')
  .hasMany({
    refunds: PaymentSchema,
  });

To something like this:

export const PaymentSchema = new Schema('payments');

PaymentSchema.hasMany({
  refunds: PaymentSchema,
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.