@povio/openapi-codegen-cli 0.0.9 → 0.0.10
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/README.md +3 -3
- package/dist/sh.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ The tool partially leverages code from [openapi-zod-client](https://github.com/a
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
yarn add @
|
|
12
|
+
yarn add @povio/openapi-codegen-cli
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Example
|
|
@@ -47,12 +47,12 @@ yarn test
|
|
|
47
47
|
|
|
48
48
|
# run sources with tsx
|
|
49
49
|
yarn start --help
|
|
50
|
-
yarn start generate --input ./test/
|
|
50
|
+
yarn start generate --input ./test/petstore.yaml --verbose
|
|
51
51
|
|
|
52
52
|
# build new version
|
|
53
53
|
yarn build
|
|
54
54
|
|
|
55
55
|
# test build
|
|
56
56
|
yarn start --help
|
|
57
|
-
yarn start:dist generate --input ./test/
|
|
57
|
+
yarn start:dist generate --input ./test/petstore.yaml --verbose
|
|
58
58
|
```
|
package/dist/sh.js
CHANGED
|
@@ -138,7 +138,7 @@ ${y.join(`
|
|
|
138
138
|
`:`
|
|
139
139
|
`)+r,i=n+1,n=e.indexOf(`
|
|
140
140
|
`,i)}while(n!==-1);return o+=e.slice(i),o}s(xg,"stringEncaseCRLFWithFirstIndex");var{stdout:Ag,stderr:Cg}=Og,al=Symbol("GENERATOR"),Ri=Symbol("STYLER"),Vs=Symbol("IS_EMPTY"),Ig=["ansi","ansi","ansi256","ansi16m"],ji=Object.create(null),CP=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=Ag?Ag.level:0;e.level=t.level===void 0?r:t.level},"applyOptions"),ll=class ll{constructor(t){return Rg(t)}};s(ll,"Chalk");var $a=ll,Rg=s(e=>{let t=s((...r)=>r.join(" "),"chalk");return CP(t,e),Object.setPrototypeOf(t,Hs.prototype),t},"chalkFactory");function Hs(e){return Rg(e)}s(Hs,"createChalk");Object.setPrototypeOf(Hs.prototype,Function.prototype);for(let[e,t]of Object.entries(or))ji[e]={get(){let r=Pa(this,cl(t.open,t.close,this[Ri]),this[Vs]);return Object.defineProperty(this,e,{value:r}),r}};ji.visible={get(){let e=Pa(this,this[Ri],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var ul=s((e,t,r,...n)=>e==="rgb"?t==="ansi16m"?or[r].ansi16m(...n):t==="ansi256"?or[r].ansi256(or.rgbToAnsi256(...n)):or[r].ansi(or.rgbToAnsi(...n)):e==="hex"?ul("rgb",t,r,...or.hexToRgb(...n)):or[r][e](...n),"getModelAnsi"),IP=["rgb","hex","ansi256"];for(let e of IP){ji[e]={get(){let{level:r}=this;return function(...n){let i=cl(ul(e,Ig[r],"color",...n),or.color.close,this[Ri]);return Pa(this,i,this[Vs])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);ji[t]={get(){let{level:r}=this;return function(...n){let i=cl(ul(e,Ig[r],"bgColor",...n),or.bgColor.close,this[Ri]);return Pa(this,i,this[Vs])}}}}var RP=Object.defineProperties(()=>{},{...ji,level:{enumerable:!0,get(){return this[al].level},set(e){this[al].level=e}}}),cl=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"),Pa=s((e,t,r)=>{let n=s((...i)=>jP(n,i.length===1?""+i[0]:i.join(" ")),"builder");return Object.setPrototypeOf(n,RP),n[al]=e,n[Ri]=t,n[Vs]=r,n},"createBuilder"),jP=s((e,t)=>{if(e.level<=0||!t)return e[Vs]?"":t;let r=e[Ri];if(r===void 0)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=Eg(t,r.close,r.open),r=r.parent;let o=t.indexOf(`
|
|
141
|
-
`);return o!==-1&&(t=xg(t,i,n,o)),n+t+i},"applyStyle");Object.defineProperties(Hs.prototype,ji);var r5=Hs(),n5=Hs({level:Cg?Cg.level:0});var Zn=new $a;function fl(e,t,r){console.log(r!==void 0&&r!==t?`${Zn.yellow(`${e}:`.padEnd(20))}${Zn.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}s(fl,"logVariable");function ki(e){console.log(`[INFO] ${e}`)}s(ki,"logInfo");function pl(e){console.log(Zn.green(`[SUCCESS] ${e}`))}s(pl,"logSuccess");function Us(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(Us,"logError");function jg(e){console.log(Zn.bgYellow(`==== ${e} ====`))}s(jg,"logBanner");import kP from"fs";function Oa(){return"0.0.9"}s(Oa,"getVersion");var y5=tn(Ng(),1);var dl=Symbol("options_key");function Vr(e){return(t,r)=>{var n,i;if(e!=null){let o={...Reflect.getMetadata(dl,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(dl,o,t)}}}s(Vr,"YargOption");function Mg(e){let t=Reflect.getMetadata(dl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}s(Mg,"getYargsOption");function Tg(e){return async t=>t.options(NP(e)).middleware(async r=>await MP(e,r),!0)}s(Tg,"getBuilder");function NP(e){return Object.entries(Mg(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}s(NP,"getYargsOptions");async function MP(e,t){let r=new e;for(let[n,i]of Object.entries(Mg(e)))r[n]=t[n]??i.default;return r}s(MP,"loadYargsConfig");var p$=tn(fS(),1);import{exec as f8}from"child_process";var pS="Schema",dS="Body",hS="Param",mS="Response",gS="ErrorResponse",ih="z.void()",Ru={bindings:["z"],from:"zod"};var yS={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:pS,additionalPropertiesDefaultValue:!1};var sh={"Content-Type":"application/json",Accept:"application/json"},oh="AppRestClient",vS={bindings:[oh],from:"@/util/rest/clients/app-rest-client"};var Kr=Symbol.for("@ts-pattern/matcher"),IM=Symbol.for("@ts-pattern/isVariadic"),ku="@ts-pattern/anonymous-select-key",ah=s(e=>!!(e&&typeof e=="object"),"r"),ju=s(e=>e&&!!e[Kr],"i"),Tr=s((e,t,r)=>{if(ju(e)){let n=e[Kr](),{matched:i,selections:o}=n.match(t);return i&&o&&Object.keys(o).forEach(a=>r(a,o[a])),i}if(ah(e)){if(!ah(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];ju(u)&&u[IM]?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)=>Tr(l,a[p],r))&&i.every((l,p)=>Tr(l,u[p],r))&&(o.length===0||Tr(o[0],c,r))}return e.length===t.length&&e.every((a,u)=>Tr(a,t[u],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||ju(o=i)&&o[Kr]().matcherType==="optional")&&Tr(i,t[n],r);var o})}return Object.is(t,e)},"s"),In=s(e=>{var t,r,n;return ah(e)?ju(e)?(t=(r=(n=e[Kr]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?qo(e,In):qo(Object.values(e),In):[]},"o"),qo=s((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function er(e){return Object.assign(e,{optional:s(()=>RM(e),"optional"),and:s(t=>Le(e,t),"and"),or:s(t=>jM(e,t),"or"),select:s(t=>t===void 0?bS(e):bS(t,e),"select")})}s(er,"u");function RM(e){return er({[Kr]:()=>({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:Tr(e,t,n),selections:r}},"match"),getSelectionKeys:s(()=>In(e),"getSelectionKeys"),matcherType:"optional"})})}s(RM,"h");function Le(...e){return er({[Kr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return{matched:e.every(i=>Tr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>qo(e,In),"getSelectionKeys"),matcherType:"and"})})}s(Le,"m");function jM(...e){return er({[Kr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return qo(e,In).forEach(i=>n(i,void 0)),{matched:e.some(i=>Tr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>qo(e,In),"getSelectionKeys"),matcherType:"or"})})}s(jM,"d");function we(e){return{[Kr]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(we,"p");function bS(...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({[Kr]:()=>({match:s(n=>{let i={[t??ku]:n};return{matched:r===void 0||Tr(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??ku].concat(r===void 0?[]:In(r)),"getSelectionKeys")})})}s(bS,"y");function Nr(e){return typeof e=="number"}s(Nr,"v");function En(e){return typeof e=="string"}s(En,"b");function xn(e){return typeof e=="bigint"}s(xn,"w");var NB=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=>En(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return An(Le(e,(r=t,we(n=>En(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>An(Le(e,(r=>we(n=>En(n)&&n.length>=r))(t))),"minLength"),length:s(t=>An(Le(e,(r=>we(n=>En(n)&&n.length===r))(t))),"length"),maxLength:s(t=>An(Le(e,(r=>we(n=>En(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return An(Le(e,(r=t,we(n=>En(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return An(Le(e,(r=t,we(n=>En(n)&&!!n.match(r)))));var r},"regex")}),"j"),MB=An(we(En)),Mr=s(e=>Object.assign(er(e),{between:s((t,r)=>Mr(Le(e,((n,i)=>we(o=>Nr(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Mr(Le(e,(r=>we(n=>Nr(n)&&n<r))(t))),"lt"),gt:s(t=>Mr(Le(e,(r=>we(n=>Nr(n)&&n>r))(t))),"gt"),lte:s(t=>Mr(Le(e,(r=>we(n=>Nr(n)&&n<=r))(t))),"lte"),gte:s(t=>Mr(Le(e,(r=>we(n=>Nr(n)&&n>=r))(t))),"gte"),int:s(()=>Mr(Le(e,we(t=>Nr(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Mr(Le(e,we(t=>Nr(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Mr(Le(e,we(t=>Nr(t)&&t>0))),"positive"),negative:s(()=>Mr(Le(e,we(t=>Nr(t)&&t<0))),"negative")}),"x"),TB=Mr(we(Nr)),Cn=s(e=>Object.assign(er(e),{between:s((t,r)=>Cn(Le(e,((n,i)=>we(o=>xn(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Cn(Le(e,(r=>we(n=>xn(n)&&n<r))(t))),"lt"),gt:s(t=>Cn(Le(e,(r=>we(n=>xn(n)&&n>r))(t))),"gt"),lte:s(t=>Cn(Le(e,(r=>we(n=>xn(n)&&n<=r))(t))),"lte"),gte:s(t=>Cn(Le(e,(r=>we(n=>xn(n)&&n>=r))(t))),"gte"),positive:s(()=>Cn(Le(e,we(t=>xn(t)&&t>0))),"positive"),negative:s(()=>Cn(Le(e,we(t=>xn(t)&&t<0))),"negative")}),"A"),qB=Cn(we(xn)),DB=er(we(function(e){return typeof e=="boolean"})),LB=er(we(function(e){return typeof e=="symbol"})),FB=er(we(function(e){return e==null})),BB=er(we(function(e){return e!=null}));var fh=class fh 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(fh,"W");var uh=fh,ch={matched:!1,value:void 0};function St(e){return new lh(e,ch)}s(St,"z");var To=class To{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=>Tr(l,this.input,u))||i&&!i(this.input)?ch:{matched:!0,value:r(o?ku in a?a[ku]:a:this.input,this.input)};return new To(this.input,c)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new To(this.input,n?{matched:!0,value:r(this.input,this.input)}:ch)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new uh(this.input)}run(){return this.exhaustive()}returnType(){return this}};s(To,"I");var lh=To;var ph=2,_S=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],SS=["query","header","path"],Nu=["get","put","post","delete","options","head","patch","trace"],wS=["string","number","integer","boolean"];var Zr=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),Do=s(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),$S=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),vr=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),PS=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),OS=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var ES=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Lo=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),hh=s(e=>Lo(e).split("/").at(-1),"getSchemaNameByRef");function $e(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s($e,"isReferenceObject");function xS(e){return kM(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/-+/g,"_").replace(/[^\w\-]+/g,"_").replace(/--+/g,"-")}s(xS,"normalizeString");function AS(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(AS,"wrapWithQuotesIfNeeded");function CS(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(CS,"unwrapQuotesIfNeeded");function kM(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(kM,"prefixStringStartingWithNumberIfNeeded");function mh(e){let t=e.replaceAll("_","#");return vr(t.replaceAll("-","_")).replaceAll("#","_")}s(mh,"pathParamToVariableName");var vs=s(e=>wS.includes(e),"isPrimitiveType");function IS(e){return St(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(IS,"primitiveTypeToTsType");function RS(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(RS,"escapeControlCharacters");function bs(e){return e.includes("application/")&&e.includes("json")||_S.includes(e)||e.includes("text/")}s(bs,"isParamMediaTypeAllowed");function gh(e){return e>=200&&e<300}s(gh,"isMainResponseStatus");function yh(e){return!(e>=200&&e<300)}s(yh,"isErrorStatus");function Mu(e){return e==="application/json"}s(Mu,"isMediaTypeAllowed");function jS(e,t,r){return r.operationId??t+TM(e)}s(jS,"getOperationName");function Tu(e,t){var r;return((r=e.tags)==null?void 0:r[0])??t.defaultTag}s(Tu,"getOperationTag");var NM=/({\w+})/g,MM=/[^\w\-]+/g;function TM(e){return Zr($S(e.replaceAll("/","-")).replaceAll("-","")).replace(NM,t=>Zr(t.slice(1,-1))).replace(MM,"_")}s(TM,"pathToVariableName");var dh=/{(\b\w+(?:-\w+)*\b)}/g;function kS(e){let t=e.match(dh);return t===null?e.replaceAll(dh,":$1"):(t.forEach(r=>{let n=mh(r.replaceAll(dh,":$1"));e=e.replaceAll(r,n)}),e)}s(kS,"replaceHyphenatedPath");function Yr(e){return!$e(e)}s(Yr,"isSchemaObject");function NS(e){return e.type==="array"}s(NS,"isArraySchemaObject");function MS(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(qM(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(MS,"inferRequiredSchema");var qM=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)=>PS(Zr(xS(e)),t),"getZodSchemaName"),Lt=s(e=>!e.startsWith("z."),"isNamedZodSchema"),TS=s(e=>vr(`${e}_${dS}`),"getBodyZodSchemaName"),qS=s((e,t)=>vr(`${e}_${t}${hS}`),"getParamZodSchemaName"),DS=s(e=>vr(`${e}${mS}`),"getMainResponseZodSchemaName"),LS=s((e,t)=>vr(`${e}_${t}_${gS}`),"getErrorResponseZodSchemaName");function qu({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${Do(t)}/`:""}${Do(t)}.${i}`:i}s(qu,"getTagFileName");var wt=s(({type:e,tag:t,options:r})=>`${Zr(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var Fo=s((e,t)=>OS(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),FS=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${wt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${t}`:t,"getImportedZodSchemaName"),BS=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${wt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${Fo(t,r)}`:t,"getImportedZodSchemaInferedTypeName");var Bo=s(e=>Do(vr(e.operationName)),"getEndpointName");function VS(e,t){return`${t.includeNamespaces?`${wt({type:"endpoints",tag:Vo(e,t),options:t})}.`:""}${Bo(e)}`}s(VS,"getImportedEndpointName");var HS=s(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function Vo(e,t){var r;return t.splitByTags?((r=e.tags)==null?void 0:r[0])??t.defaultTag:t.defaultTag}s(Vo,"getEndpointTag");function vh({resolver:e,endpoint:t,options:r}){return t.parameters.map(n=>{var o,a,u,c;let i="string";if(Lt(n.zodSchema))i=BS({resolver:e,zodSchemaName:n.zodSchema,options:r});else if((o=n.parameterObject)!=null&&o.schema&&Yr(n.parameterObject.schema)){let l=(u=(a=n.parameterObject)==null?void 0:a.schema)==null?void 0:u.type;l&&vs(l)&&(i=IS(l))}return{name: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(vh,"mapEndpointParamsToFunctionParams");function US(e){let t=e.parameters.filter(i=>i.type==="Query"),r={...e.requestFormat!==sh["Content-Type"]?{"Content-Type":e.requestFormat}:{},...e.responseFormat&&e.responseFormat!==sh.Accept?{Accept:e.responseFormat}:{}};return{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}s(US,"getEndpointConfig");function Du(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(Du,"pick");function qr({schema:e,meta:t,options:r}){let n=[];St(e.type).with("string",()=>n.push(FM(e))).with("number","integer",()=>n.push(VM(e))).with("array",()=>n.push(HM(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
|
|
141
|
+
`);return o!==-1&&(t=xg(t,i,n,o)),n+t+i},"applyStyle");Object.defineProperties(Hs.prototype,ji);var r5=Hs(),n5=Hs({level:Cg?Cg.level:0});var Zn=new $a;function fl(e,t,r){console.log(r!==void 0&&r!==t?`${Zn.yellow(`${e}:`.padEnd(20))}${Zn.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}s(fl,"logVariable");function ki(e){console.log(`[INFO] ${e}`)}s(ki,"logInfo");function pl(e){console.log(Zn.green(`[SUCCESS] ${e}`))}s(pl,"logSuccess");function Us(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(Us,"logError");function jg(e){console.log(Zn.bgYellow(`==== ${e} ====`))}s(jg,"logBanner");import kP from"fs";function Oa(){return"0.0.10"}s(Oa,"getVersion");var y5=tn(Ng(),1);var dl=Symbol("options_key");function Vr(e){return(t,r)=>{var n,i;if(e!=null){let o={...Reflect.getMetadata(dl,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(dl,o,t)}}}s(Vr,"YargOption");function Mg(e){let t=Reflect.getMetadata(dl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}s(Mg,"getYargsOption");function Tg(e){return async t=>t.options(NP(e)).middleware(async r=>await MP(e,r),!0)}s(Tg,"getBuilder");function NP(e){return Object.entries(Mg(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}s(NP,"getYargsOptions");async function MP(e,t){let r=new e;for(let[n,i]of Object.entries(Mg(e)))r[n]=t[n]??i.default;return r}s(MP,"loadYargsConfig");var p$=tn(fS(),1);import{exec as f8}from"child_process";var pS="Schema",dS="Body",hS="Param",mS="Response",gS="ErrorResponse",ih="z.void()",Ru={bindings:["z"],from:"zod"};var yS={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:pS,additionalPropertiesDefaultValue:!1};var sh={"Content-Type":"application/json",Accept:"application/json"},oh="AppRestClient",vS={bindings:[oh],from:"@/util/rest/clients/app-rest-client"};var Kr=Symbol.for("@ts-pattern/matcher"),IM=Symbol.for("@ts-pattern/isVariadic"),ku="@ts-pattern/anonymous-select-key",ah=s(e=>!!(e&&typeof e=="object"),"r"),ju=s(e=>e&&!!e[Kr],"i"),Tr=s((e,t,r)=>{if(ju(e)){let n=e[Kr](),{matched:i,selections:o}=n.match(t);return i&&o&&Object.keys(o).forEach(a=>r(a,o[a])),i}if(ah(e)){if(!ah(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];ju(u)&&u[IM]?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)=>Tr(l,a[p],r))&&i.every((l,p)=>Tr(l,u[p],r))&&(o.length===0||Tr(o[0],c,r))}return e.length===t.length&&e.every((a,u)=>Tr(a,t[u],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||ju(o=i)&&o[Kr]().matcherType==="optional")&&Tr(i,t[n],r);var o})}return Object.is(t,e)},"s"),In=s(e=>{var t,r,n;return ah(e)?ju(e)?(t=(r=(n=e[Kr]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?qo(e,In):qo(Object.values(e),In):[]},"o"),qo=s((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function er(e){return Object.assign(e,{optional:s(()=>RM(e),"optional"),and:s(t=>Le(e,t),"and"),or:s(t=>jM(e,t),"or"),select:s(t=>t===void 0?bS(e):bS(t,e),"select")})}s(er,"u");function RM(e){return er({[Kr]:()=>({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:Tr(e,t,n),selections:r}},"match"),getSelectionKeys:s(()=>In(e),"getSelectionKeys"),matcherType:"optional"})})}s(RM,"h");function Le(...e){return er({[Kr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return{matched:e.every(i=>Tr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>qo(e,In),"getSelectionKeys"),matcherType:"and"})})}s(Le,"m");function jM(...e){return er({[Kr]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return qo(e,In).forEach(i=>n(i,void 0)),{matched:e.some(i=>Tr(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>qo(e,In),"getSelectionKeys"),matcherType:"or"})})}s(jM,"d");function we(e){return{[Kr]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(we,"p");function bS(...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({[Kr]:()=>({match:s(n=>{let i={[t??ku]:n};return{matched:r===void 0||Tr(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??ku].concat(r===void 0?[]:In(r)),"getSelectionKeys")})})}s(bS,"y");function Nr(e){return typeof e=="number"}s(Nr,"v");function En(e){return typeof e=="string"}s(En,"b");function xn(e){return typeof e=="bigint"}s(xn,"w");var NB=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=>En(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return An(Le(e,(r=t,we(n=>En(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>An(Le(e,(r=>we(n=>En(n)&&n.length>=r))(t))),"minLength"),length:s(t=>An(Le(e,(r=>we(n=>En(n)&&n.length===r))(t))),"length"),maxLength:s(t=>An(Le(e,(r=>we(n=>En(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return An(Le(e,(r=t,we(n=>En(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return An(Le(e,(r=t,we(n=>En(n)&&!!n.match(r)))));var r},"regex")}),"j"),MB=An(we(En)),Mr=s(e=>Object.assign(er(e),{between:s((t,r)=>Mr(Le(e,((n,i)=>we(o=>Nr(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Mr(Le(e,(r=>we(n=>Nr(n)&&n<r))(t))),"lt"),gt:s(t=>Mr(Le(e,(r=>we(n=>Nr(n)&&n>r))(t))),"gt"),lte:s(t=>Mr(Le(e,(r=>we(n=>Nr(n)&&n<=r))(t))),"lte"),gte:s(t=>Mr(Le(e,(r=>we(n=>Nr(n)&&n>=r))(t))),"gte"),int:s(()=>Mr(Le(e,we(t=>Nr(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Mr(Le(e,we(t=>Nr(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Mr(Le(e,we(t=>Nr(t)&&t>0))),"positive"),negative:s(()=>Mr(Le(e,we(t=>Nr(t)&&t<0))),"negative")}),"x"),TB=Mr(we(Nr)),Cn=s(e=>Object.assign(er(e),{between:s((t,r)=>Cn(Le(e,((n,i)=>we(o=>xn(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Cn(Le(e,(r=>we(n=>xn(n)&&n<r))(t))),"lt"),gt:s(t=>Cn(Le(e,(r=>we(n=>xn(n)&&n>r))(t))),"gt"),lte:s(t=>Cn(Le(e,(r=>we(n=>xn(n)&&n<=r))(t))),"lte"),gte:s(t=>Cn(Le(e,(r=>we(n=>xn(n)&&n>=r))(t))),"gte"),positive:s(()=>Cn(Le(e,we(t=>xn(t)&&t>0))),"positive"),negative:s(()=>Cn(Le(e,we(t=>xn(t)&&t<0))),"negative")}),"A"),qB=Cn(we(xn)),DB=er(we(function(e){return typeof e=="boolean"})),LB=er(we(function(e){return typeof e=="symbol"})),FB=er(we(function(e){return e==null})),BB=er(we(function(e){return e!=null}));var fh=class fh 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(fh,"W");var uh=fh,ch={matched:!1,value:void 0};function St(e){return new lh(e,ch)}s(St,"z");var To=class To{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=>Tr(l,this.input,u))||i&&!i(this.input)?ch:{matched:!0,value:r(o?ku in a?a[ku]:a:this.input,this.input)};return new To(this.input,c)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new To(this.input,n?{matched:!0,value:r(this.input,this.input)}:ch)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new uh(this.input)}run(){return this.exhaustive()}returnType(){return this}};s(To,"I");var lh=To;var ph=2,_S=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],SS=["query","header","path"],Nu=["get","put","post","delete","options","head","patch","trace"],wS=["string","number","integer","boolean"];var Zr=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),Do=s(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),$S=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),vr=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),PS=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),OS=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var ES=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Lo=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),hh=s(e=>Lo(e).split("/").at(-1),"getSchemaNameByRef");function $e(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s($e,"isReferenceObject");function xS(e){return kM(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/-+/g,"_").replace(/[^\w\-]+/g,"_").replace(/--+/g,"-")}s(xS,"normalizeString");function AS(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(AS,"wrapWithQuotesIfNeeded");function CS(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(CS,"unwrapQuotesIfNeeded");function kM(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(kM,"prefixStringStartingWithNumberIfNeeded");function mh(e){let t=e.replaceAll("_","#");return vr(t.replaceAll("-","_")).replaceAll("#","_")}s(mh,"pathParamToVariableName");var vs=s(e=>wS.includes(e),"isPrimitiveType");function IS(e){return St(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(IS,"primitiveTypeToTsType");function RS(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(RS,"escapeControlCharacters");function bs(e){return e.includes("application/")&&e.includes("json")||_S.includes(e)||e.includes("text/")}s(bs,"isParamMediaTypeAllowed");function gh(e){return e>=200&&e<300}s(gh,"isMainResponseStatus");function yh(e){return!(e>=200&&e<300)}s(yh,"isErrorStatus");function Mu(e){return e==="application/json"}s(Mu,"isMediaTypeAllowed");function jS(e,t,r){return r.operationId??t+TM(e)}s(jS,"getOperationName");function Tu(e,t){var r;return((r=e.tags)==null?void 0:r[0])??t.defaultTag}s(Tu,"getOperationTag");var NM=/({\w+})/g,MM=/[^\w\-]+/g;function TM(e){return Zr($S(e.replaceAll("/","-")).replaceAll("-","")).replace(NM,t=>Zr(t.slice(1,-1))).replace(MM,"_")}s(TM,"pathToVariableName");var dh=/{(\b\w+(?:-\w+)*\b)}/g;function kS(e){let t=e.match(dh);return t===null?e.replaceAll(dh,":$1"):(t.forEach(r=>{let n=mh(r.replaceAll(dh,":$1"));e=e.replaceAll(r,n)}),e)}s(kS,"replaceHyphenatedPath");function Yr(e){return!$e(e)}s(Yr,"isSchemaObject");function NS(e){return e.type==="array"}s(NS,"isArraySchemaObject");function MS(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(qM(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(MS,"inferRequiredSchema");var qM=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)=>PS(Zr(xS(e)),t),"getZodSchemaName"),Lt=s(e=>!e.startsWith("z."),"isNamedZodSchema"),TS=s(e=>vr(`${e}_${dS}`),"getBodyZodSchemaName"),qS=s((e,t)=>vr(`${e}_${t}${hS}`),"getParamZodSchemaName"),DS=s(e=>vr(`${e}${mS}`),"getMainResponseZodSchemaName"),LS=s((e,t)=>vr(`${e}_${t}_${gS}`),"getErrorResponseZodSchemaName");function qu({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${Do(t)}/`:""}${Do(t)}.${i}`:i}s(qu,"getTagFileName");var wt=s(({type:e,tag:t,options:r})=>`${Zr(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var Fo=s((e,t)=>OS(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),FS=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${wt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${t}`:t,"getImportedZodSchemaName"),BS=s(({resolver:e,zodSchemaName:t,options:r})=>Lt(t)?`${r.includeNamespaces?`${wt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${Fo(t,r)}`:t,"getImportedZodSchemaInferedTypeName");var Bo=s(e=>Do(vr(e.operationName)),"getEndpointName");function VS(e,t){return`${t.includeNamespaces?`${wt({type:"endpoints",tag:Vo(e,t),options:t})}.`:""}${Bo(e)}`}s(VS,"getImportedEndpointName");var HS=s(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function Vo(e,t){var r;return t.splitByTags?((r=e.tags)==null?void 0:r[0])??t.defaultTag:t.defaultTag}s(Vo,"getEndpointTag");function vh({resolver:e,endpoint:t,options:r}){return t.parameters.map(n=>{var o,a,u,c;let i="string";if(Lt(n.zodSchema))i=BS({resolver:e,zodSchemaName:n.zodSchema,options:r});else if((o=n.parameterObject)!=null&&o.schema&&Yr(n.parameterObject.schema)){let l=(u=(a=n.parameterObject)==null?void 0:a.schema)==null?void 0:u.type;l&&vs(l)&&(i=IS(l))}return{name: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(vh,"mapEndpointParamsToFunctionParams");function US(e){let t=e.parameters.filter(i=>i.type==="Query"),r={...e.requestFormat!==sh["Content-Type"]?{"Content-Type":e.requestFormat}:{},...e.responseFormat&&e.responseFormat!==sh.Accept?{Accept:e.responseFormat}:{}};return{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}s(US,"getEndpointConfig");function Du(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(Du,"pick");function qr({schema:e,meta:t,options:r}){let n=[];St(e.type).with("string",()=>n.push(FM(e))).with("number","integer",()=>n.push(VM(e))).with("array",()=>n.push(HM(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
|
|
142
142
|
`,"\r",`\r
|
|
143
143
|
`].some(o=>String.prototype.includes.call(e.description,o))?n.push(`describe(\`${e.description}\`)`):n.push(`describe("${e.description}")`));let i=n.concat(DM(e,t),(r==null?void 0:r.withDefaultValues)!==!1?LM(e):[]).filter(Boolean).join(".");return i?`.${i}`:""}s(qr,"getZodChain");function DM(e,t){return e.nullable&&!(t!=null&&t.isRequired)?"nullish()":e.nullable?"nullable()":t!=null&&t.isRequired?"":"optional()"}s(DM,"getZodChainablePresence");function LM(e){return e.default!==void 0?`default(${St(e.type).with("number","integer",()=>CS(e.default)).otherwise(()=>JSON.stringify(e.default))})`:""}s(LM,"getZodChainableDefault");function FM(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=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(FM,"getZodChainableStringValidations");function BM(e){return e.startsWith("/")&&e.endsWith("/")&&(e=e.slice(1,-1)),e=RS(e),`/${e}/`}s(BM,"formatPatternIfNeeded");function VM(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(VM,"getZodChainableNumberValidations");function HM(e){let t=[];return e.minItems&&t.push(`min(${e.minItems})`),e.maxItems&&t.push(`max(${e.maxItems})`),t.join(".")}s(HM,"getZodChainableArrayValidations");var yi=s(e=>e.reduce((t,r)=>t+r,0),"sum");function nt({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")+nt({current:e,schema:{...t,type:t.type[0]}}):e+$t("oneOf")+yi(t.type.map(r=>nt({current:0,schema:{...t,type:r}})));if(t.oneOf)return t.oneOf.length===1?$t("oneOf")+nt({current:e,schema:t.oneOf[0]}):e+$t("oneOf")+yi(t.oneOf.map(r=>nt({current:0,schema:r})));if(t.anyOf)return t.anyOf.length===1?$t("anyOf")+nt({current:e,schema:t.anyOf[0]}):e+$t("anyOf")+yi(t.anyOf.map(r=>nt({current:0,schema:r})));if(t.allOf)return t.allOf.length===1?$t("allOf")+nt({current:e,schema:t.allOf[0]}):e+$t("allOf")+yi(t.allOf.map(r=>nt({current:0,schema:r})));if(!t.type)return e;if(vs(t.type))return t.enum?e+GS(t)+$t("enum")+yi(t.enum.map(r=>nt({current:0,schema:r}))):e+GS(t);if(t.type==="array")return t.items?$t("array")+nt({current:e,schema:t.items}):$t("array")+nt({current:e,schema:void 0});if(t.type==="object"||t.properties||t.additionalProperties){if(t.additionalProperties)return t.additionalProperties===!0?$t("record")+nt({current:e,schema:void 0}):$t("record")+nt({current:e,schema:t.additionalProperties});if(t.properties){let r=Object.values(t.properties);return e+$t("object")+yi(r.map(n=>nt({current:0,schema:n})))}return $t("empty-object")+nt({current:e,schema:void 0})}return e}s(nt,"getOpenAPISchemaComplexity");function GS(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(GS,"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 bh=class bh{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!==t?`${wt({type:"models",tag:i,options:r})}.${n}`:n}get complexity(){return nt({current:0,schema:this.schema})}assign(t){return this.code=t,this}inherit(t){return t&&t.children.push(this),this}};s(bh,"ZodSchema");var Lu=bh;function Ge({schema:e,resolver:t,meta:r,tag:n,options:i}){var v;if(!e)throw new Error("Schema is required");let o=new Lu(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 UM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});let c=zM({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=WM({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(p)return p;let f=KM({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(NS(e))return e.items?o.assign(`z.array(${Ge({...u,schema:e.items}).getCodeString(n,i)}${qr({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,C=(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(${Ge({...u,schema:e.additionalProperties}).getCodeString(n,i)+qr({schema:e.additionalProperties,meta:{...a,isRequired:!0},options:i})})`);let k=e.required&&e.required.length>0,A=i!=null&&i.withImplicitRequiredProps?!1:!((v=e.required)!=null&&v.length),I="{}";e.properties&&(I="{ "+Object.entries(e.properties).map(([Fe,ee])=>{var Z;let M={...a,isRequired:A?!0:k?(Z=e.required)==null?void 0:Z.includes(Fe):i==null?void 0:i.withImplicitRequiredProps,name:Fe},R=ee;if($e(ee)&&t&&(R=t.getSchemaByRef(ee.$ref),!R))throw new Error(`Schema ${ee.$ref} not found`);let q=Ge({...u,schema:ee,meta:M}).getCodeString(n,i)+qr({schema:R,meta:M,options:i});return[Fe,q]}).map(([Fe,ee])=>`${AS(Fe)}: ${ee}`).join(", ")+" }");let ae=A?".partial()":"",ue=i!=null&&i.strictObjects?".strict()":"";return o.assign(`z.object(${I})${ae}${ue}${C}${h}`)}if(!y)return o.assign("z.unknown()");throw new Error(`Unsupported schema type: ${y}`)}s(Ge,"getZodSchema");function UM({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=Ge({schema:l,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)}return r.getCodeByZodSchemaName(u)||r.setZodSchema(u,c,i),t}s(UM,"getReferenceZodSchema");function GM({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){var u;if(!Yr(e)||!e.oneOf)return;if(e.oneOf.length===1){let c=Ge({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=>Yr(c)&&((c==null?void 0:c.allOf)||[]).length>1);if(e.discriminator&&!a){let c=e.discriminator.propertyName;return t.assign(`
|
|
144
144
|
z.discriminatedUnion("${c}", [${e.oneOf.map(l=>Ge({schema:l,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)).join(", ")}])
|