@povio/openapi-codegen-cli 0.1.1 → 0.1.2
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/generators/types/metadata.d.ts +1 -0
- package/dist/index.js +7 -7
- package/dist/sh.js +1 -1
- package/package.json +1 -1
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(Vg,"stringEncaseCRLFWithFirstIndex");var{stdout:Bg,stderr:Hg}=Lg,hl=Symbol("GENERATOR"),Ni=Symbol("STYLER"),Gs=Symbol("IS_EMPTY"),Ug=["ansi","ansi","ansi256","ansi16m"],Mi=Object.create(null),xP=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=Bg?Bg.level:0;e.level=t.level===void 0?r:t.level},"applyOptions"),yl=class yl{constructor(t){return zg(t)}};s(yl,"Chalk");var Ia=yl,zg=s(e=>{let t=s((...r)=>r.join(" "),"chalk");return xP(t,e),Object.setPrototypeOf(t,Ws.prototype),t},"chalkFactory");function Ws(e){return zg(e)}s(Ws,"createChalk");Object.setPrototypeOf(Ws.prototype,Function.prototype);for(let[e,t]of Object.entries(ar))Mi[e]={get(){let r=Ra(this,gl(t.open,t.close,this[Ni]),this[Gs]);return Object.defineProperty(this,e,{value:r}),r}};Mi.visible={get(){let e=Ra(this,this[Ni],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var ml=s((e,t,r,...n)=>e==="rgb"?t==="ansi16m"?ar[r].ansi16m(...n):t==="ansi256"?ar[r].ansi256(ar.rgbToAnsi256(...n)):ar[r].ansi(ar.rgbToAnsi(...n)):e==="hex"?ml("rgb",t,r,...ar.hexToRgb(...n)):ar[r][e](...n),"getModelAnsi"),EP=["rgb","hex","ansi256"];for(let e of EP){Mi[e]={get(){let{level:r}=this;return function(...n){let i=gl(ml(e,Ug[r],"color",...n),ar.color.close,this[Ni]);return Ra(this,i,this[Gs])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);Mi[t]={get(){let{level:r}=this;return function(...n){let i=gl(ml(e,Ug[r],"bgColor",...n),ar.bgColor.close,this[Ni]);return Ra(this,i,this[Gs])}}}}var AP=Object.defineProperties(()=>{},{...Mi,level:{enumerable:!0,get(){return this[hl].level},set(e){this[hl].level=e}}}),gl=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"),Ra=s((e,t,r)=>{let n=s((...i)=>CP(n,i.length===1?""+i[0]:i.join(" ")),"builder");return Object.setPrototypeOf(n,AP),n[hl]=e,n[Ni]=t,n[Gs]=r,n},"createBuilder"),CP=s((e,t)=>{if(e.level<=0||!t)return e[Gs]?"":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=Fg(t,r.close,r.open),r=r.parent;let o=t.indexOf(`
|
|
140
|
-
`);return o!==-1&&(t=Vg(t,i,n,o)),n+t+i},"applyStyle");Object.defineProperties(Ws.prototype,Mi);var NL=Ws(),ML=Ws({level:Hg?Hg.level:0});var Zn=new Ia;function vl(e,t,r){console.log(r!==void 0&&r!==t?`${Zn.yellow(`${e}:`.padEnd(20))}${Zn.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}s(vl,"logVariable");function Ti(e){console.log(`[INFO] ${e}`)}s(Ti,"logInfo");function bl(e){console.log(Zn.green(`[SUCCESS] ${e}`))}s(bl,"logSuccess");function Ks(e,t){e instanceof Error?(console.log(Zn.red(`[ERROR] ${t||e.message}`)),process.env.VERBOSE&&console.error(e)):console.log(Zn.red(`[ERROR] ${e}`))}s(Ks,"logError");function Gg(e){console.log(Zn.bgYellow(`==== ${e} ====`))}s(Gg,"logBanner");var Wg=Et(require("fs"));function ja(){return"0.1.1"}s(ja,"getVersion");var KL=Et(Zg());var _l=Symbol("options_key");function Hr(e){return(t,r)=>{var n,i;if(e!=null){let o={...Reflect.getMetadata(_l,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(_l,o,t)}}}s(Hr,"YargOption");function Yg(e){let t=Reflect.getMetadata(_l,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}s(Yg,"getYargsOption");function Jg(e){return async t=>t.options(IP(e)).middleware(async r=>await RP(e,r),!0)}s(Jg,"getBuilder");function IP(e){return Object.entries(Yg(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}s(IP,"getYargsOptions");async function RP(e,t){let r=new e;for(let[n,i]of Object.entries(Yg(e)))r[n]=t[n]??i.default;return r}s(RP,"loadYargsConfig");var A$=Et(x1()),C$=require("child_process");var E1="Schema",A1="Body",C1="Param",I1="Response",R1="ErrorResponse",fh="z.void()",Du={bindings:["z"],from:"zod"};var j1={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:E1,additionalPropertiesDefaultValue:!1};var ph={"Content-Type":"application/json",Accept:"application/json"},dh="AppRestClient",k1={bindings:[dh],from:"@/util/rest/clients/app-rest-client"};var N1=s(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),hh=s(e=>e.replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var Zr=Symbol.for("@ts-pattern/matcher"),xM=Symbol.for("@ts-pattern/isVariadic"),Fu="@ts-pattern/anonymous-select-key",mh=s(e=>!!(e&&typeof e=="object"),"r"),Lu=s(e=>e&&!!e[Zr],"i"),qr=s((e,t,r)=>{if(Lu(e)){let n=e[Zr](),{matched:i,selections:o}=n.match(t);return i&&o&&Object.keys(o).forEach(a=>r(a,o[a])),i}if(mh(e)){if(!mh(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],o=[];for(let a of e.keys()){let u=e[a];Lu(u)&&u[xM]?o.push(u):o.length?i.push(u):n.push(u)}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),u=i.length===0?[]:t.slice(-i.length),c=t.slice(n.length,i.length===0?1/0:-i.length);return n.every((l,p)=>qr(l,a[p],r))&&i.every((l,p)=>qr(l,u[p],r))&&(o.length===0||qr(o[0],c,r))}return e.length===t.length&&e.every((a,u)=>qr(a,t[u],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||Lu(o=i)&&o[Zr]().matcherType==="optional")&&qr(i,t[n],r);var o})}return Object.is(t,e)},"s"),In=s(e=>{var t,r,n;return mh(e)?Lu(e)?(t=(r=(n=e[Zr]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?Vo(e,In):Vo(Object.values(e),In):[]},"o"),Vo=s((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function er(e){return Object.assign(e,{optional:s(()=>EM(e),"optional"),and:s(t=>Le(e,t),"and"),or:s(t=>AM(e,t),"or"),select:s(t=>t===void 0?M1(e):M1(t,e),"select")})}s(er,"u");function EM(e){return er({[Zr]:()=>({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:qr(e,t,n),selections:r}},"match"),getSelectionKeys:s(()=>In(e),"getSelectionKeys"),matcherType:"optional"})})}s(EM,"h");function Le(...e){return er({[Zr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return{matched:e.every(i=>qr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Vo(e,In),"getSelectionKeys"),matcherType:"and"})})}s(Le,"m");function AM(...e){return er({[Zr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return Vo(e,In).forEach(i=>n(i,void 0)),{matched:e.some(i=>qr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Vo(e,In),"getSelectionKeys"),matcherType:"or"})})}s(AM,"d");function we(e){return{[Zr]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(we,"p");function M1(...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({[Zr]:()=>({match:s(n=>{let i={[t??Fu]:n};return{matched:r===void 0||qr(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??Fu].concat(r===void 0?[]:In(r)),"getSelectionKeys")})})}s(M1,"y");function Mr(e){return typeof e=="number"}s(Mr,"v");function xn(e){return typeof e=="string"}s(xn,"b");function En(e){return typeof e=="bigint"}s(En,"w");var dV=er(we(function(e){return!0}));var An=s(e=>Object.assign(er(e),{startsWith:s(t=>{return An(Le(e,(r=t,we(n=>xn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return An(Le(e,(r=t,we(n=>xn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>An(Le(e,(r=>we(n=>xn(n)&&n.length>=r))(t))),"minLength"),length:s(t=>An(Le(e,(r=>we(n=>xn(n)&&n.length===r))(t))),"length"),maxLength:s(t=>An(Le(e,(r=>we(n=>xn(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return An(Le(e,(r=t,we(n=>xn(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return An(Le(e,(r=t,we(n=>xn(n)&&!!n.match(r)))));var r},"regex")}),"j"),hV=An(we(xn)),Tr=s(e=>Object.assign(er(e),{between:s((t,r)=>Tr(Le(e,((n,i)=>we(o=>Mr(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Tr(Le(e,(r=>we(n=>Mr(n)&&n<r))(t))),"lt"),gt:s(t=>Tr(Le(e,(r=>we(n=>Mr(n)&&n>r))(t))),"gt"),lte:s(t=>Tr(Le(e,(r=>we(n=>Mr(n)&&n<=r))(t))),"lte"),gte:s(t=>Tr(Le(e,(r=>we(n=>Mr(n)&&n>=r))(t))),"gte"),int:s(()=>Tr(Le(e,we(t=>Mr(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Tr(Le(e,we(t=>Mr(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Tr(Le(e,we(t=>Mr(t)&&t>0))),"positive"),negative:s(()=>Tr(Le(e,we(t=>Mr(t)&&t<0))),"negative")}),"x"),mV=Tr(we(Mr)),Cn=s(e=>Object.assign(er(e),{between:s((t,r)=>Cn(Le(e,((n,i)=>we(o=>En(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Cn(Le(e,(r=>we(n=>En(n)&&n<r))(t))),"lt"),gt:s(t=>Cn(Le(e,(r=>we(n=>En(n)&&n>r))(t))),"gt"),lte:s(t=>Cn(Le(e,(r=>we(n=>En(n)&&n<=r))(t))),"lte"),gte:s(t=>Cn(Le(e,(r=>we(n=>En(n)&&n>=r))(t))),"gte"),positive:s(()=>Cn(Le(e,we(t=>En(t)&&t>0))),"positive"),negative:s(()=>Cn(Le(e,we(t=>En(t)&&t<0))),"negative")}),"A"),gV=Cn(we(En)),yV=er(we(function(e){return typeof e=="boolean"})),vV=er(we(function(e){return typeof e=="symbol"})),bV=er(we(function(e){return e==null})),_V=er(we(function(e){return e!=null}));var bh=class bh 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(bh,"W");var gh=bh,yh={matched:!1,value:void 0};function St(e){return new vh(e,yh)}s(St,"z");var Fo=class Fo{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={},u=s((l,p)=>{o=!0,a[l]=p},"a"),c=!n.some(l=>qr(l,this.input,u))||i&&!i(this.input)?yh:{matched:!0,value:r(o?Fu in a?a[Fu]:a:this.input,this.input)};return new Fo(this.input,c)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new Fo(this.input,n?{matched:!0,value:r(this.input,this.input)}:yh)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new gh(this.input)}run(){return this.exhaustive()}returnType(){return this}};s(Fo,"I");var vh=Fo;var _h=2,T1=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],q1=["query","header","path"],Vu=["get","put","post","delete","options","head","patch","trace"],D1=["string","number","integer","boolean"];var Yr=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),Bo=s(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),L1=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),br=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),F1=s(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),V1=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),B1=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var H1=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Ho=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),wh=s(e=>Ho(e).split("/").at(-1),"getSchemaNameByRef");function $e(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s($e,"isReferenceObject");function U1(e){return CM(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/-+/g,"_").replace(/[^\w\-]+/g,"_").replace(/--+/g,"-")}s(U1,"normalizeString");function z1(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(z1,"wrapWithQuotesIfNeeded");function G1(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(G1,"unwrapQuotesIfNeeded");function CM(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(CM,"prefixStringStartingWithNumberIfNeeded");function $h(e){let t=e.replaceAll("_","#");return br(t.replaceAll("-","_")).replaceAll("#","_")}s($h,"pathParamToVariableName");var Ss=s(e=>D1.includes(e),"isPrimitiveType");function W1(e){return St(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(W1,"primitiveTypeToTsType");function K1(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(K1,"escapeControlCharacters");function ws(e){return e.includes("application/")&&e.includes("json")||T1.includes(e)||e.includes("text/")}s(ws,"isParamMediaTypeAllowed");function Ph(e){return e>=200&&e<300}s(Ph,"isMainResponseStatus");function Oh(e){return!(e>=200&&e<300)}s(Oh,"isErrorStatus");function Bu(e){return e==="application/json"}s(Bu,"isMediaTypeAllowed");function Z1(e,t,r){return r.operationId??t+jM(e)}s(Z1,"getOperationName");function yi(e){return F1(e)}s(yi,"formatTag");function Hu(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return yi(r??t.defaultTag)}s(Hu,"getOperationTag");var IM=/({\w+})/g,RM=/[^\w\-]+/g;function jM(e){return Yr(L1(e.replaceAll("/","-")).replaceAll("-","")).replace(IM,t=>Yr(t.slice(1,-1))).replace(RM,"_")}s(jM,"pathToVariableName");var Sh=/{(\b\w+(?:-\w+)*\b)}/g;function Y1(e){let t=e.match(Sh);return t===null?e.replaceAll(Sh,":$1"):(t.forEach(r=>{let n=$h(r.replaceAll(Sh,":$1"));e=e.replaceAll(r,n)}),e)}s(Y1,"replaceHyphenatedPath");function Jr(e){return!$e(e)}s(Jr,"isSchemaObject");function J1(e){return e.type==="array"}s(J1,"isArraySchemaObject");function Q1(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(kM(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($e(i)){let a=o(i.$ref);a&&n.required.forEach(u=>{var c;n.properties[u]=((c=a==null?void 0:a.properties)==null?void 0:c[u])??{}})}else{let a=i.properties??{};n.required.forEach(u=>{a[u]&&(n.properties[u]=a[u]??{})})}},"patchRequiredSchemaInLoop")}}s(Q1,"inferRequiredSchema");var kM=s(e=>!$e(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");var Rn=s((e,t)=>V1(Yr(U1(e)),t),"getZodSchemaName"),Lt=s(e=>!e.startsWith("z."),"isNamedZodSchema"),X1=s(e=>br(`${e}_${A1}`),"getBodyZodSchemaName"),e2=s((e,t)=>br(`${e}_${t}${C1}`),"getParamZodSchemaName"),t2=s(e=>br(`${e}${I1}`),"getMainResponseZodSchemaName"),r2=s((e,t)=>br(`${e}_${t}_${R1}`),"getErrorResponseZodSchemaName");function Uu({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${Bo(t)}/`:""}${Bo(t)}.${i}`:i}s(Uu,"getTagFileName");var wt=s(({type:e,tag:t,options:r})=>`${Yr(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var Uo=s((e,t)=>B1(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),n2=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${wt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${t}`:t,"getImportedZodSchemaName"),i2=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${wt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${Uo(t,r)}`:t,"getImportedZodSchemaInferedTypeName");var zo=s(e=>Bo(br(e.operationName)),"getEndpointName");function s2(e,t){return`${t.includeNamespaces?`${wt({type:"endpoints",tag:Go(e,t),options:t})}.`:""}${zo(e)}`}s(s2,"getImportedEndpointName");var o2=s(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function Go(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return yi(r??t.defaultTag)}s(Go,"getEndpointTag");function xh({resolver:e,endpoint:t,options:r}){return t.parameters.map(n=>{var o,a,u,c;let i="string";if(Lt(n.zodSchema))i=i2({resolver:e,zodSchemaName:n.zodSchema,options:r});else if((o=n.parameterObject)!=null&&o.schema&&Jr(n.parameterObject.schema)){let l=(u=(a=n.parameterObject)==null?void 0:a.schema)==null?void 0:u.type;l&&Ss(l)&&(i=W1(l))}return{name:hh(n.name),type:i,paramType:n.type,required:((c=n.parameterObject)==null?void 0:c.required)??!0}}).sort((n,i)=>{if(n.required===i.required){let o=["Path","Query","Header","Body"];return o.indexOf(n.paramType)-o.indexOf(i.paramType)}return n.required?-1:1})}s(xh,"mapEndpointParamsToFunctionParams");function a2(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let o=N1(i.name)?i.name:`"${i.name}"`,a=hh(i.name);return{...i,name:o,value:a}}),r={...e.requestFormat!==ph["Content-Type"]?{"Content-Type":e.requestFormat}:{},...e.responseFormat&&e.responseFormat!==ph.Accept?{Accept:e.responseFormat}:{}};return{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}s(a2,"getEndpointConfig");function zu(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(zu,"pick");function Dr({schema:e,meta:t,options:r}){let n=[];St(e.type).with("string",()=>n.push(TM(e))).with("number","integer",()=>n.push(DM(e))).with("array",()=>n.push(LM(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
|
|
140
|
+
`);return o!==-1&&(t=Vg(t,i,n,o)),n+t+i},"applyStyle");Object.defineProperties(Ws.prototype,Mi);var NL=Ws(),ML=Ws({level:Hg?Hg.level:0});var Zn=new Ia;function vl(e,t,r){console.log(r!==void 0&&r!==t?`${Zn.yellow(`${e}:`.padEnd(20))}${Zn.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}s(vl,"logVariable");function Ti(e){console.log(`[INFO] ${e}`)}s(Ti,"logInfo");function bl(e){console.log(Zn.green(`[SUCCESS] ${e}`))}s(bl,"logSuccess");function Ks(e,t){e instanceof Error?(console.log(Zn.red(`[ERROR] ${t||e.message}`)),process.env.VERBOSE&&console.error(e)):console.log(Zn.red(`[ERROR] ${e}`))}s(Ks,"logError");function Gg(e){console.log(Zn.bgYellow(`==== ${e} ====`))}s(Gg,"logBanner");var Wg=Et(require("fs"));function ja(){return"0.1.2"}s(ja,"getVersion");var KL=Et(Zg());var _l=Symbol("options_key");function Hr(e){return(t,r)=>{var n,i;if(e!=null){let o={...Reflect.getMetadata(_l,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(_l,o,t)}}}s(Hr,"YargOption");function Yg(e){let t=Reflect.getMetadata(_l,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}s(Yg,"getYargsOption");function Jg(e){return async t=>t.options(IP(e)).middleware(async r=>await RP(e,r),!0)}s(Jg,"getBuilder");function IP(e){return Object.entries(Yg(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}s(IP,"getYargsOptions");async function RP(e,t){let r=new e;for(let[n,i]of Object.entries(Yg(e)))r[n]=t[n]??i.default;return r}s(RP,"loadYargsConfig");var A$=Et(x1()),C$=require("child_process");var E1="Schema",A1="Body",C1="Param",I1="Response",R1="ErrorResponse",fh="z.void()",Du={bindings:["z"],from:"zod"};var j1={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:E1,additionalPropertiesDefaultValue:!1};var ph={"Content-Type":"application/json",Accept:"application/json"},dh="AppRestClient",k1={bindings:[dh],from:"@/util/rest/clients/app-rest-client"};var N1=s(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),hh=s(e=>e.replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var Zr=Symbol.for("@ts-pattern/matcher"),xM=Symbol.for("@ts-pattern/isVariadic"),Fu="@ts-pattern/anonymous-select-key",mh=s(e=>!!(e&&typeof e=="object"),"r"),Lu=s(e=>e&&!!e[Zr],"i"),qr=s((e,t,r)=>{if(Lu(e)){let n=e[Zr](),{matched:i,selections:o}=n.match(t);return i&&o&&Object.keys(o).forEach(a=>r(a,o[a])),i}if(mh(e)){if(!mh(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],o=[];for(let a of e.keys()){let u=e[a];Lu(u)&&u[xM]?o.push(u):o.length?i.push(u):n.push(u)}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),u=i.length===0?[]:t.slice(-i.length),c=t.slice(n.length,i.length===0?1/0:-i.length);return n.every((l,p)=>qr(l,a[p],r))&&i.every((l,p)=>qr(l,u[p],r))&&(o.length===0||qr(o[0],c,r))}return e.length===t.length&&e.every((a,u)=>qr(a,t[u],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||Lu(o=i)&&o[Zr]().matcherType==="optional")&&qr(i,t[n],r);var o})}return Object.is(t,e)},"s"),In=s(e=>{var t,r,n;return mh(e)?Lu(e)?(t=(r=(n=e[Zr]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?Vo(e,In):Vo(Object.values(e),In):[]},"o"),Vo=s((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function er(e){return Object.assign(e,{optional:s(()=>EM(e),"optional"),and:s(t=>Le(e,t),"and"),or:s(t=>AM(e,t),"or"),select:s(t=>t===void 0?M1(e):M1(t,e),"select")})}s(er,"u");function EM(e){return er({[Zr]:()=>({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:qr(e,t,n),selections:r}},"match"),getSelectionKeys:s(()=>In(e),"getSelectionKeys"),matcherType:"optional"})})}s(EM,"h");function Le(...e){return er({[Zr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return{matched:e.every(i=>qr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Vo(e,In),"getSelectionKeys"),matcherType:"and"})})}s(Le,"m");function AM(...e){return er({[Zr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return Vo(e,In).forEach(i=>n(i,void 0)),{matched:e.some(i=>qr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Vo(e,In),"getSelectionKeys"),matcherType:"or"})})}s(AM,"d");function we(e){return{[Zr]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(we,"p");function M1(...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({[Zr]:()=>({match:s(n=>{let i={[t??Fu]:n};return{matched:r===void 0||qr(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??Fu].concat(r===void 0?[]:In(r)),"getSelectionKeys")})})}s(M1,"y");function Mr(e){return typeof e=="number"}s(Mr,"v");function xn(e){return typeof e=="string"}s(xn,"b");function En(e){return typeof e=="bigint"}s(En,"w");var dV=er(we(function(e){return!0}));var An=s(e=>Object.assign(er(e),{startsWith:s(t=>{return An(Le(e,(r=t,we(n=>xn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return An(Le(e,(r=t,we(n=>xn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>An(Le(e,(r=>we(n=>xn(n)&&n.length>=r))(t))),"minLength"),length:s(t=>An(Le(e,(r=>we(n=>xn(n)&&n.length===r))(t))),"length"),maxLength:s(t=>An(Le(e,(r=>we(n=>xn(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return An(Le(e,(r=t,we(n=>xn(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return An(Le(e,(r=t,we(n=>xn(n)&&!!n.match(r)))));var r},"regex")}),"j"),hV=An(we(xn)),Tr=s(e=>Object.assign(er(e),{between:s((t,r)=>Tr(Le(e,((n,i)=>we(o=>Mr(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Tr(Le(e,(r=>we(n=>Mr(n)&&n<r))(t))),"lt"),gt:s(t=>Tr(Le(e,(r=>we(n=>Mr(n)&&n>r))(t))),"gt"),lte:s(t=>Tr(Le(e,(r=>we(n=>Mr(n)&&n<=r))(t))),"lte"),gte:s(t=>Tr(Le(e,(r=>we(n=>Mr(n)&&n>=r))(t))),"gte"),int:s(()=>Tr(Le(e,we(t=>Mr(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Tr(Le(e,we(t=>Mr(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Tr(Le(e,we(t=>Mr(t)&&t>0))),"positive"),negative:s(()=>Tr(Le(e,we(t=>Mr(t)&&t<0))),"negative")}),"x"),mV=Tr(we(Mr)),Cn=s(e=>Object.assign(er(e),{between:s((t,r)=>Cn(Le(e,((n,i)=>we(o=>En(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Cn(Le(e,(r=>we(n=>En(n)&&n<r))(t))),"lt"),gt:s(t=>Cn(Le(e,(r=>we(n=>En(n)&&n>r))(t))),"gt"),lte:s(t=>Cn(Le(e,(r=>we(n=>En(n)&&n<=r))(t))),"lte"),gte:s(t=>Cn(Le(e,(r=>we(n=>En(n)&&n>=r))(t))),"gte"),positive:s(()=>Cn(Le(e,we(t=>En(t)&&t>0))),"positive"),negative:s(()=>Cn(Le(e,we(t=>En(t)&&t<0))),"negative")}),"A"),gV=Cn(we(En)),yV=er(we(function(e){return typeof e=="boolean"})),vV=er(we(function(e){return typeof e=="symbol"})),bV=er(we(function(e){return e==null})),_V=er(we(function(e){return e!=null}));var bh=class bh 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(bh,"W");var gh=bh,yh={matched:!1,value:void 0};function St(e){return new vh(e,yh)}s(St,"z");var Fo=class Fo{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={},u=s((l,p)=>{o=!0,a[l]=p},"a"),c=!n.some(l=>qr(l,this.input,u))||i&&!i(this.input)?yh:{matched:!0,value:r(o?Fu in a?a[Fu]:a:this.input,this.input)};return new Fo(this.input,c)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new Fo(this.input,n?{matched:!0,value:r(this.input,this.input)}:yh)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new gh(this.input)}run(){return this.exhaustive()}returnType(){return this}};s(Fo,"I");var vh=Fo;var _h=2,T1=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],q1=["query","header","path"],Vu=["get","put","post","delete","options","head","patch","trace"],D1=["string","number","integer","boolean"];var Yr=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),Bo=s(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),L1=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),br=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),F1=s(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),V1=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),B1=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var H1=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Ho=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),wh=s(e=>Ho(e).split("/").at(-1),"getSchemaNameByRef");function $e(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s($e,"isReferenceObject");function U1(e){return CM(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/-+/g,"_").replace(/[^\w\-]+/g,"_").replace(/--+/g,"-")}s(U1,"normalizeString");function z1(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(z1,"wrapWithQuotesIfNeeded");function G1(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(G1,"unwrapQuotesIfNeeded");function CM(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(CM,"prefixStringStartingWithNumberIfNeeded");function $h(e){let t=e.replaceAll("_","#");return br(t.replaceAll("-","_")).replaceAll("#","_")}s($h,"pathParamToVariableName");var Ss=s(e=>D1.includes(e),"isPrimitiveType");function W1(e){return St(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(W1,"primitiveTypeToTsType");function K1(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(K1,"escapeControlCharacters");function ws(e){return e.includes("application/")&&e.includes("json")||T1.includes(e)||e.includes("text/")}s(ws,"isParamMediaTypeAllowed");function Ph(e){return e>=200&&e<300}s(Ph,"isMainResponseStatus");function Oh(e){return!(e>=200&&e<300)}s(Oh,"isErrorStatus");function Bu(e){return e==="application/json"}s(Bu,"isMediaTypeAllowed");function Z1(e,t,r){return r.operationId??t+jM(e)}s(Z1,"getOperationName");function yi(e){return F1(e)}s(yi,"formatTag");function Hu(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return yi(r??t.defaultTag)}s(Hu,"getOperationTag");var IM=/({\w+})/g,RM=/[^\w\-]+/g;function jM(e){return Yr(L1(e.replaceAll("/","-")).replaceAll("-","")).replace(IM,t=>Yr(t.slice(1,-1))).replace(RM,"_")}s(jM,"pathToVariableName");var Sh=/{(\b\w+(?:-\w+)*\b)}/g;function Y1(e){let t=e.match(Sh);return t===null?e.replaceAll(Sh,":$1"):(t.forEach(r=>{let n=$h(r.replaceAll(Sh,":$1"));e=e.replaceAll(r,n)}),e)}s(Y1,"replaceHyphenatedPath");function Jr(e){return!$e(e)}s(Jr,"isSchemaObject");function J1(e){return e.type==="array"}s(J1,"isArraySchemaObject");function Q1(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(kM(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($e(i)){let a=o(i.$ref);a&&n.required.forEach(u=>{var c;n.properties[u]=((c=a==null?void 0:a.properties)==null?void 0:c[u])??{}})}else{let a=i.properties??{};n.required.forEach(u=>{a[u]&&(n.properties[u]=a[u]??{})})}},"patchRequiredSchemaInLoop")}}s(Q1,"inferRequiredSchema");var kM=s(e=>!$e(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");var Rn=s((e,t)=>V1(Yr(U1(e)),t),"getZodSchemaName"),Lt=s(e=>!e.startsWith("z."),"isNamedZodSchema"),X1=s(e=>br(`${e}_${A1}`),"getBodyZodSchemaName"),e2=s((e,t)=>br(`${e}_${t}${C1}`),"getParamZodSchemaName"),t2=s(e=>br(`${e}${I1}`),"getMainResponseZodSchemaName"),r2=s((e,t)=>br(`${e}_${t}_${R1}`),"getErrorResponseZodSchemaName");function Uu({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${Bo(t)}/`:""}${Bo(t)}.${i}`:i}s(Uu,"getTagFileName");var wt=s(({type:e,tag:t,options:r})=>`${Yr(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var Uo=s((e,t)=>B1(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),n2=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${wt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${t}`:t,"getImportedZodSchemaName"),i2=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${wt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${Uo(t,r)}`:t,"getImportedZodSchemaInferedTypeName");var zo=s(e=>Bo(br(e.operationName)),"getEndpointName");function s2(e,t){return`${t.includeNamespaces?`${wt({type:"endpoints",tag:Go(e,t),options:t})}.`:""}${zo(e)}`}s(s2,"getImportedEndpointName");var o2=s(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function Go(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return yi(r??t.defaultTag)}s(Go,"getEndpointTag");function xh({resolver:e,endpoint:t,options:r}){return t.parameters.map(n=>{var o,a,u,c;let i="string";if(Lt(n.zodSchema))i=i2({resolver:e,zodSchemaName:n.zodSchema,options:r});else if((o=n.parameterObject)!=null&&o.schema&&Jr(n.parameterObject.schema)){let l=(u=(a=n.parameterObject)==null?void 0:a.schema)==null?void 0:u.type;l&&Ss(l)&&(i=W1(l))}return{name:hh(n.name),type:i,paramType:n.type,required:((c=n.parameterObject)==null?void 0:c.required)??!0}}).sort((n,i)=>{if(n.required===i.required){let o=["Path","Query","Header","Body"];return o.indexOf(n.paramType)-o.indexOf(i.paramType)}return n.required?-1:1})}s(xh,"mapEndpointParamsToFunctionParams");function a2(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let o=N1(i.name)?i.name:`"${i.name}"`,a=hh(i.name);return{...i,name:o,value:a}}),r={...e.requestFormat!==ph["Content-Type"]?{"Content-Type":e.requestFormat}:{},...e.responseFormat&&e.responseFormat!==ph.Accept?{Accept:e.responseFormat}:{}};return{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}s(a2,"getEndpointConfig");function zu(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(zu,"pick");function Dr({schema:e,meta:t,options:r}){let n=[];St(e.type).with("string",()=>n.push(TM(e))).with("number","integer",()=>n.push(DM(e))).with("array",()=>n.push(LM(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(NM(e,t),(r==null?void 0:r.withDefaultValues)!==!1?MM(e):[]).filter(Boolean).join(".");return i?`.${i}`:""}s(Dr,"getZodChain");function NM(e,t){return e.nullable&&!(t!=null&&t.isRequired)?"nullish()":e.nullable?"nullable()":t!=null&&t.isRequired?"":"optional()"}s(NM,"getZodChainablePresence");function MM(e){return e.default!==void 0?`default(${St(e.type).with("number","integer",()=>G1(e.default)).otherwise(()=>JSON.stringify(e.default))})`:""}s(MM,"getZodChainableDefault");function TM(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(${qM(e.pattern)})`),e.format){let r=St(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(TM,"getZodChainableStringValidations");function qM(e){return e.startsWith("/")&&e.endsWith("/")&&(e=e.slice(1,-1)),e=K1(e),`/${e}/`}s(qM,"formatPatternIfNeeded");function DM(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(DM,"getZodChainableNumberValidations");function LM(e){let t=[];return e.minItems&&t.push(`min(${e.minItems})`),e.maxItems&&t.push(`max(${e.maxItems})`),t.join(".")}s(LM,"getZodChainableArrayValidations");var vi=s(e=>e.reduce((t,r)=>t+r,0),"sum");function rt({current:e,schema:t}){if(!t)return e;if($e(t))return e+2;if(Array.isArray(t.type))return t.type.length===1?$t("oneOf")+rt({current:e,schema:{...t,type:t.type[0]}}):e+$t("oneOf")+vi(t.type.map(r=>rt({current:0,schema:{...t,type:r}})));if(t.oneOf)return t.oneOf.length===1?$t("oneOf")+rt({current:e,schema:t.oneOf[0]}):e+$t("oneOf")+vi(t.oneOf.map(r=>rt({current:0,schema:r})));if(t.anyOf)return t.anyOf.length===1?$t("anyOf")+rt({current:e,schema:t.anyOf[0]}):e+$t("anyOf")+vi(t.anyOf.map(r=>rt({current:0,schema:r})));if(t.allOf)return t.allOf.length===1?$t("allOf")+rt({current:e,schema:t.allOf[0]}):e+$t("allOf")+vi(t.allOf.map(r=>rt({current:0,schema:r})));if(!t.type)return e;if(Ss(t.type))return t.enum?e+u2(t)+$t("enum")+vi(t.enum.map(r=>rt({current:0,schema:r}))):e+u2(t);if(t.type==="array")return t.items?$t("array")+rt({current:e,schema:t.items}):$t("array")+rt({current:e,schema:void 0});if(t.type==="object"||t.properties||t.additionalProperties){if(t.additionalProperties)return t.additionalProperties===!0?$t("record")+rt({current:e,schema:void 0}):$t("record")+rt({current:e,schema:t.additionalProperties});if(t.properties){let r=Object.values(t.properties);return e+$t("object")+vi(r.map(n=>rt({current:0,schema:n})))}return $t("empty-object")+rt({current:e,schema:void 0})}return e}s(rt,"getOpenAPISchemaComplexity");function u2(e){let t=e.type;return t?St(t).with("string",()=>1).with("number",()=>1).with("integer",()=>1).with("boolean",()=>1).otherwise(()=>0):0}s(u2,"complexityByType");function $t(e){return e?St(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($t,"complexityByComposite");var Eh=class Eh{constructor(t,r,n={referencedBy:[]}){this.schema=t;this.resolver=r;$e(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?`${wt({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(Eh,"ZodSchema");var Gu=Eh;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 Gu(e,t,r),a={parent:o.inherit(r==null?void 0:r.parent),referencedBy:[...o.meta.referencedBy]},u={resolver:t,meta:a,tag:n,options:i};if($e(e))return FM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});let c=BM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(c)return c;let l=VM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(l)return l;let p=HM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(p)return p;let f=UM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(f)return f;let d=zM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(d)return d;let h=i!=null&&i.allReadonly?".readonly()":"";if(J1(e))return e.items?o.assign(`z.array(${Ue({...u,schema:e.items}).getCodeString(n,i)}${Dr({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({...u,schema:e.additionalProperties}).getCodeString(n,i)+Dr({schema:e.additionalProperties,meta:{...a,isRequired:!0},options:i})})`);let k=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(([Te,ee])=>{var Z;let M={...a,isRequired:C?!0:k?(Z=e.required)==null?void 0:Z.includes(Te):i==null?void 0:i.withImplicitRequiredProps,name:Te},R=ee;if($e(ee)&&t&&(R=t.getSchemaByRef(ee.$ref),!R))throw new Error(`Schema ${ee.$ref} not found`);let q=Ue({...u,schema:ee,meta:M}).getCodeString(n,i)+Dr({schema:R,meta:M,options:i});return[Te,q]}).map(([Te,ee])=>`${z1(Te)}: ${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 FM({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!$e(e)||!r)return;let a=t.meta.referencedBy.slice(0,-1).map(l=>(r==null?void 0:r.getZodSchemaNameByRef(l.ref))??l.ref),u=r.getZodSchemaNameByRef(e.$ref);if(a.length>1&&a.includes(u))return t.assign(r.getCodeByZodSchemaName(t.ref));let c=r.getCodeByZodSchemaName(e.$ref);if(!c){let l=r.getSchemaByRef(e.$ref);if(!l)throw new Error(`Schema ${e.$ref} not found`);c=Ue({schema:l,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)}return r.getCodeByZodSchemaName(u)||r.setZodSchema(u,c,i),t}s(FM,"getReferenceZodSchema");function VM({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){var u;if(!Jr(e)||!e.oneOf)return;if(e.oneOf.length===1){let c=Ue({schema:e.oneOf[0],resolver:r,meta:n,tag:i,options:o});return t.assign(c.getCodeString(i,o))}let a=(u=e.oneOf)==null?void 0:u.some(c=>Jr(c)&&((c==null?void 0:c.allOf)||[]).length>1);if(e.discriminator&&!a){let c=e.discriminator.propertyName;return t.assign(`
|
|
143
143
|
z.discriminatedUnion("${c}", [${e.oneOf.map(l=>Ue({schema:l,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)).join(", ")}])
|