@povio/openapi-codegen-cli 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sh.js CHANGED
@@ -137,7 +137,7 @@ ${y.join(`
137
137
  `:`
138
138
  `)+r,i=n+1,n=e.indexOf(`
139
139
  `,i)}while(n!==-1);return s+=e.slice(i),s}o(Oy,"stringEncaseCRLFWithFirstIndex");var{stdout:Py,stderr:wy}=_y,Vl=Symbol("GENERATOR"),ro=Symbol("STYLER"),us=Symbol("IS_EMPTY"),$y=["ansi","ansi","ansi256","ansi16m"],no=Object.create(null),C$=o((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=Py?Py.level:0;e.level=t.level===void 0?r:t.level},"applyOptions"),zl=class zl{constructor(t){return Ey(t)}};o(zl,"Chalk");var Ja=zl,Ey=o(e=>{let t=o((...r)=>r.join(" "),"chalk");return C$(t,e),Object.setPrototypeOf(t,ls.prototype),t},"chalkFactory");function ls(e){return Ey(e)}o(ls,"createChalk");Object.setPrototypeOf(ls.prototype,Function.prototype);for(let[e,t]of Object.entries(mr))no[e]={get(){let r=Xa(this,Ul(t.open,t.close,this[ro]),this[us]);return Object.defineProperty(this,e,{value:r}),r}};no.visible={get(){let e=Xa(this,this[ro],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var Hl=o((e,t,r,...n)=>e==="rgb"?t==="ansi16m"?mr[r].ansi16m(...n):t==="ansi256"?mr[r].ansi256(mr.rgbToAnsi256(...n)):mr[r].ansi(mr.rgbToAnsi(...n)):e==="hex"?Hl("rgb",t,r,...mr.hexToRgb(...n)):mr[r][e](...n),"getModelAnsi"),T$=["rgb","hex","ansi256"];for(let e of T$){no[e]={get(){let{level:r}=this;return function(...n){let i=Ul(Hl(e,$y[r],"color",...n),mr.color.close,this[ro]);return Xa(this,i,this[us])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);no[t]={get(){let{level:r}=this;return function(...n){let i=Ul(Hl(e,$y[r],"bgColor",...n),mr.bgColor.close,this[ro]);return Xa(this,i,this[us])}}}}var j$=Object.defineProperties(()=>{},{...no,level:{enumerable:!0,get(){return this[Vl].level},set(e){this[Vl].level=e}}}),Ul=o((e,t,r)=>{let n,i;return r===void 0?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},"createStyler"),Xa=o((e,t,r)=>{let n=o((...i)=>R$(n,i.length===1?""+i[0]:i.join(" ")),"builder");return Object.setPrototypeOf(n,j$),n[Vl]=e,n[ro]=t,n[us]=r,n},"createBuilder"),R$=o((e,t)=>{if(e.level<=0||!t)return e[us]?"":t;let r=e[ro];if(r===void 0)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=Sy(t,r.close,r.open),r=r.parent;let s=t.indexOf(`
140
- `);return s!==-1&&(t=Oy(t,i,n,s)),n+t+i},"applyStyle");Object.defineProperties(ls.prototype,no);var aF=ls(),cF=ls({level:wy?wy.level:0});var Rr=new Ja;function fs(e,t,r){console.log(r!==void 0&&r!==t?`${Rr.yellow(`${e}:`.padEnd(20))}${Rr.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}o(fs,"logVariable");function tr(e){console.log(`[INFO] ${e}`)}o(tr,"logInfo");function yn(e){console.log(Rr.green(`[SUCCESS] ${e}`))}o(yn,"logSuccess");function ps(e,t){e instanceof Error?(console.log(Rr.red(`[ERROR] ${t||e.message}`)),process.env.VERBOSE&&console.error(e)):console.log(Rr.red(`[ERROR] ${e}`))}o(ps,"logError");function ec(e){console.log(Rr.bgYellow(`==== ${e} ====`))}o(ec,"logBanner");var xy=gt(require("fs"));function io(){return"0.4.5"}o(io,"getVersion");var SF=gt(Iy());var Gl=Symbol("options_key");function ut(e){return(t,r)=>{var n,i;if(e!=null){let s={...Reflect.getMetadata(Gl,t)||{},[r]:{...e,describe:e.envAlias?`${e.describe||""} [${e.envAlias}]`:e.describe,type:e.type||((i=(n=Reflect.getMetadata("design:type",t,r))==null?void 0:n.name)==null?void 0:i.toLowerCase())}};Reflect.defineMetadata(Gl,s,t)}}}o(ut,"YargOption");function Cy(e){let t=Reflect.getMetadata(Gl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}o(Cy,"getYargsOption");function tc(e){return async t=>t.options(N$(e)).middleware(async r=>await k$(e,r),!0)}o(tc,"getBuilder");function N$(e){return Object.entries(Cy(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}o(N$,"getYargsOptions");async function k$(e,t){let r=new e;for(let[n,i]of Object.entries(Cy(e)))r[n]=t[n]??i.default;return r}o(k$,"loadYargsConfig");var f1=gt(qh());var oP="Schema",sP="Enum",aP="Body",cP="Param",uP="Response",lP="ErrorResponse",Dh="z.void()",au={bindings:["z"],from:"zod"};var cu={input:"input.yaml",output:"output",splitByTags:!0,defaultTag:"Common",excludeTags:[],includeNamespaces:!0,importPath:"ts",extractEnums:!0,configs:{models:{outputFileNameSuffix:"models",namespaceSuffix:"Models"},endpoints:{outputFileNameSuffix:"api",namespaceSuffix:"Api"},queries:{outputFileNameSuffix:"queries",namespaceSuffix:"Queries"},acl:{outputFileNameSuffix:"acl",namespaceSuffix:"Acl"}},schemaSuffix:oP,enumSuffix:sP,additionalPropertiesDefaultValue:!1,removeOperationPrefixEndingWith:"Controller_"};var fP={"invalid-schema":"Invalid Schemas","invalid-operation-id":"Invalid Operation IDs","missing-path-parameter":"Missing Path Parameters","not-allowed-inline-enum":"Not Allowed Inline Enums","not-allowed-circular-schema":"Not Allowed Circular Schemas","missing-acl-condition-property":"Missing x-acl Condition Property"};var Lh={"Content-Type":"application/json",Accept:"application/json"},pP="data";var dP=o(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),Nn=o(e=>e.replace(/^[^a-zA-Z_$]*/g,"").replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var nn=Symbol.for("@ts-pattern/matcher"),CM=Symbol.for("@ts-pattern/isVariadic"),lu="@ts-pattern/anonymous-select-key",Fh=o(e=>!!(e&&typeof e=="object"),"r"),uu=o(e=>e&&!!e[nn],"i"),Gr=o((e,t,r)=>{if(uu(e)){let n=e[nn](),{matched:i,selections:s}=n.match(t);return i&&s&&Object.keys(s).forEach(a=>r(a,s[a])),i}if(Fh(e)){if(!Fh(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],s=[];for(let a of e.keys()){let c=e[a];uu(c)&&c[CM]?s.push(c):s.length?i.push(c):n.push(c)}if(s.length){if(s.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<n.length+i.length)return!1;let a=t.slice(0,n.length),c=i.length===0?[]:t.slice(-i.length),u=t.slice(n.length,i.length===0?1/0:-i.length);return n.every((l,p)=>Gr(l,a[p],r))&&i.every((l,p)=>Gr(l,c[p],r))&&(s.length===0||Gr(s[0],u,r))}return e.length===t.length&&e.every((a,c)=>Gr(a,t[c],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||uu(s=i)&&s[nn]().matcherType==="optional")&&Gr(i,t[n],r);var s})}return Object.is(t,e)},"s"),Ln=o(e=>{var t,r,n;return Fh(e)?uu(e)?(t=(r=(n=e[nn]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?ia(e,Ln):ia(Object.values(e),Ln):[]},"o"),ia=o((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function cr(e){return Object.assign(e,{optional:o(()=>TM(e),"optional"),and:o(t=>Fe(e,t),"and"),or:o(t=>jM(e,t),"or"),select:o(t=>t===void 0?hP(e):hP(t,e),"select")})}o(cr,"u");function TM(e){return cr({[nn]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return t===void 0?(Ln(e).forEach(i=>n(i,void 0)),{matched:!0,selections:r}):{matched:Gr(e,t,n),selections:r}},"match"),getSelectionKeys:o(()=>Ln(e),"getSelectionKeys"),matcherType:"optional"})})}o(TM,"h");function Fe(...e){return cr({[nn]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return{matched:e.every(i=>Gr(i,t,n)),selections:r}},"match"),getSelectionKeys:o(()=>ia(e,Ln),"getSelectionKeys"),matcherType:"and"})})}o(Fe,"m");function jM(...e){return cr({[nn]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return ia(e,Ln).forEach(i=>n(i,void 0)),{matched:e.some(i=>Gr(i,t,n)),selections:r}},"match"),getSelectionKeys:o(()=>ia(e,Ln),"getSelectionKeys"),matcherType:"or"})})}o(jM,"d");function Oe(e){return{[nn]:()=>({match:o(t=>({matched:!!e(t)}),"match")})}}o(Oe,"p");function hP(...e){let t=typeof e[0]=="string"?e[0]:void 0,r=e.length===2?e[1]:typeof e[0]=="string"?void 0:e[0];return cr({[nn]:()=>({match:o(n=>{let i={[t??lu]:n};return{matched:r===void 0||Gr(r,n,(s,a)=>{i[s]=a}),selections:i}},"match"),getSelectionKeys:o(()=>[t??lu].concat(r===void 0?[]:Ln(r)),"getSelectionKeys")})})}o(hP,"y");function Ur(e){return typeof e=="number"}o(Ur,"v");function kn(e){return typeof e=="string"}o(kn,"b");function Mn(e){return typeof e=="bigint"}o(Mn,"w");var B9=cr(Oe(function(e){return!0}));var qn=o(e=>Object.assign(cr(e),{startsWith:o(t=>{return qn(Fe(e,(r=t,Oe(n=>kn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:o(t=>{return qn(Fe(e,(r=t,Oe(n=>kn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:o(t=>qn(Fe(e,(r=>Oe(n=>kn(n)&&n.length>=r))(t))),"minLength"),length:o(t=>qn(Fe(e,(r=>Oe(n=>kn(n)&&n.length===r))(t))),"length"),maxLength:o(t=>qn(Fe(e,(r=>Oe(n=>kn(n)&&n.length<=r))(t))),"maxLength"),includes:o(t=>{return qn(Fe(e,(r=t,Oe(n=>kn(n)&&n.includes(r)))));var r},"includes"),regex:o(t=>{return qn(Fe(e,(r=t,Oe(n=>kn(n)&&!!n.match(r)))));var r},"regex")}),"j"),V9=qn(Oe(kn)),zr=o(e=>Object.assign(cr(e),{between:o((t,r)=>zr(Fe(e,((n,i)=>Oe(s=>Ur(s)&&n<=s&&i>=s))(t,r))),"between"),lt:o(t=>zr(Fe(e,(r=>Oe(n=>Ur(n)&&n<r))(t))),"lt"),gt:o(t=>zr(Fe(e,(r=>Oe(n=>Ur(n)&&n>r))(t))),"gt"),lte:o(t=>zr(Fe(e,(r=>Oe(n=>Ur(n)&&n<=r))(t))),"lte"),gte:o(t=>zr(Fe(e,(r=>Oe(n=>Ur(n)&&n>=r))(t))),"gte"),int:o(()=>zr(Fe(e,Oe(t=>Ur(t)&&Number.isInteger(t)))),"int"),finite:o(()=>zr(Fe(e,Oe(t=>Ur(t)&&Number.isFinite(t)))),"finite"),positive:o(()=>zr(Fe(e,Oe(t=>Ur(t)&&t>0))),"positive"),negative:o(()=>zr(Fe(e,Oe(t=>Ur(t)&&t<0))),"negative")}),"x"),H9=zr(Oe(Ur)),Dn=o(e=>Object.assign(cr(e),{between:o((t,r)=>Dn(Fe(e,((n,i)=>Oe(s=>Mn(s)&&n<=s&&i>=s))(t,r))),"between"),lt:o(t=>Dn(Fe(e,(r=>Oe(n=>Mn(n)&&n<r))(t))),"lt"),gt:o(t=>Dn(Fe(e,(r=>Oe(n=>Mn(n)&&n>r))(t))),"gt"),lte:o(t=>Dn(Fe(e,(r=>Oe(n=>Mn(n)&&n<=r))(t))),"lte"),gte:o(t=>Dn(Fe(e,(r=>Oe(n=>Mn(n)&&n>=r))(t))),"gte"),positive:o(()=>Dn(Fe(e,Oe(t=>Mn(t)&&t>0))),"positive"),negative:o(()=>Dn(Fe(e,Oe(t=>Mn(t)&&t<0))),"negative")}),"A"),U9=Dn(Oe(Mn)),z9=cr(Oe(function(e){return typeof e=="boolean"})),G9=cr(Oe(function(e){return typeof e=="symbol"})),Z9=cr(Oe(function(e){return e==null})),W9=cr(Oe(function(e){return e!=null}));var Uh=class Uh extends Error{constructor(t){let r;try{r=JSON.stringify(t)}catch{r=t}super(`Pattern matching error: no pattern matches value ${r}`),this.input=void 0,this.input=t}};o(Uh,"W");var Bh=Uh,Vh={matched:!1,value:void 0};function Ot(e){return new Hh(e,Vh)}o(Ot,"z");var na=class na{constructor(t,r){this.input=void 0,this.state=void 0,this.input=t,this.state=r}with(...t){if(this.state.matched)return this;let r=t[t.length-1],n=[t[0]],i;t.length===3&&typeof t[1]=="function"?i=t[1]:t.length>2&&n.push(...t.slice(1,t.length-1));let s=!1,a={},c=o((l,p)=>{s=!0,a[l]=p},"a"),u=!n.some(l=>Gr(l,this.input,c))||i&&!i(this.input)?Vh:{matched:!0,value:r(s?lu in a?a[lu]:a:this.input,this.input)};return new na(this.input,u)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new na(this.input,n?{matched:!0,value:r(this.input,this.input)}:Vh)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new Bh(this.input)}run(){return this.exhaustive()}returnType(){return this}};o(na,"I");var Hh=na;var mP=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with"];var zh=2,gP=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],yP=["query","header","path"],Fn=["get","put","post","delete","options","head","patch","trace"],bP=["string","number","integer","boolean"],Gh=["allOf","anyOf","oneOf"];function Bn(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}o(Bn,"pick");var et=o(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),ki=o(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),fu=o(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),ht=o(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),vP=o(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),Zh=o((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),_P=o((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix"),RM=o(e=>{var n;let t=e.reduce((i,s)=>({...i,[s]:(i[s]??0)+1}),{});return(n=Object.entries(t).sort((i,s)=>i[1]===s[1]?s[0].length-i[0].length:s[1]-i[1])[0])==null?void 0:n[0]},"getLongestMostCommon"),Wh=o(e=>{let t=e.map(et).map(NM).map(r=>kM(r)).flat();return RM(t)},"getMostCommonAdjacentCombinationSplit"),NM=o(e=>e.split(/(?<![A-Z])(?=[A-Z])/).filter(Boolean),"splitByUppercase"),kM=o((e,t=["dto","by","for","of","in","to","and","with"])=>{var n;let r=[];for(let i=0;i<e.length;i++)if(!t.includes(e[i].toLowerCase()))for(let s=i+1;s<=e.length;s++)t.includes((n=e[s-1])==null?void 0:n.toLowerCase())||r.push(e.slice(i,s).join(""));return r},"getAdjacentStringCombinations");function Vn(e){return vP(e)}o(Vn,"formatTag");function Mi(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return Vn(r??t.defaultTag)}o(Mi,"getOperationTag");function SP(e,t){let r={};for(let n in e.paths){let i=e.paths[n],s=Bn(i,Fn);for(let a in s){let c=s[a];if(!c||c.deprecated&&!(t!=null&&t.withDeprecatedEndpoints))continue;let u=t.splitByTags?Mi(c,t):t.defaultTag;r[u]||(r[u]=[]),r[u].push(c)}}return r}o(SP,"getOperationsByTag");var PP=o(e=>`#/components/schemas/${e}`,"getSchemaRef"),qi=o(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),Uo=o(e=>qi(e).split("/").at(-1),"getSchemaNameByRef");function Ie(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}o(Ie,"isReferenceObject");function Qh(e){let t=MM(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/--+/g,"-").replace(/-+/g,"_").replace(/[^\w-]+/g,"_");return ht(t)}o(Qh,"normalizeString");function wP(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}o(wP,"wrapWithQuotesIfNeeded");function $P(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}o($P,"unwrapQuotesIfNeeded");function MM(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}o(MM,"prefixStringStartingWithNumberIfNeeded");function Jh(e){let t=e.replaceAll("_","#");return ht(t.replaceAll("-","_")).replaceAll("#","_")}o(Jh,"pathParamToVariableName");var Di=o(e=>bP.includes(e),"isPrimitiveType");function EP(e){return e.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/([\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\uFFFE\uFFFF])/g,(t,r)=>{let n=r.codePointAt(),i=n.toString(16);return n<=255?`\\x${`00${i}`.slice(-2)}`:`\\u${`0000${i}`.slice(-4)}`}).replace(/\//g,"\\/")}o(EP,"escapeControlCharacters");function Hn(e){return e.includes("application/")&&e.includes("json")||gP.includes(e)||e.includes("text/")}o(Hn,"isParamMediaTypeAllowed");function pu(e){return e>=200&&e<300}o(pu,"isMainResponseStatus");function du(e){return!(e>=200&&e<300)}o(du,"isErrorStatus");function hu(e){return e==="application/json"}o(hu,"isMediaTypeAllowed");function Kh({path:e,method:t,operation:r,options:n,keepOperationPrefixWithoutEnding:i}){let s=`${t}${DM(e)}`,a=r.operationId?Nn(r.operationId):s;if(n.removeOperationPrefixEndingWith&&i)return a.split(n.removeOperationPrefixEndingWith).map((u,l)=>l===0?u:et(u)).join("");if(n.removeOperationPrefixEndingWith&&!i){let c=new RegExp(`^.*${n.removeOperationPrefixEndingWith}`);a=a.replace(c,"")}return mP.includes(a)?s:a}o(Kh,"getOperationName");function oa({path:e,method:t,operation:r,operationsByTag:n,options:i}){let s=i.splitByTags?Mi(r,i):i.defaultTag,a=Kh({path:e,method:t,operation:r,options:i});return n[s].filter(u=>Kh({path:e,method:t,operation:u,options:i})===a).length===1?a:Kh({path:e,method:t,operation:r,options:i,keepOperationPrefixWithoutEnding:!0})}o(oa,"getUniqueOperationName");function xP(e,t,r){let n=[];for(let i in e.paths){let s=e.paths[i],a=Bn(s,Fn);for(let c in a){let u=a[c];if(!u||u.deprecated&&!(r!=null&&r.withDeprecatedEndpoints))continue;let l=oa({path:i,method:c,operation:u,operationsByTag:t,options:r});n.push(l)}}return n}o(xP,"getUniqueOperationNamesWithoutSplitByTags");var OP=/({\w+})/g,qM=/[^\w\-]+/g;function DM(e){e=et(fu(e.replaceAll("/","-")).replaceAll("-",""));let t=[...e.matchAll(OP)];if(t.length>0){let r=t.sort((n,i)=>n.index-i.index)[t.length-1][0];e=`${e.replace(OP,"")}By${et(r.slice(1,-1))}`}return e.replace(qM,"_")}o(DM,"pathToVariableName");var Yh=/{(\b\w+(?:-\w+)*\b)}/g;function AP(e){let t=e.match(Yh);return t===null?e.replaceAll(Yh,":$1"):(t.forEach(r=>{let n=Jh(r.replaceAll(Yh,":$1"));e=e.replaceAll(r,n)}),e)}o(AP,"replaceHyphenatedPath");function Zr(e){return!Ie(e)}o(Zr,"isSchemaObject");function IP(e){return e.type==="array"}o(IP,"isArraySchemaObject");function CP(e){if(!e.allOf)throw new Error("Function inferRequiredSchema is specialized to handle item with required only in an allOf array.");let[t,r]=e.allOf.reduce((i,s)=>{if(LM(s)){let a=s.required;i[0].push(...a??[])}else i[1].push(s);return i},[[],[]]),n={properties:t.reduce((i,s)=>(i[s]={},i),{}),type:"object",required:t};return{noRequiredOnlyAllof:r,composedRequiredSchema:n,patchRequiredSchemaInLoop:o((i,s)=>{if(Ie(i)){let a=s(i.$ref);a&&n.required.forEach(c=>{var u;n.properties[c]=((u=a==null?void 0:a.properties)==null?void 0:u[c])??{}})}else{let a=i.properties??{};n.required.forEach(c=>{a[c]&&(n.properties[c]=a[c]??{})})}},"patchRequiredSchemaInLoop")}}o(CP,"inferRequiredSchema");var LM=o(e=>!Ie(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function Un({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${ki(t)}/`:""}${ki(t)}.${i}`:i}o(Un,"getTagFileName");var Qe=o(({type:e,tag:t,options:r})=>`${et(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var on=o((e,t)=>Zh(et(Qh(e)),t),"getZodSchemaName"),TP=o((e,t,r)=>Zh(et(Qh(e)),`${t}${r}`),"getEnumZodSchemaName"),Dt=o(e=>!e.startsWith("z."),"isNamedZodSchema"),Li=o((e,t,r)=>t?e:`${r}_${e}`,"getZodSchemaOperationName"),mu=o(e=>ht(`${e}_${aP}`),"getBodyZodSchemaName"),jP=o((e,t)=>ht(`${e}_${t}${cP}`),"getParamZodSchemaName"),FM=o(e=>ht(`${e}${uP}`),"getMainResponseZodSchemaName"),BM=o((e,t)=>ht(`${e}_${t}_${lP}`),"getErrorResponseZodSchemaName");function gu({statusCode:e,operationName:t,isUniqueOperationName:r,tag:n}){let i=Number(e),s=Li(t,r,n);return!pu(i)&&e!=="default"&&du(i)?BM(s,e):FM(s)}o(gu,"getResponseZodSchemaName");var sa=o((e,t)=>_P(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),RP=o((e,t)=>Dt(t)?`${e.options.includeNamespaces?`${Qe({type:"models",tag:e.getTagByZodSchemaName(t),options:e.options})}.`:""}${t}`:t,"getImportedZodSchemaName"),Xh=o((e,t)=>Dt(t)?`${e.options.includeNamespaces?`${Qe({type:"models",tag:e.getTagByZodSchemaName(t),options:e.options})}.`:""}${sa(t,e.options)}`:t,"getImportedZodSchemaInferedTypeName");function NP(e){return Ot(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}o(NP,"primitiveTypeToTsType");var aa=o(e=>ki(ht(e.operationName)),"getEndpointName");function kP(e,t){return`${t.includeNamespaces?`${Qe({type:"endpoints",tag:ca(e,t),options:t})}.`:""}${aa(e)}`}o(kP,"getImportedEndpointName");var MP=o(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function ca(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return Vn(r??t.defaultTag)}o(ca,"getEndpointTag");function em(e,t){return t.parameters.map(r=>{var i,s,a,c;let n="string";if(Dt(r.zodSchema))n=Xh(e,r.zodSchema);else if((i=r.parameterObject)!=null&&i.schema&&Zr(r.parameterObject.schema)){let u=(a=(s=r.parameterObject)==null?void 0:s.schema)==null?void 0:a.type;u&&Di(u)&&(n=NP(u))}return{name:Nn(r.name),type:n,paramType:r.type,required:((c=r.parameterObject)==null?void 0:c.required)??!0}}).sort((r,n)=>{if(r.required===n.required){let i=["Path","Body","Query","Header"];return i.indexOf(r.paramType)-i.indexOf(n.paramType)}return r.required?-1:1})}o(em,"mapEndpointParamsToFunctionParams");function qP(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let s=dP(i.name)?i.name:`"${i.name}"`,a=Nn(i.name);return{...i,name:s,value:a}}),r={};return e.requestFormat!==Lh["Content-Type"]&&(r["Content-Type"]=`'${e.requestFormat}'`),e.responseFormat&&e.responseFormat!==Lh.Accept&&(r.Accept=`'${e.responseFormat}'`),e.parameters.filter(i=>i.type==="Header").forEach(i=>{r[i.name]=Nn(i.name)}),{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}o(qP,"getEndpointConfig");function yu(e){return{type:"invalid-schema",message:e}}o(yu,"getInvalidSchemaError");function DP(e){return{type:"invalid-operation-id",message:`Operation ${e}`}}o(DP,"getInvalidOperationIdError");function LP(e,t){return{type:"missing-path-parameter",message:`Path ${t} is missing [${e.map(({name:r})=>r).join(", ")}]`}}o(LP,"getMissingPathParameterError");function FP(e){return{type:"not-allowed-inline-enum",message:e}}o(FP,"getNotAllowedInlineEnumError");function BP(e){return{type:"not-allowed-circular-schema",message:e}}o(BP,"getNotAllowedCircularSchemaError");function VP(e,t){return{type:"missing-acl-condition-property",message:`Condition property ${e} is not found in parameters or body in operation ${t}`}}o(VP,"getMissingAclConditionPropertyError");function HP(e){return e.reduce((t,r)=>({...t,[r.type]:[...t[r.type]??[],r.message]}),{})}o(HP,"groupByType");function Wr({schema:e,meta:t,options:r}){let n=[];Ot(e.type).with("string",()=>n.push(UM(e))).with("number","integer",()=>n.push(GM(e))).with("array",()=>n.push(ZM(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
140
+ `);return s!==-1&&(t=Oy(t,i,n,s)),n+t+i},"applyStyle");Object.defineProperties(ls.prototype,no);var aF=ls(),cF=ls({level:wy?wy.level:0});var Rr=new Ja;function fs(e,t,r){console.log(r!==void 0&&r!==t?`${Rr.yellow(`${e}:`.padEnd(20))}${Rr.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}o(fs,"logVariable");function tr(e){console.log(`[INFO] ${e}`)}o(tr,"logInfo");function yn(e){console.log(Rr.green(`[SUCCESS] ${e}`))}o(yn,"logSuccess");function ps(e,t){e instanceof Error?(console.log(Rr.red(`[ERROR] ${t||e.message}`)),process.env.VERBOSE&&console.error(e)):console.log(Rr.red(`[ERROR] ${e}`))}o(ps,"logError");function ec(e){console.log(Rr.bgYellow(`==== ${e} ====`))}o(ec,"logBanner");var xy=gt(require("fs"));function io(){return"0.4.6"}o(io,"getVersion");var SF=gt(Iy());var Gl=Symbol("options_key");function ut(e){return(t,r)=>{var n,i;if(e!=null){let s={...Reflect.getMetadata(Gl,t)||{},[r]:{...e,describe:e.envAlias?`${e.describe||""} [${e.envAlias}]`:e.describe,type:e.type||((i=(n=Reflect.getMetadata("design:type",t,r))==null?void 0:n.name)==null?void 0:i.toLowerCase())}};Reflect.defineMetadata(Gl,s,t)}}}o(ut,"YargOption");function Cy(e){let t=Reflect.getMetadata(Gl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}o(Cy,"getYargsOption");function tc(e){return async t=>t.options(N$(e)).middleware(async r=>await k$(e,r),!0)}o(tc,"getBuilder");function N$(e){return Object.entries(Cy(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}o(N$,"getYargsOptions");async function k$(e,t){let r=new e;for(let[n,i]of Object.entries(Cy(e)))r[n]=t[n]??i.default;return r}o(k$,"loadYargsConfig");var f1=gt(qh());var oP="Schema",sP="Enum",aP="Body",cP="Param",uP="Response",lP="ErrorResponse",Dh="z.void()",au={bindings:["z"],from:"zod"};var cu={input:"input.yaml",output:"output",splitByTags:!0,defaultTag:"Common",excludeTags:[],includeNamespaces:!0,importPath:"ts",extractEnums:!0,configs:{models:{outputFileNameSuffix:"models",namespaceSuffix:"Models"},endpoints:{outputFileNameSuffix:"api",namespaceSuffix:"Api"},queries:{outputFileNameSuffix:"queries",namespaceSuffix:"Queries"},acl:{outputFileNameSuffix:"acl",namespaceSuffix:"Acl"}},schemaSuffix:oP,enumSuffix:sP,additionalPropertiesDefaultValue:!1,removeOperationPrefixEndingWith:"Controller_"};var fP={"invalid-schema":"Invalid Schemas","invalid-operation-id":"Invalid Operation IDs","missing-path-parameter":"Missing Path Parameters","not-allowed-inline-enum":"Not Allowed Inline Enums","not-allowed-circular-schema":"Not Allowed Circular Schemas","missing-acl-condition-property":"Missing x-acl Condition Property"};var Lh={"Content-Type":"application/json",Accept:"application/json"},pP="data";var dP=o(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),Nn=o(e=>e.replace(/^[^a-zA-Z_$]*/g,"").replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var nn=Symbol.for("@ts-pattern/matcher"),CM=Symbol.for("@ts-pattern/isVariadic"),lu="@ts-pattern/anonymous-select-key",Fh=o(e=>!!(e&&typeof e=="object"),"r"),uu=o(e=>e&&!!e[nn],"i"),Gr=o((e,t,r)=>{if(uu(e)){let n=e[nn](),{matched:i,selections:s}=n.match(t);return i&&s&&Object.keys(s).forEach(a=>r(a,s[a])),i}if(Fh(e)){if(!Fh(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],s=[];for(let a of e.keys()){let c=e[a];uu(c)&&c[CM]?s.push(c):s.length?i.push(c):n.push(c)}if(s.length){if(s.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<n.length+i.length)return!1;let a=t.slice(0,n.length),c=i.length===0?[]:t.slice(-i.length),u=t.slice(n.length,i.length===0?1/0:-i.length);return n.every((l,p)=>Gr(l,a[p],r))&&i.every((l,p)=>Gr(l,c[p],r))&&(s.length===0||Gr(s[0],u,r))}return e.length===t.length&&e.every((a,c)=>Gr(a,t[c],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||uu(s=i)&&s[nn]().matcherType==="optional")&&Gr(i,t[n],r);var s})}return Object.is(t,e)},"s"),Ln=o(e=>{var t,r,n;return Fh(e)?uu(e)?(t=(r=(n=e[nn]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?ia(e,Ln):ia(Object.values(e),Ln):[]},"o"),ia=o((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function cr(e){return Object.assign(e,{optional:o(()=>TM(e),"optional"),and:o(t=>Fe(e,t),"and"),or:o(t=>jM(e,t),"or"),select:o(t=>t===void 0?hP(e):hP(t,e),"select")})}o(cr,"u");function TM(e){return cr({[nn]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return t===void 0?(Ln(e).forEach(i=>n(i,void 0)),{matched:!0,selections:r}):{matched:Gr(e,t,n),selections:r}},"match"),getSelectionKeys:o(()=>Ln(e),"getSelectionKeys"),matcherType:"optional"})})}o(TM,"h");function Fe(...e){return cr({[nn]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return{matched:e.every(i=>Gr(i,t,n)),selections:r}},"match"),getSelectionKeys:o(()=>ia(e,Ln),"getSelectionKeys"),matcherType:"and"})})}o(Fe,"m");function jM(...e){return cr({[nn]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return ia(e,Ln).forEach(i=>n(i,void 0)),{matched:e.some(i=>Gr(i,t,n)),selections:r}},"match"),getSelectionKeys:o(()=>ia(e,Ln),"getSelectionKeys"),matcherType:"or"})})}o(jM,"d");function Oe(e){return{[nn]:()=>({match:o(t=>({matched:!!e(t)}),"match")})}}o(Oe,"p");function hP(...e){let t=typeof e[0]=="string"?e[0]:void 0,r=e.length===2?e[1]:typeof e[0]=="string"?void 0:e[0];return cr({[nn]:()=>({match:o(n=>{let i={[t??lu]:n};return{matched:r===void 0||Gr(r,n,(s,a)=>{i[s]=a}),selections:i}},"match"),getSelectionKeys:o(()=>[t??lu].concat(r===void 0?[]:Ln(r)),"getSelectionKeys")})})}o(hP,"y");function Ur(e){return typeof e=="number"}o(Ur,"v");function kn(e){return typeof e=="string"}o(kn,"b");function Mn(e){return typeof e=="bigint"}o(Mn,"w");var B9=cr(Oe(function(e){return!0}));var qn=o(e=>Object.assign(cr(e),{startsWith:o(t=>{return qn(Fe(e,(r=t,Oe(n=>kn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:o(t=>{return qn(Fe(e,(r=t,Oe(n=>kn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:o(t=>qn(Fe(e,(r=>Oe(n=>kn(n)&&n.length>=r))(t))),"minLength"),length:o(t=>qn(Fe(e,(r=>Oe(n=>kn(n)&&n.length===r))(t))),"length"),maxLength:o(t=>qn(Fe(e,(r=>Oe(n=>kn(n)&&n.length<=r))(t))),"maxLength"),includes:o(t=>{return qn(Fe(e,(r=t,Oe(n=>kn(n)&&n.includes(r)))));var r},"includes"),regex:o(t=>{return qn(Fe(e,(r=t,Oe(n=>kn(n)&&!!n.match(r)))));var r},"regex")}),"j"),V9=qn(Oe(kn)),zr=o(e=>Object.assign(cr(e),{between:o((t,r)=>zr(Fe(e,((n,i)=>Oe(s=>Ur(s)&&n<=s&&i>=s))(t,r))),"between"),lt:o(t=>zr(Fe(e,(r=>Oe(n=>Ur(n)&&n<r))(t))),"lt"),gt:o(t=>zr(Fe(e,(r=>Oe(n=>Ur(n)&&n>r))(t))),"gt"),lte:o(t=>zr(Fe(e,(r=>Oe(n=>Ur(n)&&n<=r))(t))),"lte"),gte:o(t=>zr(Fe(e,(r=>Oe(n=>Ur(n)&&n>=r))(t))),"gte"),int:o(()=>zr(Fe(e,Oe(t=>Ur(t)&&Number.isInteger(t)))),"int"),finite:o(()=>zr(Fe(e,Oe(t=>Ur(t)&&Number.isFinite(t)))),"finite"),positive:o(()=>zr(Fe(e,Oe(t=>Ur(t)&&t>0))),"positive"),negative:o(()=>zr(Fe(e,Oe(t=>Ur(t)&&t<0))),"negative")}),"x"),H9=zr(Oe(Ur)),Dn=o(e=>Object.assign(cr(e),{between:o((t,r)=>Dn(Fe(e,((n,i)=>Oe(s=>Mn(s)&&n<=s&&i>=s))(t,r))),"between"),lt:o(t=>Dn(Fe(e,(r=>Oe(n=>Mn(n)&&n<r))(t))),"lt"),gt:o(t=>Dn(Fe(e,(r=>Oe(n=>Mn(n)&&n>r))(t))),"gt"),lte:o(t=>Dn(Fe(e,(r=>Oe(n=>Mn(n)&&n<=r))(t))),"lte"),gte:o(t=>Dn(Fe(e,(r=>Oe(n=>Mn(n)&&n>=r))(t))),"gte"),positive:o(()=>Dn(Fe(e,Oe(t=>Mn(t)&&t>0))),"positive"),negative:o(()=>Dn(Fe(e,Oe(t=>Mn(t)&&t<0))),"negative")}),"A"),U9=Dn(Oe(Mn)),z9=cr(Oe(function(e){return typeof e=="boolean"})),G9=cr(Oe(function(e){return typeof e=="symbol"})),Z9=cr(Oe(function(e){return e==null})),W9=cr(Oe(function(e){return e!=null}));var Uh=class Uh extends Error{constructor(t){let r;try{r=JSON.stringify(t)}catch{r=t}super(`Pattern matching error: no pattern matches value ${r}`),this.input=void 0,this.input=t}};o(Uh,"W");var Bh=Uh,Vh={matched:!1,value:void 0};function Ot(e){return new Hh(e,Vh)}o(Ot,"z");var na=class na{constructor(t,r){this.input=void 0,this.state=void 0,this.input=t,this.state=r}with(...t){if(this.state.matched)return this;let r=t[t.length-1],n=[t[0]],i;t.length===3&&typeof t[1]=="function"?i=t[1]:t.length>2&&n.push(...t.slice(1,t.length-1));let s=!1,a={},c=o((l,p)=>{s=!0,a[l]=p},"a"),u=!n.some(l=>Gr(l,this.input,c))||i&&!i(this.input)?Vh:{matched:!0,value:r(s?lu in a?a[lu]:a:this.input,this.input)};return new na(this.input,u)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new na(this.input,n?{matched:!0,value:r(this.input,this.input)}:Vh)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new Bh(this.input)}run(){return this.exhaustive()}returnType(){return this}};o(na,"I");var Hh=na;var mP=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with"];var zh=2,gP=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],yP=["query","header","path"],Fn=["get","put","post","delete","options","head","patch","trace"],bP=["string","number","integer","boolean"],Gh=["allOf","anyOf","oneOf"];function Bn(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}o(Bn,"pick");var et=o(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),ki=o(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),fu=o(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),ht=o(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),vP=o(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),Zh=o((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),_P=o((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix"),RM=o(e=>{var n;let t=e.reduce((i,s)=>({...i,[s]:(i[s]??0)+1}),{});return(n=Object.entries(t).sort((i,s)=>i[1]===s[1]?s[0].length-i[0].length:s[1]-i[1])[0])==null?void 0:n[0]},"getLongestMostCommon"),Wh=o(e=>{let t=e.map(et).map(NM).map(r=>kM(r)).flat();return RM(t)},"getMostCommonAdjacentCombinationSplit"),NM=o(e=>e.split(/(?<![A-Z])(?=[A-Z])/).filter(Boolean),"splitByUppercase"),kM=o((e,t=["dto","by","for","of","in","to","and","with"])=>{var n;let r=[];for(let i=0;i<e.length;i++)if(!t.includes(e[i].toLowerCase()))for(let s=i+1;s<=e.length;s++)t.includes((n=e[s-1])==null?void 0:n.toLowerCase())||r.push(e.slice(i,s).join(""));return r},"getAdjacentStringCombinations");function Vn(e){return vP(e)}o(Vn,"formatTag");function Mi(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return Vn(r??t.defaultTag)}o(Mi,"getOperationTag");function SP(e,t){let r={};for(let n in e.paths){let i=e.paths[n],s=Bn(i,Fn);for(let a in s){let c=s[a];if(!c||c.deprecated&&!(t!=null&&t.withDeprecatedEndpoints))continue;let u=t.splitByTags?Mi(c,t):t.defaultTag;r[u]||(r[u]=[]),r[u].push(c)}}return r}o(SP,"getOperationsByTag");var PP=o(e=>`#/components/schemas/${e}`,"getSchemaRef"),qi=o(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),Uo=o(e=>qi(e).split("/").at(-1),"getSchemaNameByRef");function Ie(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}o(Ie,"isReferenceObject");function Qh(e){let t=MM(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/--+/g,"-").replace(/-+/g,"_").replace(/[^\w-]+/g,"_");return ht(t)}o(Qh,"normalizeString");function wP(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}o(wP,"wrapWithQuotesIfNeeded");function $P(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}o($P,"unwrapQuotesIfNeeded");function MM(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}o(MM,"prefixStringStartingWithNumberIfNeeded");function Jh(e){let t=e.replaceAll("_","#");return ht(t.replaceAll("-","_")).replaceAll("#","_")}o(Jh,"pathParamToVariableName");var Di=o(e=>bP.includes(e),"isPrimitiveType");function EP(e){return e.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/([\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\uFFFE\uFFFF])/g,(t,r)=>{let n=r.codePointAt(),i=n.toString(16);return n<=255?`\\x${`00${i}`.slice(-2)}`:`\\u${`0000${i}`.slice(-4)}`}).replace(/\//g,"\\/")}o(EP,"escapeControlCharacters");function Hn(e){return e.includes("application/")&&e.includes("json")||gP.includes(e)||e.includes("text/")}o(Hn,"isParamMediaTypeAllowed");function pu(e){return e>=200&&e<300}o(pu,"isMainResponseStatus");function du(e){return!(e>=200&&e<300)}o(du,"isErrorStatus");function hu(e){return e==="application/json"}o(hu,"isMediaTypeAllowed");function Kh({path:e,method:t,operation:r,options:n,keepOperationPrefixWithoutEnding:i}){let s=`${t}${DM(e)}`,a=r.operationId?Nn(r.operationId):s;if(n.removeOperationPrefixEndingWith&&i)return a.split(n.removeOperationPrefixEndingWith).map((u,l)=>l===0?u:et(u)).join("");if(n.removeOperationPrefixEndingWith&&!i){let c=new RegExp(`^.*${n.removeOperationPrefixEndingWith}`);a=a.replace(c,"")}return mP.includes(a)?s:a}o(Kh,"getOperationName");function oa({path:e,method:t,operation:r,operationsByTag:n,options:i}){let s=i.splitByTags?Mi(r,i):i.defaultTag,a=Kh({path:e,method:t,operation:r,options:i});return n[s].filter(u=>Kh({path:e,method:t,operation:u,options:i})===a).length===1?a:Kh({path:e,method:t,operation:r,options:i,keepOperationPrefixWithoutEnding:!0})}o(oa,"getUniqueOperationName");function xP(e,t,r){let n=[];for(let i in e.paths){let s=e.paths[i],a=Bn(s,Fn);for(let c in a){let u=a[c];if(!u||u.deprecated&&!(r!=null&&r.withDeprecatedEndpoints))continue;let l=oa({path:i,method:c,operation:u,operationsByTag:t,options:r});n.push(l)}}return n}o(xP,"getUniqueOperationNamesWithoutSplitByTags");var OP=/({\w+})/g,qM=/[^\w\-]+/g;function DM(e){e=et(fu(e.replaceAll("/","-")).replaceAll("-",""));let t=[...e.matchAll(OP)];if(t.length>0){let r=t.sort((n,i)=>n.index-i.index)[t.length-1][0];e=`${e.replace(OP,"")}By${et(r.slice(1,-1))}`}return e.replace(qM,"_")}o(DM,"pathToVariableName");var Yh=/{(\b\w+(?:-\w+)*\b)}/g;function AP(e){let t=e.match(Yh);return t===null?e.replaceAll(Yh,":$1"):(t.forEach(r=>{let n=Jh(r.replaceAll(Yh,":$1"));e=e.replaceAll(r,n)}),e)}o(AP,"replaceHyphenatedPath");function Zr(e){return!Ie(e)}o(Zr,"isSchemaObject");function IP(e){return e.type==="array"}o(IP,"isArraySchemaObject");function CP(e){if(!e.allOf)throw new Error("Function inferRequiredSchema is specialized to handle item with required only in an allOf array.");let[t,r]=e.allOf.reduce((i,s)=>{if(LM(s)){let a=s.required;i[0].push(...a??[])}else i[1].push(s);return i},[[],[]]),n={properties:t.reduce((i,s)=>(i[s]={},i),{}),type:"object",required:t};return{noRequiredOnlyAllof:r,composedRequiredSchema:n,patchRequiredSchemaInLoop:o((i,s)=>{if(Ie(i)){let a=s(i.$ref);a&&n.required.forEach(c=>{var u;n.properties[c]=((u=a==null?void 0:a.properties)==null?void 0:u[c])??{}})}else{let a=i.properties??{};n.required.forEach(c=>{a[c]&&(n.properties[c]=a[c]??{})})}},"patchRequiredSchemaInLoop")}}o(CP,"inferRequiredSchema");var LM=o(e=>!Ie(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function Un({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${ki(t)}/`:""}${ki(t)}.${i}`:i}o(Un,"getTagFileName");var Qe=o(({type:e,tag:t,options:r})=>`${et(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var on=o((e,t)=>Zh(et(Qh(e)),t),"getZodSchemaName"),TP=o((e,t,r)=>Zh(et(Qh(e)),`${t}${r}`),"getEnumZodSchemaName"),Dt=o(e=>!e.startsWith("z."),"isNamedZodSchema"),Li=o((e,t,r)=>t?e:`${r}_${e}`,"getZodSchemaOperationName"),mu=o(e=>ht(`${e}_${aP}`),"getBodyZodSchemaName"),jP=o((e,t)=>ht(`${e}_${t}${cP}`),"getParamZodSchemaName"),FM=o(e=>ht(`${e}${uP}`),"getMainResponseZodSchemaName"),BM=o((e,t)=>ht(`${e}_${t}_${lP}`),"getErrorResponseZodSchemaName");function gu({statusCode:e,operationName:t,isUniqueOperationName:r,tag:n}){let i=Number(e),s=Li(t,r,n);return!pu(i)&&e!=="default"&&du(i)?BM(s,e):FM(s)}o(gu,"getResponseZodSchemaName");var sa=o((e,t)=>_P(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),RP=o((e,t)=>Dt(t)?`${e.options.includeNamespaces?`${Qe({type:"models",tag:e.getTagByZodSchemaName(t),options:e.options})}.`:""}${t}`:t,"getImportedZodSchemaName"),Xh=o((e,t)=>Dt(t)?`${e.options.includeNamespaces?`${Qe({type:"models",tag:e.getTagByZodSchemaName(t),options:e.options})}.`:""}${sa(t,e.options)}`:t,"getImportedZodSchemaInferedTypeName");function NP(e){return Ot(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}o(NP,"primitiveTypeToTsType");var aa=o(e=>ki(ht(e.operationName)),"getEndpointName");function kP(e,t){return`${t.includeNamespaces?`${Qe({type:"endpoints",tag:ca(e,t),options:t})}.`:""}${aa(e)}`}o(kP,"getImportedEndpointName");var MP=o(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function ca(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return Vn(r??t.defaultTag)}o(ca,"getEndpointTag");function em(e,t){return t.parameters.map(r=>{var i,s,a,c;let n="string";if(Dt(r.zodSchema))n=Xh(e,r.zodSchema);else if((i=r.parameterObject)!=null&&i.schema&&Zr(r.parameterObject.schema)){let u=(a=(s=r.parameterObject)==null?void 0:s.schema)==null?void 0:a.type;u&&Di(u)&&(n=NP(u))}return{name:Nn(r.name),type:n,paramType:r.type,required:((c=r.parameterObject)==null?void 0:c.required)??!0}}).sort((r,n)=>{if(r.required===n.required){let i=["Path","Body","Query","Header"];return i.indexOf(r.paramType)-i.indexOf(n.paramType)}return r.required?-1:1})}o(em,"mapEndpointParamsToFunctionParams");function qP(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let s=dP(i.name)?i.name:`"${i.name}"`,a=Nn(i.name);return{...i,name:s,value:a}}),r={};return e.requestFormat!==Lh["Content-Type"]&&(r["Content-Type"]=`'${e.requestFormat}'`),e.responseFormat&&e.responseFormat!==Lh.Accept&&(r.Accept=`'${e.responseFormat}'`),e.parameters.filter(i=>i.type==="Header").forEach(i=>{r[i.name]=Nn(i.name)}),{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}o(qP,"getEndpointConfig");function yu(e){return{type:"invalid-schema",message:e}}o(yu,"getInvalidSchemaError");function DP(e){return{type:"invalid-operation-id",message:`Operation ${e}`}}o(DP,"getInvalidOperationIdError");function LP(e,t){return{type:"missing-path-parameter",message:`Path ${t} is missing [${e.map(({name:r})=>r).join(", ")}]`}}o(LP,"getMissingPathParameterError");function FP(e){return{type:"not-allowed-inline-enum",message:e}}o(FP,"getNotAllowedInlineEnumError");function BP(e){return{type:"not-allowed-circular-schema",message:e}}o(BP,"getNotAllowedCircularSchemaError");function VP(e,t){return{type:"missing-acl-condition-property",message:`Condition property ${e} is not found in parameters or body in operation ${t}`}}o(VP,"getMissingAclConditionPropertyError");function HP(e){return e.reduce((t,r)=>({...t,[r.type]:[...t[r.type]??[],r.message]}),{})}o(HP,"groupByType");function Wr({schema:e,meta:t,options:r}){let n=[];Ot(e.type).with("string",()=>n.push(UM(e))).with("number","integer",()=>n.push(GM(e))).with("array",()=>n.push(ZM(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
141
141
  `,"\r",`\r
142
142
  `].some(s=>String.prototype.includes.call(e.description,s))?n.push(`describe(\`${e.description}\`)`):n.push(`describe("${e.description}")`));let i=n.concat(VM(e,t),(r==null?void 0:r.withDefaultValues)!==!1?HM(e):[]).filter(Boolean).join(".");return i?`.${i}`:""}o(Wr,"getZodChain");function VM(e,t){return e.nullable&&!(t!=null&&t.isRequired)?"nullish()":e.nullable?"nullable()":t!=null&&t.isRequired?"":"optional()"}o(VM,"getZodChainablePresence");function HM(e){return e.default!==void 0?`default(${Ot(e.type).with("number","integer",()=>$P(e.default)).otherwise(()=>JSON.stringify(e.default))})`:""}o(HM,"getZodChainableDefault");function UM(e){let t=[];if(e.enum||(e.minLength!==void 0&&t.push(`min(${e.minLength})`),e.maxLength!==void 0&&t.push(`max(${e.maxLength})`)),e.pattern&&t.push(`regex(${zM(e.pattern)})`),e.format){let r=Ot(e.format).with("email",()=>"email()").with("hostname","uri",()=>"url()").with("uuid",()=>"uuid()").with("date-time",()=>"datetime({ offset: true })").otherwise(()=>"");r&&t.push(r)}return t.join(".")}o(UM,"getZodChainableStringValidations");function zM(e){return e.startsWith("/")&&e.endsWith("/")&&(e=e.slice(1,-1)),e=EP(e),`/${e}/`}o(zM,"formatPatternIfNeeded");function GM(e){let t=[];return e.enum?"":(e.type==="integer"&&t.push("int()"),e.minimum!==void 0?e.exclusiveMinimum===!0?t.push(`gt(${e.minimum})`):t.push(`gte(${e.minimum})`):typeof e.exclusiveMinimum=="number"&&t.push(`gt(${e.exclusiveMinimum})`),e.maximum!==void 0?e.exclusiveMaximum===!0?t.push(`lt(${e.maximum})`):t.push(`lte(${e.maximum})`):typeof e.exclusiveMaximum=="number"&&t.push(`lt(${e.exclusiveMaximum})`),e.multipleOf&&t.push(`multipleOf(${e.multipleOf})`),t.join("."))}o(GM,"getZodChainableNumberValidations");function ZM(e){let t=[];return e.minItems&&t.push(`min(${e.minItems})`),e.maxItems&&t.push(`max(${e.maxItems})`),t.join(".")}o(ZM,"getZodChainableArrayValidations");var Fi=o(e=>e.reduce((t,r)=>t+r,0),"sum");function ot(e,t){if(!t)return e;if(Ie(t))return e+2;if(Array.isArray(t.type))return t.type.length===1?At("oneOf")+ot(e,{...t,type:t.type[0]}):e+At("oneOf")+Fi(t.type.map(r=>ot(0,{...t,type:r})));if(t.oneOf)return t.oneOf.length===1?At("oneOf")+ot(e,t.oneOf[0]):e+At("oneOf")+Fi(t.oneOf.map(r=>ot(0,r)));if(t.anyOf)return t.anyOf.length===1?At("anyOf")+ot(e,t.anyOf[0]):e+At("anyOf")+Fi(t.anyOf.map(r=>ot(0,r)));if(t.allOf)return t.allOf.length===1?At("allOf")+ot(e,t.allOf[0]):e+At("allOf")+Fi(t.allOf.map(r=>ot(0,r)));if(!t.type)return e;if(Di(t.type))return t.enum?e+UP(t)+At("enum")+Fi(t.enum.map(r=>ot(0,r))):e+UP(t);if(t.type==="array")return t.items?At("array")+ot(e,t.items):At("array")+ot(e);if(t.type==="object"||t.properties||t.additionalProperties){if(t.additionalProperties)return t.additionalProperties===!0?At("record")+ot(e):At("record")+ot(e,t.additionalProperties);if(t.properties){let r=Object.values(t.properties);return e+At("object")+Fi(r.map(n=>ot(0,n)))}return At("empty-object")+ot(e)}return e}o(ot,"getOpenAPISchemaComplexity");function UP(e){return Ot(e.type).with("string","number","integer","boolean",()=>1).otherwise(()=>0)}o(UP,"complexityByType");function At(e){return Ot(e).with("oneOf",()=>2).with("anyOf",()=>3).with("allOf",()=>2).with("enum","array","record","empty-object",()=>1).with("object",()=>2).otherwise(()=>0)}o(At,"complexityByComposite");var tm=class tm{constructor(t,r,n={referencedBy:[]},i){this.schema=t;this.resolver=r;Ie(t)&&(this.ref=t.$ref),i&&(this.enumRef=i),this.meta={...n,referencedBy:[...(n==null?void 0:n.referencedBy)??[]]},this.ref&&this.meta.referencedBy.push(this)}code;ref;enumRef;children=[];meta;getCodeString(t,r){var s,a;if(!this.ref&&this.code)return this.code;if(!this.ref)throw new Error("Zod schema is missing both ref and code");let n=(s=this.resolver)==null?void 0:s.getZodSchemaNameByRef(this.ref);if(!n)return this.ref;let i=(a=this.resolver)==null?void 0:a.getTagByZodSchemaName(n);return r!=null&&r.includeNamespaces&&i&&i!==t?`${Qe({type:"models",tag:i,options:r})}.${n}`:n}get complexity(){return ot(0,this.schema)}assign(t){return this.code=t,this}inherit(t){return t&&t.children.push(this),this}};o(tm,"ZodSchema");var ua=tm;function ze({schema:e,resolver:t,meta:r,tag:n}){var y;let i=new ua(e,t,r),s={parent:i.inherit(r==null?void 0:r.parent),referencedBy:[...i.meta.referencedBy]},a={resolver:t,meta:s,tag:n};if(Ie(e))return WM({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});let c=YM({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(c)return c;let u=KM({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(u)return u;let l=QM({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(l)return l;let p=JM({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(p)return p;let f=XM({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(f)return f;let d=t.options.allReadonly?".readonly()":"";if(IP(e))return e.items?i.assign(`z.array(${ze({...a,schema:e.items}).getCodeString(n,t.options)}${Wr({schema:e.items,meta:{...s,isRequired:!0},options:t.options})})${d}`):i.assign(`z.array(z.any())${d}`);let h=e.type?e.type.toLowerCase():void 0;if(h==="object"||e.properties||e.additionalProperties){let b=t.options.additionalPropertiesDefaultValue!==void 0?t.options.additionalPropertiesDefaultValue:!0,$=(e.additionalProperties===null||e.additionalProperties===void 0?b:e.additionalProperties)===!1?"":".passthrough()";if(typeof e.additionalProperties=="object"&&Object.keys(e.additionalProperties).length>0)return i.assign(`z.record(${ze({...a,schema:e.additionalProperties}).getCodeString(n,t.options)+Wr({schema:e.additionalProperties,meta:{...s,isRequired:!0},options:t.options})})`);let x=e.required&&e.required.length>0,C=t.options.withImplicitRequiredProps?!1:!((y=e.required)!=null&&y.length),T="{}";e.properties&&(T="{ "+Object.entries(e.properties).map(([Pe,we])=>{var M;let ne={...s,isRequired:C?!0:x?(M=e.required)==null?void 0:M.includes(Pe):t.options.withImplicitRequiredProps,name:Pe},k=we;if(Ie(we)&&t&&(k=t.getSchemaByRef(we.$ref),!k))throw new Error(`Schema ${we.$ref} not found`);let j=ze({...a,schema:we,meta:ne}).getCodeString(n,t.options)+Wr({schema:k,meta:ne,options:t.options});return[Pe,j]}).map(([Pe,we])=>`${wP(Pe)}: ${we}`).join(", ")+" }");let I=C?".partial()":"",se=t.options.strictObjects?".strict()":"";return i.assign(`z.object(${T})${I}${se}${$}${d}`)}if(!h)return i.assign("z.unknown()");throw new Error(`Unsupported schema type: ${h}`)}o(ze,"getZodSchema");function WM({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){if(!Ie(e))return;let s=t.meta.referencedBy.slice(0,-1).map(u=>u.ref?r.getZodSchemaNameByRef(u.ref)??u.ref:void 0).filter(Boolean),a=r.getZodSchemaNameByRef(e.$ref);if(s.length>1&&s.includes(a))return t.assign(r.getCodeByZodSchemaName(t.ref));let c=r.getCodeByZodSchemaName(e.$ref);if(!c){let u=r.getSchemaByRef(e.$ref);if(!u)throw new Error(`Schema ${e.$ref} not found`);c=ze({schema:u,resolver:r,meta:n,tag:i}).getCodeString(i,r.options)}return r.getCodeByZodSchemaName(a)||r.setZodSchema(a,c,i),t}o(WM,"getReferenceZodSchema");function KM({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){var a;if(!Zr(e)||!e.oneOf)return;if(e.oneOf.length===1){let c=ze({schema:e.oneOf[0],resolver:r,meta:n,tag:i});return t.assign(c.getCodeString(i,r.options))}let s=(a=e.oneOf)==null?void 0:a.some(c=>Zr(c)&&((c==null?void 0:c.allOf)||[]).length>1);if(e.discriminator&&!s){let c=e.discriminator.propertyName;return t.assign(`
143
143
  z.discriminatedUnion("${c}", [${e.oneOf.map(u=>ze({schema:u,resolver:r,meta:n,tag:i}).getCodeString(i,r.options)).join(", ")}])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/openapi-codegen-cli",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "main": "./dist/index.js",
5
5
  "bin": {
6
6
  "openapi-codegen": "./dist/sh.js"
@@ -4,6 +4,7 @@
4
4
  {{#each imports as | import |}}
5
5
  {{{genImport import}}}
6
6
  {{/each}}
7
+
7
8
  {{! AppAbilities union type }}
8
9
  export type AppAbilities =
9
10
  {{#if includeNamespace}}{{#each namespaces as | namespace |}} | {{namespace}}.{{../allAbilities}}{{/each}}