@povio/openapi-codegen-cli 0.2.1 → 0.2.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/index.d.ts +1 -0
- package/dist/sh.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { GenerateMetadataParams } from "./generators/types/metadata";
|
|
2
2
|
export declare function getGenerateMetadata({ input, options: genOptions }: GenerateMetadataParams): Promise<import("./generators/types/metadata").GenerateMetadata>;
|
|
3
|
+
export { TsFieldDescriptor } from "./generators/types/generate";
|
|
3
4
|
export * from "./generators/types/metadata";
|
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(Hg,"stringEncaseCRLFWithFirstIndex");var{stdout:Ug,stderr:zg}=Vg,gl=Symbol("GENERATOR"),Mi=Symbol("STYLER"),Gs=Symbol("IS_EMPTY"),Gg=["ansi","ansi","ansi256","ansi16m"],Ti=Object.create(null),R$=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=Ug?Ug.level:0;e.level=t.level===void 0?r:t.level},"applyOptions"),bl=class bl{constructor(t){return Wg(t)}};s(bl,"Chalk");var Ra=bl,Wg=s(e=>{let t=s((...r)=>r.join(" "),"chalk");return R$(t,e),Object.setPrototypeOf(t,Ws.prototype),t},"chalkFactory");function Ws(e){return Wg(e)}s(Ws,"createChalk");Object.setPrototypeOf(Ws.prototype,Function.prototype);for(let[e,t]of Object.entries(ar))Ti[e]={get(){let r=ja(this,vl(t.open,t.close,this[Mi]),this[Gs]);return Object.defineProperty(this,e,{value:r}),r}};Ti.visible={get(){let e=ja(this,this[Mi],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var yl=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"?yl("rgb",t,r,...ar.hexToRgb(...n)):ar[r][e](...n),"getModelAnsi"),j$=["rgb","hex","ansi256"];for(let e of j$){Ti[e]={get(){let{level:r}=this;return function(...n){let i=vl(yl(e,Gg[r],"color",...n),ar.color.close,this[Mi]);return ja(this,i,this[Gs])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);Ti[t]={get(){let{level:r}=this;return function(...n){let i=vl(yl(e,Gg[r],"bgColor",...n),ar.bgColor.close,this[Mi]);return ja(this,i,this[Gs])}}}}var k$=Object.defineProperties(()=>{},{...Ti,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"),ja=s((e,t,r)=>{let n=s((...i)=>N$(n,i.length===1?""+i[0]:i.join(" ")),"builder");return Object.setPrototypeOf(n,k$),n[gl]=e,n[Mi]=t,n[Gs]=r,n},"createBuilder"),N$=s((e,t)=>{if(e.level<=0||!t)return e[Gs]?"":t;let r=e[Mi];if(r===void 0)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=Bg(t,r.close,r.open),r=r.parent;let o=t.indexOf(`
|
|
140
|
-
`);return o!==-1&&(t=Hg(t,i,n,o)),n+t+i},"applyStyle");Object.defineProperties(Ws.prototype,Ti);var LL=Ws(),FL=Ws({level:zg?zg.level:0});var Kn=new Ra;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 Ks(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(Ks,"logError");function Kg(e){console.log(Kn.bgYellow(`==== ${e} ====`))}s(Kg,"logBanner");var Zg=Et(require("fs"));function ka(){return"0.2.1"}s(ka,"getVersion");var XL=Et(Jg());var Pl=Symbol("options_key");function Hr(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(Hr,"YargOption");function Qg(e){let t=Reflect.getMetadata(Pl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}s(Qg,"getYargsOption");function Xg(e){return async t=>t.options(M$(e)).middleware(async r=>await T$(e,r),!0)}s(Xg,"getBuilder");function M$(e){return Object.entries(Qg(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}s(M$,"getYargsOptions");async function T$(e,t){let r=new e;for(let[n,i]of Object.entries(Qg(e)))r[n]=t[n]??i.default;return r}s(T$,"loadYargsConfig");var kw=Et(A1()),Nw=require("child_process");var C1="Schema",I1="Body",R1="Param",j1="Response",k1="ErrorResponse",dh="z.void()",Lu={bindings:["z"],from:"zod"};var N1={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:C1,additionalPropertiesDefaultValue:!1};var hh={"Content-Type":"application/json",Accept:"application/json"},M1="data";var T1=s(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),mh=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"),RM=Symbol.for("@ts-pattern/isVariadic"),Vu="@ts-pattern/anonymous-select-key",gh=s(e=>!!(e&&typeof e=="object"),"r"),Fu=s(e=>e&&!!e[Zr],"i"),qr=s((e,t,r)=>{if(Fu(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(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 u=e[a];Fu(u)&&u[RM]?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||Fu(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 gh(e)?Fu(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(()=>jM(e),"optional"),and:s(t=>Le(e,t),"and"),or:s(t=>kM(e,t),"or"),select:s(t=>t===void 0?q1(e):q1(t,e),"select")})}s(er,"u");function jM(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(jM,"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 kM(...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(kM,"d");function Pe(e){return{[Zr]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(Pe,"p");function q1(...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??Vu]:n};return{matched:r===void 0||qr(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??Vu].concat(r===void 0?[]:In(r)),"getSelectionKeys")})})}s(q1,"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 vV=er(Pe(function(e){return!0}));var An=s(e=>Object.assign(er(e),{startsWith:s(t=>{return An(Le(e,(r=t,Pe(n=>xn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return An(Le(e,(r=t,Pe(n=>xn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>An(Le(e,(r=>Pe(n=>xn(n)&&n.length>=r))(t))),"minLength"),length:s(t=>An(Le(e,(r=>Pe(n=>xn(n)&&n.length===r))(t))),"length"),maxLength:s(t=>An(Le(e,(r=>Pe(n=>xn(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return An(Le(e,(r=t,Pe(n=>xn(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return An(Le(e,(r=t,Pe(n=>xn(n)&&!!n.match(r)))));var r},"regex")}),"j"),bV=An(Pe(xn)),Tr=s(e=>Object.assign(er(e),{between:s((t,r)=>Tr(Le(e,((n,i)=>Pe(o=>Mr(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Tr(Le(e,(r=>Pe(n=>Mr(n)&&n<r))(t))),"lt"),gt:s(t=>Tr(Le(e,(r=>Pe(n=>Mr(n)&&n>r))(t))),"gt"),lte:s(t=>Tr(Le(e,(r=>Pe(n=>Mr(n)&&n<=r))(t))),"lte"),gte:s(t=>Tr(Le(e,(r=>Pe(n=>Mr(n)&&n>=r))(t))),"gte"),int:s(()=>Tr(Le(e,Pe(t=>Mr(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Tr(Le(e,Pe(t=>Mr(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Tr(Le(e,Pe(t=>Mr(t)&&t>0))),"positive"),negative:s(()=>Tr(Le(e,Pe(t=>Mr(t)&&t<0))),"negative")}),"x"),_V=Tr(Pe(Mr)),Cn=s(e=>Object.assign(er(e),{between:s((t,r)=>Cn(Le(e,((n,i)=>Pe(o=>En(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Cn(Le(e,(r=>Pe(n=>En(n)&&n<r))(t))),"lt"),gt:s(t=>Cn(Le(e,(r=>Pe(n=>En(n)&&n>r))(t))),"gt"),lte:s(t=>Cn(Le(e,(r=>Pe(n=>En(n)&&n<=r))(t))),"lte"),gte:s(t=>Cn(Le(e,(r=>Pe(n=>En(n)&&n>=r))(t))),"gte"),positive:s(()=>Cn(Le(e,Pe(t=>En(t)&&t>0))),"positive"),negative:s(()=>Cn(Le(e,Pe(t=>En(t)&&t<0))),"negative")}),"A"),SV=Cn(Pe(En)),PV=er(Pe(function(e){return typeof e=="boolean"})),wV=er(Pe(function(e){return typeof e=="symbol"})),$V=er(Pe(function(e){return e==null})),OV=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 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)?vh:{matched:!0,value:r(o?Vu in a?a[Vu]: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)}: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(Fo,"I");var bh=Fo;var Sh=2,D1=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],L1=["query","header","path"],Bu=["get","put","post","delete","options","head","patch","trace"],F1=["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"),V1=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),br=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),B1=s(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),H1=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),U1=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var z1=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Ho=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),Hu=s(e=>Ho(e).split("/").at(-1),"getSchemaNameByRef");function we(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s(we,"isReferenceObject");function G1(e){return NM(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/-+/g,"_").replace(/[^\w\-]+/g,"_").replace(/--+/g,"-")}s(G1,"normalizeString");function W1(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(W1,"wrapWithQuotesIfNeeded");function K1(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(K1,"unwrapQuotesIfNeeded");function NM(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(NM,"prefixStringStartingWithNumberIfNeeded");function wh(e){let t=e.replaceAll("_","#");return br(t.replaceAll("-","_")).replaceAll("#","_")}s(wh,"pathParamToVariableName");var gi=s(e=>F1.includes(e),"isPrimitiveType");function Z1(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(Z1,"escapeControlCharacters");function Ps(e){return e.includes("application/")&&e.includes("json")||D1.includes(e)||e.includes("text/")}s(Ps,"isParamMediaTypeAllowed");function $h(e){return e>=200&&e<300}s($h,"isMainResponseStatus");function Oh(e){return!(e>=200&&e<300)}s(Oh,"isErrorStatus");function Uu(e){return e==="application/json"}s(Uu,"isMediaTypeAllowed");function Y1(e,t,r){return r.operationId??t+qM(e)}s(Y1,"getOperationName");function yi(e){return B1(e)}s(yi,"formatTag");function zu(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return yi(r??t.defaultTag)}s(zu,"getOperationTag");var MM=/({\w+})/g,TM=/[^\w\-]+/g;function qM(e){return Yr(V1(e.replaceAll("/","-")).replaceAll("-","")).replace(MM,t=>Yr(t.slice(1,-1))).replace(TM,"_")}s(qM,"pathToVariableName");var Ph=/{(\b\w+(?:-\w+)*\b)}/g;function J1(e){let t=e.match(Ph);return t===null?e.replaceAll(Ph,":$1"):(t.forEach(r=>{let n=wh(r.replaceAll(Ph,":$1"));e=e.replaceAll(r,n)}),e)}s(J1,"replaceHyphenatedPath");function Jr(e){return!we(e)}s(Jr,"isSchemaObject");function Q1(e){return e.type==="array"}s(Q1,"isArraySchemaObject");function X1(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(DM(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(we(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(X1,"inferRequiredSchema");var DM=s(e=>!we(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function e2(e){return gt(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(e2,"primitiveTypeToTsType");var Rn=s((e,t)=>H1(Yr(G1(e)),t),"getZodSchemaName"),Lt=s(e=>!e.startsWith("z."),"isNamedZodSchema"),t2=s(e=>br(`${e}_${I1}`),"getBodyZodSchemaName"),r2=s((e,t)=>br(`${e}_${t}${R1}`),"getParamZodSchemaName"),n2=s(e=>br(`${e}${j1}`),"getMainResponseZodSchemaName"),i2=s((e,t)=>br(`${e}_${t}_${k1}`),"getErrorResponseZodSchemaName");function Gu({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(Gu,"getTagFileName");var Pt=s(({type:e,tag:t,options:r})=>`${Yr(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var Uo=s((e,t)=>U1(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),s2=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${Pt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${t}`:t,"getImportedZodSchemaName"),o2=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${Pt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${Uo(t,r)}`:t,"getImportedZodSchemaInferedTypeName");var zo=s(e=>Bo(br(e.operationName)),"getEndpointName");function a2(e,t){return`${t.includeNamespaces?`${Pt({type:"endpoints",tag:Go(e,t),options:t})}.`:""}${zo(e)}`}s(a2,"getImportedEndpointName");var u2=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=o2({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&&gi(l)&&(i=e2(l))}return{name:mh(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","Body","Query","Header"];return o.indexOf(n.paramType)-o.indexOf(i.paramType)}return n.required?-1:1})}s(xh,"mapEndpointParamsToFunctionParams");function c2(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let o=T1(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(c2,"getEndpointConfig");function Wu(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(Wu,"pick");function Dr({schema:e,meta:t,options:r}){let n=[];gt(e.type).with("string",()=>n.push(VM(e))).with("number","integer",()=>n.push(HM(e))).with("array",()=>n.push(UM(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
|
|
140
|
+
`);return o!==-1&&(t=Hg(t,i,n,o)),n+t+i},"applyStyle");Object.defineProperties(Ws.prototype,Ti);var LL=Ws(),FL=Ws({level:zg?zg.level:0});var Kn=new Ra;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 Ks(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(Ks,"logError");function Kg(e){console.log(Kn.bgYellow(`==== ${e} ====`))}s(Kg,"logBanner");var Zg=Et(require("fs"));function ka(){return"0.2.2"}s(ka,"getVersion");var XL=Et(Jg());var Pl=Symbol("options_key");function Hr(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(Hr,"YargOption");function Qg(e){let t=Reflect.getMetadata(Pl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}s(Qg,"getYargsOption");function Xg(e){return async t=>t.options(M$(e)).middleware(async r=>await T$(e,r),!0)}s(Xg,"getBuilder");function M$(e){return Object.entries(Qg(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}s(M$,"getYargsOptions");async function T$(e,t){let r=new e;for(let[n,i]of Object.entries(Qg(e)))r[n]=t[n]??i.default;return r}s(T$,"loadYargsConfig");var kw=Et(A1()),Nw=require("child_process");var C1="Schema",I1="Body",R1="Param",j1="Response",k1="ErrorResponse",dh="z.void()",Lu={bindings:["z"],from:"zod"};var N1={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:C1,additionalPropertiesDefaultValue:!1};var hh={"Content-Type":"application/json",Accept:"application/json"},M1="data";var T1=s(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),mh=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"),RM=Symbol.for("@ts-pattern/isVariadic"),Vu="@ts-pattern/anonymous-select-key",gh=s(e=>!!(e&&typeof e=="object"),"r"),Fu=s(e=>e&&!!e[Zr],"i"),qr=s((e,t,r)=>{if(Fu(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(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 u=e[a];Fu(u)&&u[RM]?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||Fu(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 gh(e)?Fu(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(()=>jM(e),"optional"),and:s(t=>Le(e,t),"and"),or:s(t=>kM(e,t),"or"),select:s(t=>t===void 0?q1(e):q1(t,e),"select")})}s(er,"u");function jM(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(jM,"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 kM(...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(kM,"d");function Pe(e){return{[Zr]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(Pe,"p");function q1(...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??Vu]:n};return{matched:r===void 0||qr(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??Vu].concat(r===void 0?[]:In(r)),"getSelectionKeys")})})}s(q1,"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 vV=er(Pe(function(e){return!0}));var An=s(e=>Object.assign(er(e),{startsWith:s(t=>{return An(Le(e,(r=t,Pe(n=>xn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return An(Le(e,(r=t,Pe(n=>xn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>An(Le(e,(r=>Pe(n=>xn(n)&&n.length>=r))(t))),"minLength"),length:s(t=>An(Le(e,(r=>Pe(n=>xn(n)&&n.length===r))(t))),"length"),maxLength:s(t=>An(Le(e,(r=>Pe(n=>xn(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return An(Le(e,(r=t,Pe(n=>xn(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return An(Le(e,(r=t,Pe(n=>xn(n)&&!!n.match(r)))));var r},"regex")}),"j"),bV=An(Pe(xn)),Tr=s(e=>Object.assign(er(e),{between:s((t,r)=>Tr(Le(e,((n,i)=>Pe(o=>Mr(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Tr(Le(e,(r=>Pe(n=>Mr(n)&&n<r))(t))),"lt"),gt:s(t=>Tr(Le(e,(r=>Pe(n=>Mr(n)&&n>r))(t))),"gt"),lte:s(t=>Tr(Le(e,(r=>Pe(n=>Mr(n)&&n<=r))(t))),"lte"),gte:s(t=>Tr(Le(e,(r=>Pe(n=>Mr(n)&&n>=r))(t))),"gte"),int:s(()=>Tr(Le(e,Pe(t=>Mr(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Tr(Le(e,Pe(t=>Mr(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Tr(Le(e,Pe(t=>Mr(t)&&t>0))),"positive"),negative:s(()=>Tr(Le(e,Pe(t=>Mr(t)&&t<0))),"negative")}),"x"),_V=Tr(Pe(Mr)),Cn=s(e=>Object.assign(er(e),{between:s((t,r)=>Cn(Le(e,((n,i)=>Pe(o=>En(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Cn(Le(e,(r=>Pe(n=>En(n)&&n<r))(t))),"lt"),gt:s(t=>Cn(Le(e,(r=>Pe(n=>En(n)&&n>r))(t))),"gt"),lte:s(t=>Cn(Le(e,(r=>Pe(n=>En(n)&&n<=r))(t))),"lte"),gte:s(t=>Cn(Le(e,(r=>Pe(n=>En(n)&&n>=r))(t))),"gte"),positive:s(()=>Cn(Le(e,Pe(t=>En(t)&&t>0))),"positive"),negative:s(()=>Cn(Le(e,Pe(t=>En(t)&&t<0))),"negative")}),"A"),SV=Cn(Pe(En)),PV=er(Pe(function(e){return typeof e=="boolean"})),wV=er(Pe(function(e){return typeof e=="symbol"})),$V=er(Pe(function(e){return e==null})),OV=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 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)?vh:{matched:!0,value:r(o?Vu in a?a[Vu]: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)}: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(Fo,"I");var bh=Fo;var Sh=2,D1=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],L1=["query","header","path"],Bu=["get","put","post","delete","options","head","patch","trace"],F1=["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"),V1=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),br=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),B1=s(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),H1=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),U1=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var z1=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Ho=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),Hu=s(e=>Ho(e).split("/").at(-1),"getSchemaNameByRef");function we(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s(we,"isReferenceObject");function G1(e){return NM(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/-+/g,"_").replace(/[^\w\-]+/g,"_").replace(/--+/g,"-")}s(G1,"normalizeString");function W1(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(W1,"wrapWithQuotesIfNeeded");function K1(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(K1,"unwrapQuotesIfNeeded");function NM(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(NM,"prefixStringStartingWithNumberIfNeeded");function wh(e){let t=e.replaceAll("_","#");return br(t.replaceAll("-","_")).replaceAll("#","_")}s(wh,"pathParamToVariableName");var gi=s(e=>F1.includes(e),"isPrimitiveType");function Z1(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(Z1,"escapeControlCharacters");function Ps(e){return e.includes("application/")&&e.includes("json")||D1.includes(e)||e.includes("text/")}s(Ps,"isParamMediaTypeAllowed");function $h(e){return e>=200&&e<300}s($h,"isMainResponseStatus");function Oh(e){return!(e>=200&&e<300)}s(Oh,"isErrorStatus");function Uu(e){return e==="application/json"}s(Uu,"isMediaTypeAllowed");function Y1(e,t,r){return r.operationId??t+qM(e)}s(Y1,"getOperationName");function yi(e){return B1(e)}s(yi,"formatTag");function zu(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return yi(r??t.defaultTag)}s(zu,"getOperationTag");var MM=/({\w+})/g,TM=/[^\w\-]+/g;function qM(e){return Yr(V1(e.replaceAll("/","-")).replaceAll("-","")).replace(MM,t=>Yr(t.slice(1,-1))).replace(TM,"_")}s(qM,"pathToVariableName");var Ph=/{(\b\w+(?:-\w+)*\b)}/g;function J1(e){let t=e.match(Ph);return t===null?e.replaceAll(Ph,":$1"):(t.forEach(r=>{let n=wh(r.replaceAll(Ph,":$1"));e=e.replaceAll(r,n)}),e)}s(J1,"replaceHyphenatedPath");function Jr(e){return!we(e)}s(Jr,"isSchemaObject");function Q1(e){return e.type==="array"}s(Q1,"isArraySchemaObject");function X1(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(DM(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(we(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(X1,"inferRequiredSchema");var DM=s(e=>!we(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function e2(e){return gt(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(e2,"primitiveTypeToTsType");var Rn=s((e,t)=>H1(Yr(G1(e)),t),"getZodSchemaName"),Lt=s(e=>!e.startsWith("z."),"isNamedZodSchema"),t2=s(e=>br(`${e}_${I1}`),"getBodyZodSchemaName"),r2=s((e,t)=>br(`${e}_${t}${R1}`),"getParamZodSchemaName"),n2=s(e=>br(`${e}${j1}`),"getMainResponseZodSchemaName"),i2=s((e,t)=>br(`${e}_${t}_${k1}`),"getErrorResponseZodSchemaName");function Gu({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(Gu,"getTagFileName");var Pt=s(({type:e,tag:t,options:r})=>`${Yr(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var Uo=s((e,t)=>U1(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),s2=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${Pt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${t}`:t,"getImportedZodSchemaName"),o2=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${Pt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${Uo(t,r)}`:t,"getImportedZodSchemaInferedTypeName");var zo=s(e=>Bo(br(e.operationName)),"getEndpointName");function a2(e,t){return`${t.includeNamespaces?`${Pt({type:"endpoints",tag:Go(e,t),options:t})}.`:""}${zo(e)}`}s(a2,"getImportedEndpointName");var u2=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=o2({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&&gi(l)&&(i=e2(l))}return{name:mh(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","Body","Query","Header"];return o.indexOf(n.paramType)-o.indexOf(i.paramType)}return n.required?-1:1})}s(xh,"mapEndpointParamsToFunctionParams");function c2(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let o=T1(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(c2,"getEndpointConfig");function Wu(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(Wu,"pick");function Dr({schema:e,meta:t,options:r}){let n=[];gt(e.type).with("string",()=>n.push(VM(e))).with("number","integer",()=>n.push(HM(e))).with("array",()=>n.push(UM(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(LM(e,t),(r==null?void 0:r.withDefaultValues)!==!1?FM(e):[]).filter(Boolean).join(".");return i?`.${i}`:""}s(Dr,"getZodChain");function LM(e,t){return e.nullable&&!(t!=null&&t.isRequired)?"nullish()":e.nullable?"nullable()":t!=null&&t.isRequired?"":"optional()"}s(LM,"getZodChainablePresence");function FM(e){return e.default!==void 0?`default(${gt(e.type).with("number","integer",()=>K1(e.default)).otherwise(()=>JSON.stringify(e.default))})`:""}s(FM,"getZodChainableDefault");function VM(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(${BM(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(VM,"getZodChainableStringValidations");function BM(e){return e.startsWith("/")&&e.endsWith("/")&&(e=e.slice(1,-1)),e=Z1(e),`/${e}/`}s(BM,"formatPatternIfNeeded");function HM(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(HM,"getZodChainableNumberValidations");function UM(e){let t=[];return e.minItems&&t.push(`min(${e.minItems})`),e.maxItems&&t.push(`max(${e.maxItems})`),t.join(".")}s(UM,"getZodChainableArrayValidations");var vi=s(e=>e.reduce((t,r)=>t+r,0),"sum");function rt({current:e,schema:t}){if(!t)return e;if(we(t))return e+2;if(Array.isArray(t.type))return t.type.length===1?wt("oneOf")+rt({current:e,schema:{...t,type:t.type[0]}}):e+wt("oneOf")+vi(t.type.map(r=>rt({current:0,schema:{...t,type:r}})));if(t.oneOf)return t.oneOf.length===1?wt("oneOf")+rt({current:e,schema:t.oneOf[0]}):e+wt("oneOf")+vi(t.oneOf.map(r=>rt({current:0,schema:r})));if(t.anyOf)return t.anyOf.length===1?wt("anyOf")+rt({current:e,schema:t.anyOf[0]}):e+wt("anyOf")+vi(t.anyOf.map(r=>rt({current:0,schema:r})));if(t.allOf)return t.allOf.length===1?wt("allOf")+rt({current:e,schema:t.allOf[0]}):e+wt("allOf")+vi(t.allOf.map(r=>rt({current:0,schema:r})));if(!t.type)return e;if(gi(t.type))return t.enum?e+l2(t)+wt("enum")+vi(t.enum.map(r=>rt({current:0,schema:r}))):e+l2(t);if(t.type==="array")return t.items?wt("array")+rt({current:e,schema:t.items}):wt("array")+rt({current:e,schema:void 0});if(t.type==="object"||t.properties||t.additionalProperties){if(t.additionalProperties)return t.additionalProperties===!0?wt("record")+rt({current:e,schema:void 0}):wt("record")+rt({current:e,schema:t.additionalProperties});if(t.properties){let r=Object.values(t.properties);return e+wt("object")+vi(r.map(n=>rt({current:0,schema:n})))}return wt("empty-object")+rt({current:e,schema:void 0})}return e}s(rt,"getOpenAPISchemaComplexity");function l2(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(l2,"complexityByType");function wt(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(wt,"complexityByComposite");var Eh=class Eh{constructor(t,r,n={referencedBy:[]}){this.schema=t;this.resolver=r;we(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(Eh,"ZodSchema");var Ku=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 Ku(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(we(e))return zM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});let c=WM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(c)return c;let l=GM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(l)return l;let p=KM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(p)return p;let f=ZM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(f)return f;let d=YM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(d)return d;let h=i!=null&&i.allReadonly?".readonly()":"";if(Q1(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(we(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])=>`${W1(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 zM({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!we(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(zM,"getReferenceZodSchema");function GM({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(", ")}])
|