Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@manifoldco/graphql-gen

Package Overview
Dependencies
Maintainers
15
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@manifoldco/graphql-gen - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

bin/cli.js

@@ -14,3 +14,3 @@ #!/usr/bin/env node

Usage
$ @manifoldco/graphql-gen [input] [options]
$ graphql-gen [input] [options]

@@ -17,0 +17,0 @@ Options

@@ -1,1 +0,1 @@

"use strict";var prettier=require("prettier"),__assign=function(){return(__assign=Object.assign||function(r){for(var e,n=1,t=arguments.length;n<t;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=e[a]);return r}).apply(this,arguments)};function __rest(r,e){var n={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.indexOf(t)<0&&(n[t]=r[t]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(r);a<t.length;a++)e.indexOf(t[a])<0&&(n[t[a]]=r[t[a]])}return n}var TYPES={boolean:"Boolean",integer:"Int",number:"Number",string:"String"};function camelCase(r){return r.replace(/(-|_|\.|\s)+[a-z]/g,function(r){return r.toUpperCase().replace(/[^0-9a-z]/gi,"")})}function snakeCase(r){return r.replace(/(-|\.|\s)/g,"_").replace(/[A-Z]/g,function(r){return"_"+r}).toUpperCase()}function parse(r){var e=[],n=[],t=[],a=r.definitions;function s(r){var e=r.replace("#/definitions/","");return[e,a[e]]}function i(r){var e=r[0],n=r[1];t.push("enum "+e+" {"),n.forEach(function(r){if("number"==typeof r||!1===isNaN(parseInt(r,10))){var n=e.search(/[A-Z](?=[^A-Z]*$)/),a=e.substr(n,e.length);t.push(""+a+r)}else t.push(snakeCase(r))}),t.push("}")}function o(){var r=e.pop();if(r){var a=r[0],o=r[1],p=o.allOf,u=o.properties,f=o.required,c=u||{},l=[];if(Array.isArray(p)&&p.forEach(function(r){if(r.$ref){var e=s(r.$ref)[0];l.push(e)}else r.properties&&(c=__assign({},c,r.properties))}),Object.keys(c).length){var h=l.length?" implements "+l.join(", "):"";for(t.push("type "+camelCase(a)+h+" {"),Object.entries(c).forEach(function(r){var i=r[0],o=r[1],p=!Array.isArray(f)||-1===f.indexOf(i)?"":"!",u=camelCase(i),c=camelCase(a+"_"+i),l=function(r,n){var t=r.$ref,a=r.items,i=r.type,o=__rest(r,["$ref","items","type"]);if(t){var p=s(t),u=p[0],f=p[1];return"ID"===u?"ID":""+(TYPES[f.type]||u||"scalar")}if("array"===i&&a){if(a.$ref){var c=s(a.$ref);return u=c[0],f=c[1],"ID"===u?"ID":"["+(TYPES[f.type]||u||"scalar")+"]"}return"["+(TYPES[a.type]||"scalar")+"]"}return o.properties?(e.push([n,__assign({$ref:t,items:a,type:i},o)]),n):TYPES[i]||i||"scalar"}(o,c);if("string"==typeof o.description&&t.push('"'+o.description.replace(/\n$/,"").replace(/\n/g," ")+'"'),Array.isArray(o.enum))return n.push([c,o.enum]),void t.push(u+": "+c+p);t.push(u+": "+l+p)}),t.push("}");n.length>0;){var y=n.pop();y&&i(y)}}}}for(Object.entries(a).forEach(function(r){return e.push(r)}),e.sort(function(r,e){return r[0].localeCompare(e[0])});e.length>0;)o();return prettier.format(t.join("\n"),{parser:"graphql"})}var index=function(r,e){var n=e&&e.swagger||2;if(1!==n&&3!==n)return parse(r);console.error("That version is not supported")};module.exports=index;
"use strict";var prettier=require("prettier"),__assign=function(){return(__assign=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var a in e=arguments[t])Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=e[a]);return r}).apply(this,arguments)};function __rest(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(r);a<n.length;a++)e.indexOf(n[a])<0&&(t[n[a]]=r[n[a]])}return t}var TYPES={boolean:"Boolean",integer:"Int",number:"Number",string:"String"};function camelCase(r){return r.replace(/(-|_|\.|\s)+[a-z]/g,function(r){return r.toUpperCase().replace(/[^0-9a-z]/gi,"")})}function snakeCase(r){return r.replace(/(-|\.|\s)/g,"_").replace(/[A-Z]/g,function(r){return"_"+r}).toUpperCase()}function parse(r){var e=[],t=[],n=[],a=r.definitions;function s(r){var e=r.replace("#/definitions/","");return[e,a[e]]}function i(r){var e=r[0],t=r[1];n.push("enum "+e+" {"),t.forEach(function(r){if("number"==typeof r||!1===isNaN(parseInt(r,10))){var t=e.search(/[A-Z](?=[^A-Z]*$)/),a=e.substr(t,e.length);n.push(""+a+r)}else n.push(snakeCase(r))}),n.push("}")}function o(){var r=e.pop();if(r){var a=r[0],o=r[1],p=o.allOf,u=o.properties,f=o.required,c=u||{},l=[];if(Array.isArray(p)&&p.forEach(function(r){if(r.$ref){var e=s(r.$ref)[0];l.push(e)}else r.properties&&(c=__assign({},c,r.properties))}),Object.keys(c).length){var h=l.length?" implements "+l.join(", "):"";for(n.push("type "+camelCase(a)+h+" {"),Object.entries(c).forEach(function(r){var i=r[0],o=r[1],p=!Array.isArray(f)||-1===f.indexOf(i)?"":"!",u=camelCase(i),c=camelCase(a+"_"+i),l=function r(t,n){var a=t.$ref,i=t.items,o=t.type,p=__rest(t,["$ref","items","type"]);if(a){var u=s(a),f=u[0],c=u[1];return"ID"===f?"ID":c.items&&c.items.$ref?r(c,f):""+(TYPES[c.type]||f||"scalar")}if("array"===o&&i){if(i.$ref){var l=s(i.$ref);return f=l[0],c=l[1],"ID"===f?"ID":"["+(TYPES[c.type]||f||"scalar")+"]"}return"["+(TYPES[i.type]||"scalar")+"]"}return p.properties?(e.push([n,__assign({$ref:a,items:i,type:o},p)]),n):TYPES[o]||o||"scalar"}(o,c);if("string"==typeof o.description&&n.push('"'+o.description.replace(/\n$/,"").replace(/\n/g," ")+'"'),Array.isArray(o.enum))return t.push([c,o.enum]),void n.push(u+": "+c+p);n.push(u+": "+l+p)}),n.push("}");t.length>0;){var y=t.pop();y&&i(y)}}}}for(Object.entries(a).forEach(function(r){return e.push(r)}),e.sort(function(r,e){return r[0].localeCompare(e[0])});e.length>0;)o();return prettier.format(n.join("\n"),{parser:"graphql"})}var index=function(r,e){var t=e&&e.swagger||2;if(1!==t&&3!==t)return parse(r);console.error("That version is not supported")};module.exports=index;

@@ -62,4 +62,5 @@ import { format } from 'prettier';

function getRef(lookup) {
var ref = lookup.replace('#/definitions/', '');
return [ref, definitions[ref]];
var ID = lookup.replace('#/definitions/', '');
var ref = definitions[ID];
return [ID, ref];
}

@@ -72,2 +73,5 @@ function getType(definition, nestedName) {

return 'ID';
if (refProperties.items && refProperties.items.$ref) {
return getType(refProperties, refName);
}
return "" + (TYPES[refProperties.type] || refName || 'scalar');

@@ -74,0 +78,0 @@ }

{
"name": "@manifoldco/graphql-gen",
"version": "1.1.0",
"version": "1.1.1",
"description": "Generate GraphQL schemas from Swagger OpenAPI specs ",
"main": "dist/index.js",

@@ -5,0 +6,0 @@ "bin": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc