@povio/openapi-codegen-cli 0.2.8 → 0.2.9
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.
|
@@ -29,9 +29,9 @@ export interface TsArrayMetaType {
|
|
|
29
29
|
}
|
|
30
30
|
export interface TsCompositeMetaType {
|
|
31
31
|
metaType: "composite";
|
|
32
|
-
allOf?: TsNestedType;
|
|
33
|
-
oneOf?: TsNestedType;
|
|
34
|
-
anyOf?: TsNestedType;
|
|
32
|
+
allOf?: TsNestedType[];
|
|
33
|
+
oneOf?: TsNestedType[];
|
|
34
|
+
anyOf?: TsNestedType[];
|
|
35
35
|
}
|
|
36
36
|
export type TsMetaType = TsPrimitiveMetaType | TsObjectMetaType | TsArrayMetaType | TsCompositeMetaType;
|
|
37
37
|
export type ModelMetadata = TsNestedType;
|
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 o+=e.slice(i),o}s(Gg,"stringEncaseCRLFWithFirstIndex");var{stdout:Wg,stderr:Kg}=Ug,gl=Symbol("GENERATOR"),Ni=Symbol("STYLER"),Zs=Symbol("IS_EMPTY"),Zg=["ansi","ansi","ansi256","ansi16m"],Mi=Object.create(null),Nw=s((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=Wg?Wg.level:0;e.level=t.level===void 0?r:t.level},"applyOptions"),bl=class bl{constructor(t){return Yg(t)}};s(bl,"Chalk");var Na=bl,Yg=s(e=>{let t=s((...r)=>r.join(" "),"chalk");return Nw(t,e),Object.setPrototypeOf(t,Ys.prototype),t},"chalkFactory");function Ys(e){return Yg(e)}s(Ys,"createChalk");Object.setPrototypeOf(Ys.prototype,Function.prototype);for(let[e,t]of Object.entries(cr))Mi[e]={get(){let r=Ma(this,vl(t.open,t.close,this[Ni]),this[Zs]);return Object.defineProperty(this,e,{value:r}),r}};Mi.visible={get(){let e=Ma(this,this[Ni],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var yl=s((e,t,r,...n)=>e==="rgb"?t==="ansi16m"?cr[r].ansi16m(...n):t==="ansi256"?cr[r].ansi256(cr.rgbToAnsi256(...n)):cr[r].ansi(cr.rgbToAnsi(...n)):e==="hex"?yl("rgb",t,r,...cr.hexToRgb(...n)):cr[r][e](...n),"getModelAnsi"),Mw=["rgb","hex","ansi256"];for(let e of Mw){Mi[e]={get(){let{level:r}=this;return function(...n){let i=vl(yl(e,Zg[r],"color",...n),cr.color.close,this[Ni]);return Ma(this,i,this[Zs])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);Mi[t]={get(){let{level:r}=this;return function(...n){let i=vl(yl(e,Zg[r],"bgColor",...n),cr.bgColor.close,this[Ni]);return Ma(this,i,this[Zs])}}}}var qw=Object.defineProperties(()=>{},{...Mi,level:{enumerable:!0,get(){return this[gl].level},set(e){this[gl].level=e}}}),vl=s((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"),Ma=s((e,t,r)=>{let n=s((...i)=>Dw(n,i.length===1?""+i[0]:i.join(" ")),"builder");return Object.setPrototypeOf(n,qw),n[gl]=e,n[Ni]=t,n[Zs]=r,n},"createBuilder"),Dw=s((e,t)=>{if(e.level<=0||!t)return e[Zs]?"":t;let r=e[Ni];if(r===void 0)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=zg(t,r.close,r.open),r=r.parent;let o=t.indexOf(`
|
|
140
|
-
`);return o!==-1&&(t=Gg(t,i,n,o)),n+t+i},"applyStyle");Object.defineProperties(Ys.prototype,Mi);var HL=Ys(),UL=Ys({level:Kg?Kg.level:0});var Kn=new Na;function _l(e,t,r){console.log(r!==void 0&&r!==t?`${Kn.yellow(`${e}:`.padEnd(20))}${Kn.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}s(_l,"logVariable");function qi(e){console.log(`[INFO] ${e}`)}s(qi,"logInfo");function Sl(e){console.log(Kn.green(`[SUCCESS] ${e}`))}s(Sl,"logSuccess");function Js(e,t){e instanceof Error?(console.log(Kn.red(`[ERROR] ${t||e.message}`)),process.env.VERBOSE&&console.error(e)):console.log(Kn.red(`[ERROR] ${e}`))}s(Js,"logError");function Jg(e){console.log(Kn.bgYellow(`==== ${e} ====`))}s(Jg,"logBanner");var Qg=Et(require("fs"));function qa(){return"0.2.8"}s(qa,"getVersion");var n5=Et(ey());var Pl=Symbol("options_key");function xr(e){return(t,r)=>{var n,i;if(e!=null){let o={...Reflect.getMetadata(Pl,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(Pl,o,t)}}}s(xr,"YargOption");function ty(e){let t=Reflect.getMetadata(Pl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}s(ty,"getYargsOption");function ry(e){return async t=>t.options(Lw(e)).middleware(async r=>await Fw(e,r),!0)}s(ry,"getBuilder");function Lw(e){return Object.entries(ty(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}s(Lw,"getYargsOptions");async function Fw(e,t){let r=new e;for(let[n,i]of Object.entries(ty(e)))r[n]=t[n]??i.default;return r}s(Fw,"loadYargsConfig");var qO=Et(j1()),DO=require("child_process");var R1="Schema",T1="Body",k1="Param",N1="Response",M1="ErrorResponse",dh="z.void()",Hc={bindings:["z"],from:"zod"};var q1={output:"output",splitByTags:!0,defaultTag:"Common",excludeTags:[],includeNamespaces:!0,configs:{models:{outputFileNameSuffix:"models",namespaceSuffix:"Models"},endpoints:{outputFileNameSuffix:"api",namespaceSuffix:"Api"},queries:{outputFileNameSuffix:"queries",namespaceSuffix:"Queries"}},schemaSuffix:R1,additionalPropertiesDefaultValue:!1,removeOperationPrefixEndingWith:"Controller_"};var hh={"Content-Type":"application/json",Accept:"application/json"},D1="data";var L1=s(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),mh=s(e=>e.replace(/^[^a-zA-Z_$]*/g,"").replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var Jr=Symbol.for("@ts-pattern/matcher"),N3=Symbol.for("@ts-pattern/isVariadic"),zc="@ts-pattern/anonymous-select-key",gh=s(e=>!!(e&&typeof e=="object"),"r"),Uc=s(e=>e&&!!e[Jr],"i"),Lr=s((e,t,r)=>{if(Uc(e)){let n=e[Jr](),{matched:i,selections:o}=n.match(t);return i&&o&&Object.keys(o).forEach(a=>r(a,o[a])),i}if(gh(e)){if(!gh(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],o=[];for(let a of e.keys()){let c=e[a];Uc(c)&&c[N3]?o.push(c):o.length?i.push(c):n.push(c)}if(o.length){if(o.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)=>Lr(l,a[p],r))&&i.every((l,p)=>Lr(l,c[p],r))&&(o.length===0||Lr(o[0],u,r))}return e.length===t.length&&e.every((a,c)=>Lr(a,t[c],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||Uc(o=i)&&o[Jr]().matcherType==="optional")&&Lr(i,t[n],r);var o})}return Object.is(t,e)},"s"),In=s(e=>{var t,r,n;return gh(e)?Uc(e)?(t=(r=(n=e[Jr]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?Uo(e,In):Uo(Object.values(e),In):[]},"o"),Uo=s((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function er(e){return Object.assign(e,{optional:s(()=>M3(e),"optional"),and:s(t=>De(e,t),"and"),or:s(t=>q3(e,t),"or"),select:s(t=>t===void 0?F1(e):F1(t,e),"select")})}s(er,"u");function M3(e){return er({[Jr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return t===void 0?(In(e).forEach(i=>n(i,void 0)),{matched:!0,selections:r}):{matched:Lr(e,t,n),selections:r}},"match"),getSelectionKeys:s(()=>In(e),"getSelectionKeys"),matcherType:"optional"})})}s(M3,"h");function De(...e){return er({[Jr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return{matched:e.every(i=>Lr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Uo(e,In),"getSelectionKeys"),matcherType:"and"})})}s(De,"m");function q3(...e){return er({[Jr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return Uo(e,In).forEach(i=>n(i,void 0)),{matched:e.some(i=>Lr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Uo(e,In),"getSelectionKeys"),matcherType:"or"})})}s(q3,"d");function Pe(e){return{[Jr]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(Pe,"p");function F1(...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 er({[Jr]:()=>({match:s(n=>{let i={[t??zc]:n};return{matched:r===void 0||Lr(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??zc].concat(r===void 0?[]:In(r)),"getSelectionKeys")})})}s(F1,"y");function qr(e){return typeof e=="number"}s(qr,"v");function xn(e){return typeof e=="string"}s(xn,"b");function En(e){return typeof e=="bigint"}s(En,"w");var PV=er(Pe(function(e){return!0}));var An=s(e=>Object.assign(er(e),{startsWith:s(t=>{return An(De(e,(r=t,Pe(n=>xn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return An(De(e,(r=t,Pe(n=>xn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>An(De(e,(r=>Pe(n=>xn(n)&&n.length>=r))(t))),"minLength"),length:s(t=>An(De(e,(r=>Pe(n=>xn(n)&&n.length===r))(t))),"length"),maxLength:s(t=>An(De(e,(r=>Pe(n=>xn(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return An(De(e,(r=t,Pe(n=>xn(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return An(De(e,(r=t,Pe(n=>xn(n)&&!!n.match(r)))));var r},"regex")}),"j"),OV=An(Pe(xn)),Dr=s(e=>Object.assign(er(e),{between:s((t,r)=>Dr(De(e,((n,i)=>Pe(o=>qr(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Dr(De(e,(r=>Pe(n=>qr(n)&&n<r))(t))),"lt"),gt:s(t=>Dr(De(e,(r=>Pe(n=>qr(n)&&n>r))(t))),"gt"),lte:s(t=>Dr(De(e,(r=>Pe(n=>qr(n)&&n<=r))(t))),"lte"),gte:s(t=>Dr(De(e,(r=>Pe(n=>qr(n)&&n>=r))(t))),"gte"),int:s(()=>Dr(De(e,Pe(t=>qr(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Dr(De(e,Pe(t=>qr(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Dr(De(e,Pe(t=>qr(t)&&t>0))),"positive"),negative:s(()=>Dr(De(e,Pe(t=>qr(t)&&t<0))),"negative")}),"x"),wV=Dr(Pe(qr)),Cn=s(e=>Object.assign(er(e),{between:s((t,r)=>Cn(De(e,((n,i)=>Pe(o=>En(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Cn(De(e,(r=>Pe(n=>En(n)&&n<r))(t))),"lt"),gt:s(t=>Cn(De(e,(r=>Pe(n=>En(n)&&n>r))(t))),"gt"),lte:s(t=>Cn(De(e,(r=>Pe(n=>En(n)&&n<=r))(t))),"lte"),gte:s(t=>Cn(De(e,(r=>Pe(n=>En(n)&&n>=r))(t))),"gte"),positive:s(()=>Cn(De(e,Pe(t=>En(t)&&t>0))),"positive"),negative:s(()=>Cn(De(e,Pe(t=>En(t)&&t<0))),"negative")}),"A"),$V=Cn(Pe(En)),xV=er(Pe(function(e){return typeof e=="boolean"})),EV=er(Pe(function(e){return typeof e=="symbol"})),AV=er(Pe(function(e){return e==null})),CV=er(Pe(function(e){return e!=null}));var _h=class _h 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}};s(_h,"W");var yh=_h,vh={matched:!1,value:void 0};function gt(e){return new bh(e,vh)}s(gt,"z");var Ho=class Ho{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 o=!1,a={},c=s((l,p)=>{o=!0,a[l]=p},"a"),u=!n.some(l=>Lr(l,this.input,c))||i&&!i(this.input)?vh:{matched:!0,value:r(o?zc in a?a[zc]:a:this.input,this.input)};return new Ho(this.input,u)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new Ho(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 yh(this.input)}run(){return this.exhaustive()}returnType(){return this}};s(Ho,"I");var bh=Ho;var Sh=2,V1=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],B1=["query","header","path"],Ps=["get","put","post","delete","options","head","patch","trace"],H1=["string","number","integer","boolean"];function Os(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(Os,"pick");var Fr=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),zo=s(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),U1=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),_r=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),z1=s(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),G1=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),W1=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var Z1=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Go=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),wh=s(e=>Go(e).split("/").at(-1),"getSchemaNameByRef");function He(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s(He,"isReferenceObject");function Y1(e){return D3(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/-+/g,"_").replace(/[^\w\-]+/g,"_").replace(/--+/g,"-")}s(Y1,"normalizeString");function J1(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(J1,"wrapWithQuotesIfNeeded");function Q1(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(Q1,"unwrapQuotesIfNeeded");function D3(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(D3,"prefixStringStartingWithNumberIfNeeded");function $h(e){let t=e.replaceAll("_","#");return _r(t.replaceAll("-","_")).replaceAll("#","_")}s($h,"pathParamToVariableName");var gi=s(e=>H1.includes(e),"isPrimitiveType");function X1(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,"\\/")}s(X1,"escapeControlCharacters");function ws(e){return e.includes("application/")&&e.includes("json")||V1.includes(e)||e.includes("text/")}s(ws,"isParamMediaTypeAllowed");function xh(e){return e>=200&&e<300}s(xh,"isMainResponseStatus");function Eh(e){return!(e>=200&&e<300)}s(Eh,"isErrorStatus");function Gc(e){return e==="application/json"}s(Gc,"isMediaTypeAllowed");function Ph({path:e,method:t,operation:r,options:n,keepOperationPrefixWithoutEnding:i}){let o=r.operationId??t+V3(e);if(n.removeOperationPrefixEndingWith&&i)return o.split(n.removeOperationPrefixEndingWith).map((c,u)=>u===0?c:Fr(c)).join("");if(n.removeOperationPrefixEndingWith&&!i){let a=new RegExp(`^.*${n.removeOperationPrefixEndingWith}`);o=o.replace(a,"")}return o}s(Ph,"getOperationName");function e2({path:e,method:t,operation:r,openApiDoc:n,options:i}){let o=L3(n,i),a=i.splitByTags?$s(r,i):i.defaultTag,c=Ph({path:e,method:t,operation:r,options:i});return o[a].filter(l=>Ph({path:e,method:t,operation:l,options:i})===c).length===1?c:Ph({path:e,method:t,operation:r,options:i,keepOperationPrefixWithoutEnding:!0})}s(e2,"getUniqueOperationName");function L3(e,t){let r={};for(let n in e.paths){let i=e.paths[n],o=Os(i,Ps);for(let a in o){let c=o[a];if(!c||c.deprecated&&!(t!=null&&t.withDeprecatedEndpoints))continue;let u=t.splitByTags?$s(c,t):t.defaultTag;r[u]||(r[u]=[]),r[u].push(c)}}return r}s(L3,"getOperationsByTag");function yi(e){return z1(e)}s(yi,"formatTag");function $s(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return yi(r??t.defaultTag)}s($s,"getOperationTag");var K1=/({\w+})/g,F3=/[^\w\-]+/g;function V3(e){e=Fr(U1(e.replaceAll("/","-")).replaceAll("-",""));let t=[...e.matchAll(K1)];if(t.length>0){let r=t.sort((n,i)=>n.index-i.index)[t.length-1][0];e=`${e.replace(K1,"")}By${Fr(r.slice(1,-1))}`}return e.replace(F3,"_")}s(V3,"pathToVariableName");var Oh=/{(\b\w+(?:-\w+)*\b)}/g;function t2(e){let t=e.match(Oh);return t===null?e.replaceAll(Oh,":$1"):(t.forEach(r=>{let n=$h(r.replaceAll(Oh,":$1"));e=e.replaceAll(r,n)}),e)}s(t2,"replaceHyphenatedPath");function Qr(e){return!He(e)}s(Qr,"isSchemaObject");function r2(e){return e.type==="array"}s(r2,"isArraySchemaObject");function n2(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,o)=>{if(B3(o)){let a=o.required;i[0].push(...a??[])}else i[1].push(o);return i},[[],[]]),n={properties:t.reduce((i,o)=>(i[o]={},i),{}),type:"object",required:t};return{noRequiredOnlyAllof:r,composedRequiredSchema:n,patchRequiredSchemaInLoop:s((i,o)=>{if(He(i)){let a=o(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")}}s(n2,"inferRequiredSchema");var B3=s(e=>!He(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function Wo({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${zo(t)}/`:""}${zo(t)}.${i}`:i}s(Wo,"getTagFileName");var Pt=s(({type:e,tag:t,options:r})=>`${Fr(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var jn=s((e,t)=>G1(Fr(Y1(e)),t),"getZodSchemaName"),Tt=s(e=>!e.startsWith("z."),"isNamedZodSchema"),i2=s(e=>_r(`${e}_${T1}`),"getBodyZodSchemaName"),s2=s((e,t)=>_r(`${e}_${t}${k1}`),"getParamZodSchemaName"),o2=s(e=>_r(`${e}${N1}`),"getMainResponseZodSchemaName"),a2=s((e,t)=>_r(`${e}_${t}_${M1}`),"getErrorResponseZodSchemaName");var Ko=s((e,t)=>W1(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),c2=s(({resolver:e,zodSchemaName:t,options:r})=>Tt(t)?`${r.includeNamespaces?`${Pt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${t}`:t,"getImportedZodSchemaName"),Ah=s(({resolver:e,zodSchemaName:t,options:r})=>Tt(t)?`${r.includeNamespaces?`${Pt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${Ko(t,r)}`:t,"getImportedZodSchemaInferedTypeName");function u2(e){return gt(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(u2,"primitiveTypeToTsType");var Zo=s(e=>zo(_r(e.operationName)),"getEndpointName");function l2(e,t){return`${t.includeNamespaces?`${Pt({type:"endpoints",tag:Yo(e,t),options:t})}.`:""}${Zo(e)}`}s(l2,"getImportedEndpointName");var f2=s(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function Yo(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return yi(r??t.defaultTag)}s(Yo,"getEndpointTag");function Ch({resolver:e,endpoint:t,options:r}){return t.parameters.map(n=>{var o,a,c,u;let i="string";if(Tt(n.zodSchema))i=Ah({resolver:e,zodSchemaName:n.zodSchema,options:r});else if((o=n.parameterObject)!=null&&o.schema&&Qr(n.parameterObject.schema)){let l=(c=(a=n.parameterObject)==null?void 0:a.schema)==null?void 0:c.type;l&&gi(l)&&(i=u2(l))}return{name:mh(n.name),type:i,paramType:n.type,required:((u=n.parameterObject)==null?void 0:u.required)??!0}}).sort((n,i)=>{if(n.required===i.required){let o=["Path","Body","Query","Header"];return o.indexOf(n.paramType)-o.indexOf(i.paramType)}return n.required?-1:1})}s(Ch,"mapEndpointParamsToFunctionParams");function p2(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let o=L1(i.name)?i.name:`"${i.name}"`,a=mh(i.name);return{...i,name:o,value:a}}),r={...e.requestFormat!==hh["Content-Type"]?{"Content-Type":e.requestFormat}:{},...e.responseFormat&&e.responseFormat!==hh.Accept?{Accept:e.responseFormat}:{}};return{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}s(p2,"getEndpointConfig");function Vr({schema:e,meta:t,options:r}){let n=[];gt(e.type).with("string",()=>n.push(z3(e))).with("number","integer",()=>n.push(W3(e))).with("array",()=>n.push(K3(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
|
|
140
|
+
`);return o!==-1&&(t=Gg(t,i,n,o)),n+t+i},"applyStyle");Object.defineProperties(Ys.prototype,Mi);var HL=Ys(),UL=Ys({level:Kg?Kg.level:0});var Kn=new Na;function _l(e,t,r){console.log(r!==void 0&&r!==t?`${Kn.yellow(`${e}:`.padEnd(20))}${Kn.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}s(_l,"logVariable");function qi(e){console.log(`[INFO] ${e}`)}s(qi,"logInfo");function Sl(e){console.log(Kn.green(`[SUCCESS] ${e}`))}s(Sl,"logSuccess");function Js(e,t){e instanceof Error?(console.log(Kn.red(`[ERROR] ${t||e.message}`)),process.env.VERBOSE&&console.error(e)):console.log(Kn.red(`[ERROR] ${e}`))}s(Js,"logError");function Jg(e){console.log(Kn.bgYellow(`==== ${e} ====`))}s(Jg,"logBanner");var Qg=Et(require("fs"));function qa(){return"0.2.9"}s(qa,"getVersion");var n5=Et(ey());var Pl=Symbol("options_key");function xr(e){return(t,r)=>{var n,i;if(e!=null){let o={...Reflect.getMetadata(Pl,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(Pl,o,t)}}}s(xr,"YargOption");function ty(e){let t=Reflect.getMetadata(Pl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}s(ty,"getYargsOption");function ry(e){return async t=>t.options(Lw(e)).middleware(async r=>await Fw(e,r),!0)}s(ry,"getBuilder");function Lw(e){return Object.entries(ty(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}s(Lw,"getYargsOptions");async function Fw(e,t){let r=new e;for(let[n,i]of Object.entries(ty(e)))r[n]=t[n]??i.default;return r}s(Fw,"loadYargsConfig");var qO=Et(j1()),DO=require("child_process");var R1="Schema",T1="Body",k1="Param",N1="Response",M1="ErrorResponse",dh="z.void()",Hc={bindings:["z"],from:"zod"};var q1={output:"output",splitByTags:!0,defaultTag:"Common",excludeTags:[],includeNamespaces:!0,configs:{models:{outputFileNameSuffix:"models",namespaceSuffix:"Models"},endpoints:{outputFileNameSuffix:"api",namespaceSuffix:"Api"},queries:{outputFileNameSuffix:"queries",namespaceSuffix:"Queries"}},schemaSuffix:R1,additionalPropertiesDefaultValue:!1,removeOperationPrefixEndingWith:"Controller_"};var hh={"Content-Type":"application/json",Accept:"application/json"},D1="data";var L1=s(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),mh=s(e=>e.replace(/^[^a-zA-Z_$]*/g,"").replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var Jr=Symbol.for("@ts-pattern/matcher"),N3=Symbol.for("@ts-pattern/isVariadic"),zc="@ts-pattern/anonymous-select-key",gh=s(e=>!!(e&&typeof e=="object"),"r"),Uc=s(e=>e&&!!e[Jr],"i"),Lr=s((e,t,r)=>{if(Uc(e)){let n=e[Jr](),{matched:i,selections:o}=n.match(t);return i&&o&&Object.keys(o).forEach(a=>r(a,o[a])),i}if(gh(e)){if(!gh(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],o=[];for(let a of e.keys()){let c=e[a];Uc(c)&&c[N3]?o.push(c):o.length?i.push(c):n.push(c)}if(o.length){if(o.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)=>Lr(l,a[p],r))&&i.every((l,p)=>Lr(l,c[p],r))&&(o.length===0||Lr(o[0],u,r))}return e.length===t.length&&e.every((a,c)=>Lr(a,t[c],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||Uc(o=i)&&o[Jr]().matcherType==="optional")&&Lr(i,t[n],r);var o})}return Object.is(t,e)},"s"),In=s(e=>{var t,r,n;return gh(e)?Uc(e)?(t=(r=(n=e[Jr]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?Uo(e,In):Uo(Object.values(e),In):[]},"o"),Uo=s((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function er(e){return Object.assign(e,{optional:s(()=>M3(e),"optional"),and:s(t=>De(e,t),"and"),or:s(t=>q3(e,t),"or"),select:s(t=>t===void 0?F1(e):F1(t,e),"select")})}s(er,"u");function M3(e){return er({[Jr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return t===void 0?(In(e).forEach(i=>n(i,void 0)),{matched:!0,selections:r}):{matched:Lr(e,t,n),selections:r}},"match"),getSelectionKeys:s(()=>In(e),"getSelectionKeys"),matcherType:"optional"})})}s(M3,"h");function De(...e){return er({[Jr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return{matched:e.every(i=>Lr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Uo(e,In),"getSelectionKeys"),matcherType:"and"})})}s(De,"m");function q3(...e){return er({[Jr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return Uo(e,In).forEach(i=>n(i,void 0)),{matched:e.some(i=>Lr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Uo(e,In),"getSelectionKeys"),matcherType:"or"})})}s(q3,"d");function Pe(e){return{[Jr]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(Pe,"p");function F1(...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 er({[Jr]:()=>({match:s(n=>{let i={[t??zc]:n};return{matched:r===void 0||Lr(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??zc].concat(r===void 0?[]:In(r)),"getSelectionKeys")})})}s(F1,"y");function qr(e){return typeof e=="number"}s(qr,"v");function xn(e){return typeof e=="string"}s(xn,"b");function En(e){return typeof e=="bigint"}s(En,"w");var PV=er(Pe(function(e){return!0}));var An=s(e=>Object.assign(er(e),{startsWith:s(t=>{return An(De(e,(r=t,Pe(n=>xn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return An(De(e,(r=t,Pe(n=>xn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>An(De(e,(r=>Pe(n=>xn(n)&&n.length>=r))(t))),"minLength"),length:s(t=>An(De(e,(r=>Pe(n=>xn(n)&&n.length===r))(t))),"length"),maxLength:s(t=>An(De(e,(r=>Pe(n=>xn(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return An(De(e,(r=t,Pe(n=>xn(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return An(De(e,(r=t,Pe(n=>xn(n)&&!!n.match(r)))));var r},"regex")}),"j"),OV=An(Pe(xn)),Dr=s(e=>Object.assign(er(e),{between:s((t,r)=>Dr(De(e,((n,i)=>Pe(o=>qr(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Dr(De(e,(r=>Pe(n=>qr(n)&&n<r))(t))),"lt"),gt:s(t=>Dr(De(e,(r=>Pe(n=>qr(n)&&n>r))(t))),"gt"),lte:s(t=>Dr(De(e,(r=>Pe(n=>qr(n)&&n<=r))(t))),"lte"),gte:s(t=>Dr(De(e,(r=>Pe(n=>qr(n)&&n>=r))(t))),"gte"),int:s(()=>Dr(De(e,Pe(t=>qr(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Dr(De(e,Pe(t=>qr(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Dr(De(e,Pe(t=>qr(t)&&t>0))),"positive"),negative:s(()=>Dr(De(e,Pe(t=>qr(t)&&t<0))),"negative")}),"x"),wV=Dr(Pe(qr)),Cn=s(e=>Object.assign(er(e),{between:s((t,r)=>Cn(De(e,((n,i)=>Pe(o=>En(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Cn(De(e,(r=>Pe(n=>En(n)&&n<r))(t))),"lt"),gt:s(t=>Cn(De(e,(r=>Pe(n=>En(n)&&n>r))(t))),"gt"),lte:s(t=>Cn(De(e,(r=>Pe(n=>En(n)&&n<=r))(t))),"lte"),gte:s(t=>Cn(De(e,(r=>Pe(n=>En(n)&&n>=r))(t))),"gte"),positive:s(()=>Cn(De(e,Pe(t=>En(t)&&t>0))),"positive"),negative:s(()=>Cn(De(e,Pe(t=>En(t)&&t<0))),"negative")}),"A"),$V=Cn(Pe(En)),xV=er(Pe(function(e){return typeof e=="boolean"})),EV=er(Pe(function(e){return typeof e=="symbol"})),AV=er(Pe(function(e){return e==null})),CV=er(Pe(function(e){return e!=null}));var _h=class _h 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}};s(_h,"W");var yh=_h,vh={matched:!1,value:void 0};function gt(e){return new bh(e,vh)}s(gt,"z");var Ho=class Ho{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 o=!1,a={},c=s((l,p)=>{o=!0,a[l]=p},"a"),u=!n.some(l=>Lr(l,this.input,c))||i&&!i(this.input)?vh:{matched:!0,value:r(o?zc in a?a[zc]:a:this.input,this.input)};return new Ho(this.input,u)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new Ho(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 yh(this.input)}run(){return this.exhaustive()}returnType(){return this}};s(Ho,"I");var bh=Ho;var Sh=2,V1=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],B1=["query","header","path"],Ps=["get","put","post","delete","options","head","patch","trace"],H1=["string","number","integer","boolean"];function Os(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(Os,"pick");var Fr=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),zo=s(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),U1=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),_r=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),z1=s(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),G1=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),W1=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var Z1=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Go=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),wh=s(e=>Go(e).split("/").at(-1),"getSchemaNameByRef");function He(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s(He,"isReferenceObject");function Y1(e){return D3(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/-+/g,"_").replace(/[^\w\-]+/g,"_").replace(/--+/g,"-")}s(Y1,"normalizeString");function J1(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(J1,"wrapWithQuotesIfNeeded");function Q1(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(Q1,"unwrapQuotesIfNeeded");function D3(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(D3,"prefixStringStartingWithNumberIfNeeded");function $h(e){let t=e.replaceAll("_","#");return _r(t.replaceAll("-","_")).replaceAll("#","_")}s($h,"pathParamToVariableName");var gi=s(e=>H1.includes(e),"isPrimitiveType");function X1(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,"\\/")}s(X1,"escapeControlCharacters");function ws(e){return e.includes("application/")&&e.includes("json")||V1.includes(e)||e.includes("text/")}s(ws,"isParamMediaTypeAllowed");function xh(e){return e>=200&&e<300}s(xh,"isMainResponseStatus");function Eh(e){return!(e>=200&&e<300)}s(Eh,"isErrorStatus");function Gc(e){return e==="application/json"}s(Gc,"isMediaTypeAllowed");function Ph({path:e,method:t,operation:r,options:n,keepOperationPrefixWithoutEnding:i}){let o=r.operationId??t+V3(e);if(n.removeOperationPrefixEndingWith&&i)return o.split(n.removeOperationPrefixEndingWith).map((c,u)=>u===0?c:Fr(c)).join("");if(n.removeOperationPrefixEndingWith&&!i){let a=new RegExp(`^.*${n.removeOperationPrefixEndingWith}`);o=o.replace(a,"")}return o}s(Ph,"getOperationName");function e2({path:e,method:t,operation:r,openApiDoc:n,options:i}){let o=L3(n,i),a=i.splitByTags?$s(r,i):i.defaultTag,c=Ph({path:e,method:t,operation:r,options:i});return o[a].filter(l=>Ph({path:e,method:t,operation:l,options:i})===c).length===1?c:Ph({path:e,method:t,operation:r,options:i,keepOperationPrefixWithoutEnding:!0})}s(e2,"getUniqueOperationName");function L3(e,t){let r={};for(let n in e.paths){let i=e.paths[n],o=Os(i,Ps);for(let a in o){let c=o[a];if(!c||c.deprecated&&!(t!=null&&t.withDeprecatedEndpoints))continue;let u=t.splitByTags?$s(c,t):t.defaultTag;r[u]||(r[u]=[]),r[u].push(c)}}return r}s(L3,"getOperationsByTag");function yi(e){return z1(e)}s(yi,"formatTag");function $s(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return yi(r??t.defaultTag)}s($s,"getOperationTag");var K1=/({\w+})/g,F3=/[^\w\-]+/g;function V3(e){e=Fr(U1(e.replaceAll("/","-")).replaceAll("-",""));let t=[...e.matchAll(K1)];if(t.length>0){let r=t.sort((n,i)=>n.index-i.index)[t.length-1][0];e=`${e.replace(K1,"")}By${Fr(r.slice(1,-1))}`}return e.replace(F3,"_")}s(V3,"pathToVariableName");var Oh=/{(\b\w+(?:-\w+)*\b)}/g;function t2(e){let t=e.match(Oh);return t===null?e.replaceAll(Oh,":$1"):(t.forEach(r=>{let n=$h(r.replaceAll(Oh,":$1"));e=e.replaceAll(r,n)}),e)}s(t2,"replaceHyphenatedPath");function Qr(e){return!He(e)}s(Qr,"isSchemaObject");function r2(e){return e.type==="array"}s(r2,"isArraySchemaObject");function n2(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,o)=>{if(B3(o)){let a=o.required;i[0].push(...a??[])}else i[1].push(o);return i},[[],[]]),n={properties:t.reduce((i,o)=>(i[o]={},i),{}),type:"object",required:t};return{noRequiredOnlyAllof:r,composedRequiredSchema:n,patchRequiredSchemaInLoop:s((i,o)=>{if(He(i)){let a=o(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")}}s(n2,"inferRequiredSchema");var B3=s(e=>!He(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function Wo({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${zo(t)}/`:""}${zo(t)}.${i}`:i}s(Wo,"getTagFileName");var Pt=s(({type:e,tag:t,options:r})=>`${Fr(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var jn=s((e,t)=>G1(Fr(Y1(e)),t),"getZodSchemaName"),Tt=s(e=>!e.startsWith("z."),"isNamedZodSchema"),i2=s(e=>_r(`${e}_${T1}`),"getBodyZodSchemaName"),s2=s((e,t)=>_r(`${e}_${t}${k1}`),"getParamZodSchemaName"),o2=s(e=>_r(`${e}${N1}`),"getMainResponseZodSchemaName"),a2=s((e,t)=>_r(`${e}_${t}_${M1}`),"getErrorResponseZodSchemaName");var Ko=s((e,t)=>W1(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),c2=s(({resolver:e,zodSchemaName:t,options:r})=>Tt(t)?`${r.includeNamespaces?`${Pt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${t}`:t,"getImportedZodSchemaName"),Ah=s(({resolver:e,zodSchemaName:t,options:r})=>Tt(t)?`${r.includeNamespaces?`${Pt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${Ko(t,r)}`:t,"getImportedZodSchemaInferedTypeName");function u2(e){return gt(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(u2,"primitiveTypeToTsType");var Zo=s(e=>zo(_r(e.operationName)),"getEndpointName");function l2(e,t){return`${t.includeNamespaces?`${Pt({type:"endpoints",tag:Yo(e,t),options:t})}.`:""}${Zo(e)}`}s(l2,"getImportedEndpointName");var f2=s(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function Yo(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return yi(r??t.defaultTag)}s(Yo,"getEndpointTag");function Ch({resolver:e,endpoint:t,options:r}){return t.parameters.map(n=>{var o,a,c,u;let i="string";if(Tt(n.zodSchema))i=Ah({resolver:e,zodSchemaName:n.zodSchema,options:r});else if((o=n.parameterObject)!=null&&o.schema&&Qr(n.parameterObject.schema)){let l=(c=(a=n.parameterObject)==null?void 0:a.schema)==null?void 0:c.type;l&&gi(l)&&(i=u2(l))}return{name:mh(n.name),type:i,paramType:n.type,required:((u=n.parameterObject)==null?void 0:u.required)??!0}}).sort((n,i)=>{if(n.required===i.required){let o=["Path","Body","Query","Header"];return o.indexOf(n.paramType)-o.indexOf(i.paramType)}return n.required?-1:1})}s(Ch,"mapEndpointParamsToFunctionParams");function p2(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let o=L1(i.name)?i.name:`"${i.name}"`,a=mh(i.name);return{...i,name:o,value:a}}),r={...e.requestFormat!==hh["Content-Type"]?{"Content-Type":e.requestFormat}:{},...e.responseFormat&&e.responseFormat!==hh.Accept?{Accept:e.responseFormat}:{}};return{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}s(p2,"getEndpointConfig");function Vr({schema:e,meta:t,options:r}){let n=[];gt(e.type).with("string",()=>n.push(z3(e))).with("number","integer",()=>n.push(W3(e))).with("array",()=>n.push(K3(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
|
|
141
141
|
`,"\r",`\r
|
|
142
142
|
`].some(o=>String.prototype.includes.call(e.description,o))?n.push(`describe(\`${e.description}\`)`):n.push(`describe("${e.description}")`));let i=n.concat(H3(e,t),(r==null?void 0:r.withDefaultValues)!==!1?U3(e):[]).filter(Boolean).join(".");return i?`.${i}`:""}s(Vr,"getZodChain");function H3(e,t){return e.nullable&&!(t!=null&&t.isRequired)?"nullish()":e.nullable?"nullable()":t!=null&&t.isRequired?"":"optional()"}s(H3,"getZodChainablePresence");function U3(e){return e.default!==void 0?`default(${gt(e.type).with("number","integer",()=>Q1(e.default)).otherwise(()=>JSON.stringify(e.default))})`:""}s(U3,"getZodChainableDefault");function z3(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(${G3(e.pattern)})`),e.format){let r=gt(e.format).with("email",()=>"email()").with("hostname",()=>"url()").with("uri",()=>"url()").with("uuid",()=>"uuid()").with("date-time",()=>"datetime({ offset: true })").otherwise(()=>"");r&&t.push(r)}return t.join(".")}s(z3,"getZodChainableStringValidations");function G3(e){return e.startsWith("/")&&e.endsWith("/")&&(e=e.slice(1,-1)),e=X1(e),`/${e}/`}s(G3,"formatPatternIfNeeded");function W3(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("."))}s(W3,"getZodChainableNumberValidations");function K3(e){let t=[];return e.minItems&&t.push(`min(${e.minItems})`),e.maxItems&&t.push(`max(${e.maxItems})`),t.join(".")}s(K3,"getZodChainableArrayValidations");var vi=s(e=>e.reduce((t,r)=>t+r,0),"sum");function rt({current:e,schema:t}){if(!t)return e;if(He(t))return e+2;if(Array.isArray(t.type))return t.type.length===1?Ot("oneOf")+rt({current:e,schema:{...t,type:t.type[0]}}):e+Ot("oneOf")+vi(t.type.map(r=>rt({current:0,schema:{...t,type:r}})));if(t.oneOf)return t.oneOf.length===1?Ot("oneOf")+rt({current:e,schema:t.oneOf[0]}):e+Ot("oneOf")+vi(t.oneOf.map(r=>rt({current:0,schema:r})));if(t.anyOf)return t.anyOf.length===1?Ot("anyOf")+rt({current:e,schema:t.anyOf[0]}):e+Ot("anyOf")+vi(t.anyOf.map(r=>rt({current:0,schema:r})));if(t.allOf)return t.allOf.length===1?Ot("allOf")+rt({current:e,schema:t.allOf[0]}):e+Ot("allOf")+vi(t.allOf.map(r=>rt({current:0,schema:r})));if(!t.type)return e;if(gi(t.type))return t.enum?e+d2(t)+Ot("enum")+vi(t.enum.map(r=>rt({current:0,schema:r}))):e+d2(t);if(t.type==="array")return t.items?Ot("array")+rt({current:e,schema:t.items}):Ot("array")+rt({current:e,schema:void 0});if(t.type==="object"||t.properties||t.additionalProperties){if(t.additionalProperties)return t.additionalProperties===!0?Ot("record")+rt({current:e,schema:void 0}):Ot("record")+rt({current:e,schema:t.additionalProperties});if(t.properties){let r=Object.values(t.properties);return e+Ot("object")+vi(r.map(n=>rt({current:0,schema:n})))}return Ot("empty-object")+rt({current:e,schema:void 0})}return e}s(rt,"getOpenAPISchemaComplexity");function d2(e){let t=e.type;return t?gt(t).with("string",()=>1).with("number",()=>1).with("integer",()=>1).with("boolean",()=>1).otherwise(()=>0):0}s(d2,"complexityByType");function Ot(e){return e?gt(e).with("oneOf",()=>2).with("anyOf",()=>3).with("allOf",()=>2).with("enum",()=>1).with("array",()=>1).with("record",()=>1).with("empty-object",()=>1).with("object",()=>2).otherwise(()=>0):0}s(Ot,"complexityByComposite");var Ih=class Ih{constructor(t,r,n={referencedBy:[]}){this.schema=t;this.resolver=r;He(t)&&(this.ref=t.$ref),this.meta={...n,referencedBy:[...(n==null?void 0:n.referencedBy)??[]]},this.ref&&this.meta.referencedBy.push(this)}code;ref;children=[];meta;getCodeString(t,r){var o,a;if((!this.ref||!this.resolver)&&this.code)return this.code;let n=(o=this.resolver)==null?void 0:o.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?`${Pt({type:"models",tag:i,options:r})}.${n}`:n}get complexity(){return rt({current:0,schema:this.schema})}assign(t){return this.code=t,this}inherit(t){return t&&t.children.push(this),this}};s(Ih,"ZodSchema");var Wc=Ih;function Ue({schema:e,resolver:t,meta:r,tag:n,options:i}){var v;if(!e)throw new Error("Schema is required");let o=new Wc(e,t,r),a={parent:o.inherit(r==null?void 0:r.parent),referencedBy:[...o.meta.referencedBy]},c={resolver:t,meta:a,tag:n,options:i};if(He(e))return Z3({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});let u=J3({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(u)return u;let l=Y3({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(l)return l;let p=Q3({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(p)return p;let f=X3({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(f)return f;let d=eM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(d)return d;let h=i!=null&&i.allReadonly?".readonly()":"";if(r2(e))return e.items?o.assign(`z.array(${Ue({...c,schema:e.items}).getCodeString(n,i)}${Vr({schema:e.items,meta:{...a,isRequired:!0},options:i})})${h}`):o.assign(`z.array(z.any())${h}`);let y=e.type?e.type.toLowerCase():void 0;if(y==="object"||e.properties||e.additionalProperties){let g=(i==null?void 0:i.additionalPropertiesDefaultValue)!==void 0?i==null?void 0:i.additionalPropertiesDefaultValue:!0,A=(e.additionalProperties===null||e.additionalProperties===void 0?g:e.additionalProperties)===!1?"":".passthrough()";if(typeof e.additionalProperties=="object"&&Object.keys(e.additionalProperties).length>0)return o.assign(`z.record(${Ue({...c,schema:e.additionalProperties}).getCodeString(n,i)+Vr({schema:e.additionalProperties,meta:{...a,isRequired:!0},options:i})})`);let T=e.required&&e.required.length>0,C=i!=null&&i.withImplicitRequiredProps?!1:!((v=e.required)!=null&&v.length),I="{}";e.properties&&(I="{ "+Object.entries(e.properties).map(([Ne,ee])=>{var Z;let N={...a,isRequired:C?!0:T?(Z=e.required)==null?void 0:Z.includes(Ne):i==null?void 0:i.withImplicitRequiredProps,name:Ne},j=ee;if(He(ee)&&t&&(j=t.getSchemaByRef(ee.$ref),!j))throw new Error(`Schema ${ee.$ref} not found`);let q=Ue({...c,schema:ee,meta:N}).getCodeString(n,i)+Vr({schema:j,meta:N,options:i});return[Ne,q]}).map(([Ne,ee])=>`${J1(Ne)}: ${ee}`).join(", ")+" }");let fe=C?".partial()":"",ne=i!=null&&i.strictObjects?".strict()":"";return o.assign(`z.object(${I})${fe}${ne}${A}${h}`)}if(!y)return o.assign("z.unknown()");throw new Error(`Unsupported schema type: ${y}`)}s(Ue,"getZodSchema");function Z3({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!He(e)||!r)return;let a=t.meta.referencedBy.slice(0,-1).map(l=>(r==null?void 0:r.getZodSchemaNameByRef(l.ref))??l.ref),c=r.getZodSchemaNameByRef(e.$ref);if(a.length>1&&a.includes(c))return t.assign(r.getCodeByZodSchemaName(t.ref));let u=r.getCodeByZodSchemaName(e.$ref);if(!u){let l=r.getSchemaByRef(e.$ref);if(!l)throw new Error(`Schema ${e.$ref} not found`);u=Ue({schema:l,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)}return r.getCodeByZodSchemaName(c)||r.setZodSchema(c,u,i),t}s(Z3,"getReferenceZodSchema");function Y3({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){var c;if(!Qr(e)||!e.oneOf)return;if(e.oneOf.length===1){let u=Ue({schema:e.oneOf[0],resolver:r,meta:n,tag:i,options:o});return t.assign(u.getCodeString(i,o))}let a=(c=e.oneOf)==null?void 0:c.some(u=>Qr(u)&&((u==null?void 0:u.allOf)||[]).length>1);if(e.discriminator&&!a){let u=e.discriminator.propertyName;return t.assign(`
|
|
143
143
|
z.discriminatedUnion("${u}", [${e.oneOf.map(l=>Ue({schema:l,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)).join(", ")}])
|