New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hyperone/cli-ext-root-openapi-generator

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperone/cli-ext-root-openapi-generator - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

2

dist/index.js

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

module.exports=function(e){var t={};function a(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=e,a.c=t,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)a.d(r,o,function(t){return e[t]}.bind(null,o));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=4)}([function(e,t){e.exports=require("@hyperone/cli-core")},function(e,t){e.exports=require("@hyperone/cli-framework")},function(e){e.exports=JSON.parse('{"name":"@hyperone/cli-ext-root-openapi-generator","version":"1.0.7","description":"","main":"dist/index.js","browser":"index.js","scripts":{"prepack":"NODE_ENV=production webpack","build":"webpack","watch":"webpack --watch","clean":"rm dist -rf"},"devDependencies":{"webpack":"^4.43.0","webpack-cli":"^3.3.12","webpack-dev-server":"^3.11.0"},"author":"Adam Dobrawy","license":"MIT","dependencies":{"@hyperone/cli-core":"^1.0.7","@hyperone/cli-framework":"^1.0.6","jsonpatch":"^3.0.1","openapi-sampler":"^1.0.0-beta.16","pluralize":"^8.0.0"},"gitHead":"b51a930fcf67d351fb8243c40b64e8e17d80c10b","publishConfig":{"access":"public"}}')},function(e,t,a){e.exports=function(){var e=[],t=[],a={},r={},o={};function n(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function i(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,a){return t[a]||""}))}function u(e,t){return e.replace(t[0],(function(a,r){var o=s(t[1],arguments);return i(""===a?e[r-1]:a,o)}))}function c(e,t,r){if(!e.length||a.hasOwnProperty(e))return t;for(var o=r.length;o--;){var n=r[o];if(n[0].test(t))return u(t,n)}return t}function l(e,t,a){return function(r){var o=r.toLowerCase();return t.hasOwnProperty(o)?i(r,o):e.hasOwnProperty(o)?i(r,e[o]):c(o,r,a)}}function p(e,t,a,r){return function(r){var o=r.toLowerCase();return!!t.hasOwnProperty(o)||!e.hasOwnProperty(o)&&c(o,o,a)===o}}function d(e,t,a){return(a?t+" ":"")+(1===t?d.singular(e):d.plural(e))}return d.plural=l(o,r,e),d.isPlural=p(o,r,e),d.singular=l(r,o,t),d.isSingular=p(r,o,t),d.addPluralRule=function(t,a){e.push([n(t),a])},d.addSingularRule=function(e,a){t.push([n(e),a])},d.addUncountableRule=function(e){"string"!=typeof e?(d.addPluralRule(e,"$0"),d.addSingularRule(e,"$0")):a[e.toLowerCase()]=!0},d.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),o[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach((function(e){return d.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return d.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return d.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(d.addUncountableRule),d}()},function(e,t,a){"use strict";a.r(t);var r=a(3),o=a.n(r),n=a(1),i=a(0);const s=e=>String(e).replace(/([a-z])([A-Z])/,(e,t,a)=>`${t}-${a}`).toLowerCase(),u=(e,t,a)=>{const r=String.prototype.split.call(t,/[,[\].]+?/).filter(Boolean);let o=e;for(const e of r.slice(0,-1))void 0===o[e]&&(o[e]={}),o=o[e];o[r[r.length-1]]=a};var c={extractId:e=>e.startsWith("/")?e.split("/").pop():e,nestedValue:e=>{const t={};for(const a of e.split(",")){const[e,r]=a.split(/=/,2);t[e]=r}return t}};const l=e=>e.replace(/Id$/,""),p=(e=[])=>{const t=[];for(const a of e){const e=l(a.name),r=[a.description],o={name:s(e),use:{in:"path",field:a.name}};a.name.endsWith("Id")&&Object.assign(o,{required:!0,defaultSource:e,type:c.extractId,typeLabel:"id-or-uri"}),t.push({...o,description:r.join(".")})}return t},d=(e,t="",a="")=>{const r=[];for(const[o,n]of Object.entries(e.properties||{})){const u=[],l=e.required||[],p={name:`${t}${s(o)}`,required:l.includes(o),use:{in:"body",field:`${a}/${o}`}};if(n.title&&u.push(n.title),n.readOnly)continue;const m=n["x-audience"];if(!m||["user","all"].includes(m)){if(n["x-resource"]){Object.assign(p,{typeLabel:"uri"});const e=i.openapi.getEndpointForKind(n["x-resource"].kind);1==e.length?(Object.assign(p,{typeLabel:"id-or-uri",prefix:e[0]}),u.push("Provide ID or URI of "+n["x-resource"].kind)):u.push("Provide URI of "+n["x-resource"].kind)}if(n["x-permissions"]&&u.push("Requires permissions "+n["x-permissions"].join(", ")),"string"==n.type&&Object.assign(p,{placeholder:o}),"array"==n.type&&"string"==n.items.type&&Object.assign(p,{multiple:!0}),"boolean"==n.type){const e=[!0,!1].map(String);Object.assign(p,{type:e=>"true"==e,typeLabel:e.join(","),choices:e})}if("object"!=n.type){if("array"==n.type&&"object"==n.items.type){const e=Object.entries(n.items.properties||{}).filter(([,e])=>1!=e.readOnly).map(([e])=>`${e}=${e}`).join(",");Object.assign(p,{multiple:!0,typeLabel:e,type:c.nestedValue})}n.default&&(u.push("Defaults is "+n.default),Object.assign(p,{defaultValue:n.default})),Object.assign(p,{description:u.join(". ")}),r.push(p)}else r.push(...d(n,t?`${t}-${o}`:o+"-",`${a}/${o}`))}}return r},m=(e,t,a)=>{let r=e;for(const[e,,t]of r.matchAll("{((.+?)Id)}"))r=r.replace(e,a[t]);return r};var h={renderOptions:e=>{const t=i.openapi.getSchema(e);return[...p(e.parameters),...d(t)]},renderBody:(e,t,a)=>{const r={};for(const o of a){if(!o.use||"body"!=o.use.in)continue;let a=t[o.name];o.prefix&&a&&!a.startsWith("/")&&(a=m(o.prefix,e,t)),u(r,o.use.field.replace(/\//g,"."),a)}return r},renderPath:m,renderQuery:(e,t)=>{const a=i.openapi.getResponse(t)||{},r=[];let o;if("array"==a.type?o=a.items.properties||{}:"object"==a.type&&(o=a.properties||{}),o)for(const e of["id","name","state","flavour","content","enabled","size"])o[e]&&r.push(`${e}:${e}`);return 0==r.length&&r.push("value:@"),`[].{${r.join(",")}}`}};const f=(e,t)=>new n.Command({name:e,summary:"Print specification of context",handler:()=>t}),$=({name:e,operation:t,method:a,path:r})=>()=>{const o=h.renderOptions(t);return new n.Command({name:e,summary:`${t.summary} [${t.operationId}]`,options:o,tags:[t.operationId],handler:async e=>{const n=e._all||e,s=i.openapi.getUrl(h.renderPath(r,t,n)),u=h.renderBody(t,n,o);e.defaultQuery=h.renderQuery(r,t,n);const c=await e.api[a](s,u);return e.format(e,c)}})},g=(e,t)=>()=>{const a=new n.Category({name:e.type,summary:t.description||`Management of ${e.type} resource`});a.addCommand(f("spec",t));const r=i.openapi.getPath(t.path)||{};r&&(r.post&&a.addCommand($({...t,name:"create",method:"post",operation:r.post})),r.get&&a.addCommand($({...t,name:"list",method:"get",operation:r.get})),r.patch&&a.addCommand($({...t,name:"update",method:"patch",operation:r.patch})));const s=`${t.path}/{${e.type}Id}`,u=i.openapi.getPath(s)||{};u&&(u.get&&a.addCommand($({...t,name:"show",method:"get",operation:u.get,path:s})),u.patch&&a.addCommand($({...t,name:"update",method:"patch",operation:u.patch,path:s})),u.delete&&a.addCommand($({...t,name:"delete",method:"delete",operation:u.delete,path:s})));for(const{name:e,path:r}of i.openapi.getActions(s))a.addCommand($({...t,name:e,method:"post",operation:i.openapi.getPath(r).post,path:r}));for(const t of i.openapi.getChild(s))a.addCommand(g(t,{path:t.path,description:`Manage ${o()(t.type)} of the ${e.type}`}));return a},y=(e,t,a)=>async()=>{const r=new n.Category({name:e,summary:`Management of ${e} namespace`,extensions:["@hyperone/cli-ext-"+e]});r.addCommand(f("spec",t));const o={};for(const e of t){let t=a.path;if(e.location&&(t+="/{locationId}"),e.parent)for(const i of e.parent){let s;"project"==i?s=r:(o[i]=o[i]||new n.Category({name:i,summary:"Management of "+i}),s=o[i]),s.addCommand(g(e,{...a,path:`${t}/${i}/{${i}Id}/${e.type}`}))}else r.addCommand(g(e,{...a,path:`${t}/${e.type}`}))}return r.addCommand(...Object.values(o)),r};t.default={name:a(2).name,version:a(2).version,load:async e=>{const t=i.openapi.getNamespaces();for(const[a,r]of Object.entries(t))await e.addCommand(y(a,r,{path:"/"+a}))}}}]);
module.exports=function(e){var t={};function a(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}return a.m=e,a.c=t,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=4)}([function(e,t){e.exports=require("@hyperone/cli-core")},function(e,t){e.exports=require("@hyperone/cli-framework")},function(e){e.exports=JSON.parse('{"name":"@hyperone/cli-ext-root-openapi-generator","version":"1.0.8","description":"","main":"dist/index.js","browser":"index.js","scripts":{"prepack":"NODE_ENV=production webpack","build":"webpack","watch":"webpack --watch","clean":"rm dist -rf"},"devDependencies":{"webpack":"^4.43.0","webpack-cli":"^3.3.12","webpack-dev-server":"^3.11.0"},"author":"Adam Dobrawy","license":"MIT","dependencies":{"@hyperone/cli-core":"^1.0.8","@hyperone/cli-framework":"^1.0.8","jsonpatch":"^3.0.1","openapi-sampler":"^1.0.0-beta.16","pluralize":"^8.0.0"},"gitHead":"a3a4d4cf6ce542757ec9adbc129f9b93bea9380e","publishConfig":{"access":"public"}}')},function(e,t,a){e.exports=function(){var e=[],t=[],a={},r={},n={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function i(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,a){return t[a]||""}))}function c(e,t){return e.replace(t[0],(function(a,r){var n=s(t[1],arguments);return i(""===a?e[r-1]:a,n)}))}function u(e,t,r){if(!e.length||a.hasOwnProperty(e))return t;for(var n=r.length;n--;){var o=r[n];if(o[0].test(t))return c(t,o)}return t}function p(e,t,a){return function(r){var n=r.toLowerCase();return t.hasOwnProperty(n)?i(r,n):e.hasOwnProperty(n)?i(r,e[n]):u(n,r,a)}}function l(e,t,a,r){return function(r){var n=r.toLowerCase();return!!t.hasOwnProperty(n)||!e.hasOwnProperty(n)&&u(n,n,a)===n}}function d(e,t,a){return(a?t+" ":"")+(1===t?d.singular(e):d.plural(e))}return d.plural=p(n,r,e),d.isPlural=l(n,r,e),d.singular=p(r,n,t),d.isSingular=l(r,n,t),d.addPluralRule=function(t,a){e.push([o(t),a])},d.addSingularRule=function(e,a){t.push([o(e),a])},d.addUncountableRule=function(e){"string"!=typeof e?(d.addPluralRule(e,"$0"),d.addSingularRule(e,"$0")):a[e.toLowerCase()]=!0},d.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),n[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach((function(e){return d.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return d.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return d.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(d.addUncountableRule),d}()},function(e,t,a){"use strict";a.r(t),a.d(t,"makeOperationCommand",(function(){return g})),a.d(t,"makeResourceCommand",(function(){return y})),a.d(t,"buildNamespaceCommand",(function(){return b}));var r=a(3),n=a.n(r),o=a(1),i=a(0);const s=e=>String(e).replace(/([a-z])([A-Z])/,(e,t,a)=>`${t}-${a}`).toLowerCase(),c=(e,t,a)=>{const r=String.prototype.split.call(t,/[,[\].]+?/).filter(Boolean);let n=e;for(const e of r.slice(0,-1))void 0===n[e]&&(n[e]={}),n=n[e];n[r[r.length-1]]=a};var u={extractId:e=>e.startsWith("/")?e.split("/").pop():e,nestedValue:e=>{const t={};for(const a of e.split(",")){const[e,r]=a.split(/=/,2);t[e]=r}return t}};const p=e=>e.replace(/Id$/,""),l=(e=[])=>{const t=[];for(const a of e){const e=p(a.name),r=[a.description],n={name:s(e),use:{in:"path",field:a.name}};a.name.endsWith("Id")&&Object.assign(n,{required:!0,defaultSource:e,type:u.extractId,typeLabel:"id-or-uri"}),t.push({...n,description:r.join(".")})}return t},d=(e,t="",a="")=>{const r=[];for(const[n,o]of Object.entries(e.properties||{})){const c=[],p=e.required||[],l={name:`${t}${s(n)}`,required:p.includes(n),use:{in:"body",field:`${a}/${n}`}};if(o.title&&c.push(o.title),o.readOnly)continue;const m=o["x-audience"];if(!m||["user","all"].includes(m)){if(o["x-resource"]){Object.assign(l,{typeLabel:"uri"});const e=i.openapi.getEndpointForKind(o["x-resource"].kind);1==e.length?(Object.assign(l,{typeLabel:"id-or-uri",prefix:e[0]}),c.push("Provide ID or URI of "+o["x-resource"].kind)):c.push("Provide URI of "+o["x-resource"].kind)}if(o["x-permissions"]&&c.push("Requires permissions "+o["x-permissions"].join(", ")),"string"==o.type&&Object.assign(l,{placeholder:n}),"array"==o.type&&"string"==o.items.type&&Object.assign(l,{multiple:!0}),"boolean"==o.type){const e=[!0,!1].map(String);Object.assign(l,{type:e=>"true"==e,typeLabel:e.join(","),choices:e})}if("object"!=o.type){if("array"==o.type&&"object"==o.items.type){const e=Object.entries(o.items.properties||{}).filter(([,e])=>1!=e.readOnly).map(([e])=>`${e}=${e}`).join(",");Object.assign(l,{multiple:!0,typeLabel:e,type:u.nestedValue})}o.default&&(c.push("Defaults is "+o.default),Object.assign(l,{defaultValue:o.default})),Object.assign(l,{description:c.join(". ")}),r.push(l)}else r.push(...d(o,t?`${t}-${n}`:n+"-",`${a}/${n}`))}}return r},m=e=>{if(e.allOf){const t={};for(const a of e.allOf)Object.assign(t,a.properties);return{type:"object",properties:t}}return e},h=(e,t,a)=>{let r=e;for(const[e,,t]of r.matchAll("{((.+?)Id)}"))r=r.replace(e,a[t]);return r};var f={renderOptions:(e,t=[])=>{const a=i.openapi.getSchema(e);return[...l(t),...d(m(a))]},renderBody:(e,t,a)=>{const r={};for(const n of a){if(!n.use||"body"!=n.use.in)continue;let a=t[n.name];n.prefix&&a&&!a.startsWith("/")&&(a=h(n.prefix,e,t)),c(r,n.use.field.replace(/\//g,"."),a)}return r},renderPath:h,renderQuery:(e,t)=>{const a=i.openapi.getResponse(t)||{},r=[];let n;if("array"==a.type?n=a.items.properties||{}:"object"==a.type&&(n=a.properties||{}),n)for(const e of["id","name","state","flavour","content","enabled","size"])n[e]&&r.push(`${e}:${e}`);return 0==r.length&&r.push("value:@"),`[].{${r.join(",")}}`}};const $=(e,t)=>new o.Command({name:e,summary:"Print specification of context",handler:()=>t}),g=({name:e,endpoint:t,method:a,path:r})=>()=>{const n=t[a],s=[...n.parameters||[],...t.parameters||[]],c=f.renderOptions(n,s);return new o.Command({name:e,summary:`${n.summary} [${n.operationId}]`,options:c,tags:[n.operationId],handler:async e=>{const t=e._all||e,o=i.openapi.getUrl(f.renderPath(r,n,t)),s=f.renderBody(n,t,c);e.defaultQuery=f.renderQuery(r,n,t);const u=await e.api[a](o,s);return e.format(e,u)}})},y=(e,t)=>()=>{const a=new o.Category({name:e.type,summary:t.description||`Management of ${e.type} resource`});a.addCommand(()=>$("spec",t));const r=i.openapi.getPath(t.path)||{};r&&(r.post&&a.addCommand(g({...t,name:"create",method:"post",endpoint:r})),r.get&&a.addCommand(g({...t,name:"list",method:"get",endpoint:r})),r.patch&&a.addCommand(g({...t,name:"update",method:"patch",endpoint:r})));for(const{path:r,endpoint:o}of i.openapi.getDetail(t.path)){o.get&&a.addCommand(g({...t,name:"show",method:"get",endpoint:o,path:r})),o.patch&&a.addCommand(g({...t,name:"update",method:"patch",endpoint:o,path:r})),o.delete&&a.addCommand(g({...t,name:"delete",method:"delete",endpoint:o,path:r}));for(const{name:e,path:n,endpoint:o}of i.openapi.getActions(r))for(const r of["post","get"])o[r]&&a.addCommand(g({...t,name:e,method:r,path:n,endpoint:o}));for(const t of i.openapi.getChild(r))a.addCommand(y(t,{path:t.path,description:`Manage ${n()(t.type)} of the ${e.type}`}))}return a},b=(e,t,a)=>async()=>{const r=new o.Category({name:e,summary:`Management of ${e} namespace`,extensions:["@hyperone/cli-ext-"+e]});r.addCommand($("spec",t));const n=[...i.openapi.getChild(a.path)];"iam"!==e&&n.push(...i.openapi.getChild(a.path+"/project/{projectId}"),...i.openapi.getChild(a.path+"/{locationId}/project/{projectId}"));for(const e of n)r.addCommand(y(e,{path:e.path,description:`Management of ${e.type} resource`}));return r};t.default={name:a(2).name,version:a(2).version,load:async e=>{const t=i.openapi.getNamespaces();for(const[a,r]of Object.entries(t))await e.addCommand(b(a,r,{path:"/"+a}))}}}]);
import pluralize from 'pluralize';
import {Category, Command} from '@hyperone/cli-framework';
import {openapi} from '@hyperone/cli-core';
import { Category, Command } from '@hyperone/cli-framework';
import { openapi } from '@hyperone/cli-core';

@@ -14,4 +14,10 @@ import request from './request';

const makeOperationCommand = ({ name, operation, method, path }) => () => {
const options = request.renderOptions(operation);
export const makeOperationCommand = ({ name, endpoint, method, path }) => () => {
const operation = endpoint[method];
const parameters = [
...operation.parameters || [],
...endpoint.parameters || [],
];
const options = request.renderOptions(operation, parameters);
return new Command({

@@ -33,3 +39,3 @@ name,

const makeResourceCommand = (resource, ctx) => () => {
export const makeResourceCommand = (resource, ctx) => () => {
const cmd = new Category({

@@ -40,8 +46,8 @@ name: resource.type,

cmd.addCommand(printCommand('spec', ctx));
cmd.addCommand(() => printCommand('spec', ctx));
const collectionOperation = openapi.getPath(ctx.path) || {};
const collectionEndpoint = openapi.getPath(ctx.path) || {};
if (collectionOperation) {
if (collectionOperation.post) {
if (collectionEndpoint) {
if (collectionEndpoint.post) {
cmd.addCommand(

@@ -52,7 +58,7 @@ makeOperationCommand({

method: 'post',
operation: collectionOperation.post,
endpoint: collectionEndpoint,
})
);
}
if (collectionOperation.get) {
if (collectionEndpoint.get) {
cmd.addCommand(

@@ -63,7 +69,7 @@ makeOperationCommand({

method: 'get',
operation: collectionOperation.get,
endpoint: collectionEndpoint,
})
);
}
if (collectionOperation.patch) {
if (collectionEndpoint.patch) {
cmd.addCommand(

@@ -74,3 +80,3 @@ makeOperationCommand({

method: 'patch',
operation: collectionOperation.patch,
endpoint: collectionEndpoint,
})

@@ -81,6 +87,4 @@ );

const instancePathPrefix = `${ctx.path}/{${resource.type}Id}`;
const instanceOperation = openapi.getPath(instancePathPrefix) || {};
if (instanceOperation) {
if (instanceOperation.get) {
for (const { path, endpoint } of openapi.getDetail(ctx.path)) {
if (endpoint.get) {
cmd.addCommand(

@@ -91,8 +95,8 @@ makeOperationCommand({

method: 'get',
operation: instanceOperation.get,
path: instancePathPrefix,
endpoint,
path,
})
);
}
if (instanceOperation.patch) {
if (endpoint.patch) {
cmd.addCommand(

@@ -103,5 +107,4 @@ makeOperationCommand({

method: 'patch',
operation: instanceOperation.patch,
path: instancePathPrefix,
endpoint,
path,
})

@@ -111,3 +114,3 @@ );

if (instanceOperation.delete) {
if (endpoint.delete) {
cmd.addCommand(

@@ -118,24 +121,28 @@ makeOperationCommand({

method: 'delete',
operation: instanceOperation.delete,
path: instancePathPrefix,
endpoint,
path,
})
);
}
}
for (const { name, path } of openapi.getActions(instancePathPrefix)) {
cmd.addCommand(makeOperationCommand({
...ctx,
name,
method: 'post',
operation: openapi.getPath(path).post,
path,
}));
}
for (const { name, path: actionPath, endpoint } of openapi.getActions(path)) {
for (const method of ['post', 'get']) {
if (!endpoint[method]) continue;
for (const child of openapi.getChild(instancePathPrefix)) {
cmd.addCommand(makeResourceCommand(child, {
path: child.path,
description: `Manage ${pluralize(child.type)} of the ${resource.type}`,
}));
cmd.addCommand(makeOperationCommand({
...ctx,
name,
method,
path: actionPath,
endpoint,
}));
}
}
for (const child of openapi.getChild(path)) {
cmd.addCommand(makeResourceCommand(child, {
path: child.path,
description: `Manage ${pluralize(child.type)} of the ${resource.type}`,
}));
}
}

@@ -146,3 +153,3 @@

const buildNamespaceCommand = (name, spec, ctx) => async () => {
export const buildNamespaceCommand = (name, spec, ctx) => async () => {
const cmd = new Category({

@@ -156,45 +163,20 @@ name,

const parent_cmds = {};
const children = [
...openapi.getChild(ctx.path),
];
for (const resource of spec) {
let path = ctx.path;
if (name !== 'iam') {
children.push(
...openapi.getChild(`${ctx.path}/project/{projectId}`),
...openapi.getChild(`${ctx.path}/{locationId}/project/{projectId}`),
);
}
if (resource.location) {
path = `${path}/{locationId}`;
}
for (const child of children) {
cmd.addCommand(makeResourceCommand(child, {
path: child.path,
description: `Management of ${child.type} resource`,
}));
}
// Custom logic for resource in multiple namespaces
// Example for "iam/policy":
// iam policy - for policy of project
// iam policy organisation - for policy of project
// Example for "website/instance":
// website instance - for instance of project
// Future proof, adding new resources at any level
if (resource.parent) {
for (const parent of resource.parent) {
let parent_cmd;
if (parent == 'project') {
parent_cmd = cmd;
} else {
parent_cmds[parent] = parent_cmds[parent] || new Category({
name: parent,
summary: `Management of ${parent}`,
});
parent_cmd = parent_cmds[parent];
}
parent_cmd.addCommand(makeResourceCommand(resource, {
...ctx,
path: `${path}/${parent}/{${parent}Id}/${resource.type}`,
}));
}
} else {
cmd.addCommand(makeResourceCommand(resource, {
...ctx,
path: `${path}/${resource.type}`,
}));
}
}
cmd.addCommand(...Object.values(parent_cmds));
// fs.subdirectories(directory, false, options.matching)
return cmd;

@@ -201,0 +183,0 @@ };

{
"name": "@hyperone/cli-ext-root-openapi-generator",
"version": "1.0.7",
"version": "1.0.8",
"description": "",

@@ -21,4 +21,4 @@ "main": "dist/index.js",

"dependencies": {
"@hyperone/cli-core": "^1.0.7",
"@hyperone/cli-framework": "^1.0.6",
"@hyperone/cli-core": "^1.0.8",
"@hyperone/cli-framework": "^1.0.8",
"jsonpatch": "^3.0.1",

@@ -28,3 +28,3 @@ "openapi-sampler": "^1.0.0-beta.16",

},
"gitHead": "b51a930fcf67d351fb8243c40b64e8e17d80c10b",
"gitHead": "a3a4d4cf6ce542757ec9adbc129f9b93bea9380e",
"publishConfig": {

@@ -31,0 +31,0 @@ "access": "public"

@@ -5,3 +5,3 @@

import types from '@hyperone/cli-core/types';
import {set} from '@hyperone/cli-core/lib/transform';
import { set } from '@hyperone/cli-core/lib/transform';

@@ -154,11 +154,22 @@ const idless = (name) => name.replace(/Id$/, '');

const renderOptions = (operation) => {
const flatSchema = (schema) => {
if (schema.allOf) {
const properties = {};
for (const sch of schema.allOf) {
Object.assign(properties, sch.properties);
}
return {
type: 'object',
properties,
};
}
return schema;
};
const renderOptions = (operation, parameters=[]) => {
const schema = openapi.getSchema(operation);
const parameters = [
...parameterForParameter(operation.parameters),
...parameterForSchema(schema),
return [
...parameterForParameter(parameters),
...parameterForSchema(flatSchema(schema)),
];
return parameters;
};

@@ -165,0 +176,0 @@

@@ -17,3 +17,2 @@

},
externals: {

@@ -20,0 +19,0 @@ '@hyperone/cli-core':'commonjs2 @hyperone/cli-core',

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