Huge News!Announcing our $40M Series B led by Abstract Ventures.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.16 to 1.0.17

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 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.16","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.16","@hyperone/cli-framework":"^1.0.12","jsonpatch":"^3.0.1","openapi-sampler":"^1.0.0-beta.16","pluralize":"^8.0.0"},"gitHead":"f965f99bb528f0d8a3aa513fe37d64627c6361d9","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 u(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 p(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 u(t,o)}return t}function c(e,t,a){return function(r){var n=r.toLowerCase();return t.hasOwnProperty(n)?i(r,n):e.hasOwnProperty(n)?i(r,e[n]):p(n,r,a)}}function l(e,t,a,r){return function(r){var n=r.toLowerCase();return!!t.hasOwnProperty(n)||!e.hasOwnProperty(n)&&p(n,n,a)===n}}function d(e,t,a){return(a?t+" ":"")+(1===t?d.singular(e):d.plural(e))}return d.plural=c(n,r,e),d.isPlural=l(n,r,e),d.singular=c(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(),u=(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 p={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 c=e=>e.replace(/Id$/,""),l=(e=[])=>{const t=[];for(const a of e){const e=c(a.name),r=[a.description],n={name:s(e),use:{in:a.in,field:a.name}};a.name.endsWith("Id")&&Object.assign(n,{required:!0,defaultSource:e,type:p.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 u=[],c=e.required||[],l={name:`${t}${s(n)}`,required:c.includes(n),use:{in:"body",field:`${a}/${n}`}};if(o.title&&u.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]}),u.push("Provide ID or URI of "+o["x-resource"].kind)):u.push("Provide URI of "+o["x-resource"].kind)}if(o["x-permissions"]&&u.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:p.nestedValue})}o.default&&(u.push("Defaults is "+o.default),Object.assign(l,{defaultValue:o.default})),Object.assign(l,{description:u.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},f=(e,t)=>{const a={};for(const r of t.filter(e=>e.use))e[r.name]&&["path","query"].includes(r.use.in)&&(a[r.use.field]=e[r.name]);return a};var h={renderOptions:(e,t=[])=>{const a=i.openapi.getSchema(e);return[...l(t),...d(m(a))]},renderBody:(e,t,a)=>{const r={},n=f(t,a);for(const e of a){if(!e.use||"body"!=e.use.in)continue;let a=t[e.name];void 0!==a&&(a!=e.defaultValue&&(e.prefix&&a&&!a.startsWith("/")&&(a=i.openapi.renderPath(e.prefix,{...n,[e.name+"Id"]:a})),u(r,e.use.field.replace(/\//g,"."),a)))}return r},renderQuery:(e,t)=>Object.fromEntries(t.filter(t=>t.use&&"query"==t.use.in&&e[t.name]).map(t=>[t.use.field,e[t.name]])),generateQuery:(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(",")}}`},renderParameter:f};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||[]],u=h.renderOptions(n,s);return new o.Command({name:e,summary:`${n.summary} [${n.operationId}]`,options:[...u,{name:"skeleton",type:e=>"true"==e,typeLabel:"true,false",choices:["true","false"]}],tags:[n.operationId],handler:async e=>{const t=e._all||e,o=h.renderParameter(t,u),s=i.openapi.getUrl(r,o),p=h.renderQuery(t,u);let c;if(e.defaultQuery=h.generateQuery(r,n,t),["post","patch","put"].includes(a)&&(c=h.renderBody(n,t,u)),t.skeleton)return{parameters:o,requestBody:c||{}};const l=await e.api[a](s,{json:c,query:p});return e.format(e,l)}})},y=(e,t)=>()=>{const a=new o.Category({name:s(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}))}}}]);
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.17","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.17","@hyperone/cli-framework":"^1.0.17","jsonpatch":"^3.0.1","openapi-sampler":"^1.0.0-beta.16","pluralize":"^8.0.0"},"gitHead":"596e620b30d7431c04af75d402f5f986e1569c34","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 u(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 p(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 u(t,o)}return t}function c(e,t,a){return function(r){var n=r.toLowerCase();return t.hasOwnProperty(n)?i(r,n):e.hasOwnProperty(n)?i(r,e[n]):p(n,r,a)}}function l(e,t,a,r){return function(r){var n=r.toLowerCase();return!!t.hasOwnProperty(n)||!e.hasOwnProperty(n)&&p(n,n,a)===n}}function d(e,t,a){return(a?t+" ":"")+(1===t?d.singular(e):d.plural(e))}return d.plural=c(n,r,e),d.isPlural=l(n,r,e),d.singular=c(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(),u=(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 p={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 c=e=>e.replace(/Id$/,""),l=(e=[])=>{const t=[];for(const a of e){const e=c(a.name),r=[a.description],n={name:s(e),use:{in:a.in,field:a.name}};a.name.endsWith("Id")&&Object.assign(n,{required:!0,defaultSource:e,type:p.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 u=[],c=e.required||[],l={name:`${t}${s(n)}`,required:c.includes(n),use:{in:"body",field:`${a}/${n}`}};if(o.title&&u.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]}),u.push("Provide ID or URI of "+o["x-resource"].kind)):u.push("Provide URI of "+o["x-resource"].kind)}if(o["x-permissions"]&&u.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:p.nestedValue})}o.default&&(u.push("Defaults is "+o.default),Object.assign(l,{defaultValue:o.default})),Object.assign(l,{description:u.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},f=(e,t)=>{const a={};for(const r of t.filter(e=>e.use))e[r.name]&&["path","query"].includes(r.use.in)&&(a[r.use.field]=e[r.name]);return a};var h={renderOptions:(e,t=[])=>{const a=i.openapi.getSchema(e);return[...l(t),...d(m(a))]},renderBody:(e,t,a)=>{const r={},n=f(t,a);for(const e of a){if(!e.use||"body"!=e.use.in)continue;let a=t[e.name];void 0!==a&&(a!=e.defaultValue&&(e.prefix&&a&&!a.startsWith("/")&&(a=i.openapi.renderPath(e.prefix,{...n,[e.name+"Id"]:a})),u(r,e.use.field.replace(/\//g,"."),a)))}return r},renderQuery:(e,t)=>Object.fromEntries(t.filter(t=>t.use&&"query"==t.use.in&&e[t.name]).map(t=>[t.use.field,e[t.name]])),generateQuery:(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(",")}}`},renderParameter:f};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||[]],u=h.renderOptions(n,s),p=new o.Command({name:e,summary:`${n.summary} [${n.operationId}]`,options:[...u,{name:"skeleton",type:e=>"true"==e,typeLabel:"true,false",choices:["true","false"]}],tags:[n.operationId],examples:async()=>{if(!n["x-examples"])return[];const e=await n["x-examples"](),t=[];for(const[a,r]of Object.entries(e))t.push({title:a,command:await p.generateArgv(r).join(" ")});return t},handler:async e=>{const t=e._all||e,o=h.renderParameter(t,u),s=i.openapi.getUrl(r,o),p=h.renderQuery(t,u);let c;if(e.defaultQuery=h.generateQuery(r,n,t),["post","patch","put"].includes(a)&&(c=h.renderBody(n,t,u)),t.skeleton)return{parameters:o,requestBody:c||{}};const l=await e.api[a](s,{json:c,query:p});return e.format(e,l)}});return p},y=(e,t)=>()=>{const a=new o.Category({name:s(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}))}}}]);

@@ -22,4 +22,3 @@

const options = request.renderOptions(operation, parameters);
return new Command({
const cmd = new Command({
name,

@@ -37,2 +36,16 @@ summary: `${operation.summary} [${operation.operationId}]`,

tags: [operation.operationId],
examples: async () => {
if (!operation['x-examples']) {
return [];
}
const openApiexamples = await operation['x-examples']();
const cliExamples = [];
for (const [title, example] of Object.entries(openApiexamples)) {
cliExamples.push({
title,
command: await cmd.generateArgv(example).join(' '),
});
}
return cliExamples;
},
handler: async (opts) => {

@@ -63,2 +76,3 @@ const optsAll = opts._all || opts;

});
return cmd;
};

@@ -65,0 +79,0 @@

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

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

"dependencies": {
"@hyperone/cli-core": "^1.0.16",
"@hyperone/cli-framework": "^1.0.12",
"@hyperone/cli-core": "^1.0.17",
"@hyperone/cli-framework": "^1.0.17",
"jsonpatch": "^3.0.1",

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

},
"gitHead": "f965f99bb528f0d8a3aa513fe37d64627c6361d9",
"gitHead": "596e620b30d7431c04af75d402f5f986e1569c34",
"publishConfig": {

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

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