added json to bigquery, mysql and mongoose

This commit is contained in:
Ritesh Kumar committed 2017-08-26 02:00:29 +05:30
1 parent 1f12d09126
commit 21fc03ae01
8 files changed
+184 -34

No files matched your search

+2 -1
View File
@@ -17,7 +17,8 @@ if (isBrowser) {
require("brace/mode/typescript");
require("brace/mode/css");
require("brace/mode/html");
require("brace/mode/rust")
require("brace/mode/rust");
require("brace/mode/mysql");
}
// const prettierParsers = {
+38 -33
View File
@@ -16,6 +16,38 @@ Router.onRouteChangeStart = url => {
Router.onRouteChangeComplete = () => NProgress.done();
Router.onRouteChangeError = () => NProgress.done();
const routes = [{
label: 'JSON to React PropTypes',
path: '/'
}, {
label: 'JSON to Flow Types',
path: '/json-to-flow-types'
}, {
label: 'JSON to Typescript Interface',
path: '/json-to-ts-interface'
}, {
label: 'JSON to MobX-State-Tree Model',
path: '/json-to-mobx-state-tree'
}, {
label: 'CSS to JS Objects',
path: '/css-to-js'
}, {
label: 'HTML to JSX',
path: '/html-to-jsx'
}, {
label: 'JSON to Rust Serde',
path: '/json-to-rust-serde'
}, {
label: 'JSON to Mongoose Schema',
path: '/json-to-mongoose'
}, {
label: "JSON to Big Query Schema",
path: "/json-to-big-query"
}, {
label: "JSON to MySQL",
path: "/json-to-mysql"
}]
function Logo() {
return (
<svg
@@ -93,6 +125,7 @@ export default function({ children, pathname }) {
ul {
padding: 20px 0;
flex: 1;
overflow-y: scroll;
}
li {
@@ -177,41 +210,13 @@ export default function({ children, pathname }) {
<Logo />
</div>
<ul>
<li className={getClass("/")}>
<Link prefetch href="/">
<a>JSON to React PropTypes</a>
</Link>
</li>
<li className={getClass("/json-to-flow-types")}>
<Link prefetch href="/json-to-flow-types">
<a>JSON to Flow Types</a>
</Link>
</li>
<li className={getClass("/json-to-ts-interface")}>
<Link prefetch href="/json-to-ts-interface">
<a>JSON to Typescript Interface</a>
</Link>
</li>
<li className={getClass("/json-to-mobx-state-tree")}>
<Link prefetch href="/json-to-mobx-state-tree">
<a>JSON to MobX-State-Tree Model</a>
</Link>
</li>
<li className={getClass("/css-to-js")}>
<Link prefetch href="/css-to-js">
<a>CSS to JS Objects</a>
</Link>
</li>
<li className={getClass("/html-to-jsx")}>
<Link prefetch href="/html-to-jsx">
<a>HTML to JSX</a>
</Link>
</li>
<li className={getClass("/json-to-rust-serde")}>
<Link prefetch href="/json-to-rust-serde">
<a>JSON to Rust Serde</a>
{routes.map(route => (
<li key={route.path} className={getClass(route.path)}>
<Link prefetch href={route.path}>
<a>{route.label}</a>
</Link>
</li>
))}
</ul>
<div className="footer">
+2
View File
@@ -20,6 +20,7 @@
"babili-webpack-plugin": "^0.1.2",
"copy-text-to-clipboard": "^1.0.2",
"css-to-react-native": "^2.0.4",
"generate-schema": "^2.5.1",
"is-in-browser": "^1.1.3",
"json2dts": "^0.0.2",
"lodash": "^4.17.4",
@@ -31,6 +32,7 @@
"react-ace": "^5.1.2",
"react-dom": "^15.6.1",
"react-github-corner": "^0.3.0",
"stringify-object": "^3.2.0",
"webpack-bundle-analyzer": "^2.9.0"
},
"devDependencies": {
+30
View File
@@ -0,0 +1,30 @@
import React, { PureComponent } from "react";
import { bigquery } from "generate-schema"
import stringify from "stringify-object"
import Layout from "../components/Layout";
import ConversionPanel from "../components/ConversionPanel";
import defaultText from "../utils/dummy-object-json";
export default class Json2Ts extends PureComponent {
getTransformedValue = newValue => {
const value = JSON.parse(newValue)
return stringify(bigquery(value))
};
render() {
return (
<Layout pathname={this.props.url.pathname}>
<ConversionPanel
leftTitle="JSON"
rightTitle="Big Query Schema"
getTransformedValue={this.getTransformedValue}
name={"big-query"}
defaultText={defaultText}
leftMode="json"
rightMode="javascript"
url={this.props.url}
/>
</Layout>
);
}
}
+30
View File
@@ -0,0 +1,30 @@
import React, { PureComponent } from "react";
import { mongoose } from "generate-schema"
import stringify from "stringify-object"
import Layout from "../components/Layout";
import ConversionPanel from "../components/ConversionPanel";
import defaultText from "../utils/dummy-object-json";
export default class Json2Ts extends PureComponent {
getTransformedValue = newValue => {
const value = JSON.parse(newValue)
return stringify(mongoose(value))
};
render() {
return (
<Layout pathname={this.props.url.pathname}>
<ConversionPanel
leftTitle="JSON"
rightTitle="Mongoose Schema"
getTransformedValue={this.getTransformedValue}
name={"mongoose"}
defaultText={defaultText}
leftMode="json"
rightMode="javascript"
url={this.props.url}
/>
</Layout>
);
}
}
+30
View File
@@ -0,0 +1,30 @@
import React, { PureComponent } from "react";
import { mysql } from "generate-schema"
import stringify from "stringify-object"
import Layout from "../components/Layout";
import ConversionPanel from "../components/ConversionPanel";
import defaultText from "../utils/dummy-json";
export default class Json2Ts extends PureComponent {
getTransformedValue = newValue => {
const value = JSON.parse(newValue)
return mysql(value)
};
render() {
return (
<Layout pathname={this.props.url.pathname}>
<ConversionPanel
leftTitle="JSON"
rightTitle="MySQL Table Schema"
getTransformedValue={this.getTransformedValue}
name={"mysql"}
defaultText={defaultText}
leftMode="json"
rightMode="mysql"
url={this.props.url}
/>
</Layout>
);
}
}
+21
View File
@@ -0,0 +1,21 @@
const y = `{
"title": {
"type": "String",
"trim": true,
"index": true,
"required": true
},
"year": {
"type": "Number",
"max": 2012,
"validate": "validateBookYear"
},
"author": {
"type": "ObjectId",
"ref": "Author",
"index": true,
"required": true
}
}`
export default y
+31
View File
@@ -2009,10 +2009,21 @@ gauge@~2.7.3:
strip-ansi "^3.0.1"
wide-align "^1.1.0"
generate-schema@^2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/generate-schema/-/generate-schema-2.5.1.tgz#73c8ddd07dfeb47e0becd43c4e93a93b2d67f18a"
dependencies:
commander "^2.9.0"
type-of-is "^3.4.0"
get-caller-file@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5"
get-own-enumerable-property-symbols@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-1.0.1.tgz#f1d4e3ad1402e039898e56d1e9b9aa924c26e484"
getpass@^0.1.1:
version "0.1.7"
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
@@ -2373,6 +2384,10 @@ is-number@^3.0.0:
dependencies:
kind-of "^3.0.2"
is-obj@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"
is-path-cwd@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d"
@@ -2401,6 +2416,10 @@ is-promise@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"
is-regexp@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
@@ -3823,6 +3842,14 @@ string_decoder@~1.0.3:
dependencies:
safe-buffer "~5.1.0"
stringify-object@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/stringify-object/-/stringify-object-3.2.0.tgz#94370a135e41bc048358813bf99481f1315c6aa6"
dependencies:
get-own-enumerable-property-symbols "^1.0.1"
is-obj "^1.0.1"
is-regexp "^1.0.0"
stringstream@~0.0.4:
version "0.0.5"
resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878"
@@ -3977,6 +4004,10 @@ type-is@~1.6.15:
media-typer "0.3.0"
mime-types "~2.1.15"
type-of-is@^3.4.0:
version "3.5.1"
resolved "https://registry.yarnpkg.com/type-of-is/-/type-of-is-3.5.1.tgz#eec2fc89b828dbf9900eb6416eee30f4fe0fcd31"
ua-parser-js@^0.7.9:
version "0.7.12"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"