@povio/openapi-codegen-cli 0.4.11 → 0.4.12

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.js CHANGED
@@ -74,4 +74,4 @@ Expecting `+tn.join(", ")+", got '"+(this.terminals_[P]||P)+"'":Oa="Parse error
74
74
  `].some(s=>String.prototype.includes.call(e.description,s))?n.push(`describe(\`${e.description}\`)`):n.push(`describe("${e.description}")`));let i=n.concat(tN(e,t),(r==null?void 0:r.withDefaultValues)!==!1?rN(e):[]).filter(Boolean).join(".");return i?`.${i}`:""}o(xt,"getZodChain");function tN(e,t){return e.nullable&&!(t!=null&&t.isRequired)?"nullish()":e.nullable?"nullable()":t!=null&&t.isRequired?"":"optional()"}o(tN,"getZodChainablePresence");function rN(e){return e.default!==void 0?`default(${ge(e.type).with("number","integer",()=>Dv(e.default)).otherwise(()=>JSON.stringify(e.default))})`:""}o(rN,"getZodChainableDefault");function nN(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(${iN(e.pattern)})`),e.format){let r=ge(e.format).with("email",()=>"email()").with("hostname","uri",()=>"url()").with("uuid",()=>"uuid()").with("date-time",()=>"datetime({ offset: true })").otherwise(()=>"");r&&t.push(r)}return t.join(".")}o(nN,"getZodChainableStringValidations");function iN(e){return e.startsWith("/")&&e.endsWith("/")&&(e=e.slice(1,-1)),e=Lv(e),`/${e}/`}o(iN,"formatPatternIfNeeded");function oN(e){let t=[];return e.enum?"":(e.type==="integer"&&t.push("int()"),e.minimum!==void 0?e.exclusiveMinimum===!0?t.push(`gt(${e.minimum})`):t.push(`gte(${e.minimum})`):typeof e.exclusiveMinimum=="number"&&t.push(`gt(${e.exclusiveMinimum})`),e.maximum!==void 0?e.exclusiveMaximum===!0?t.push(`lt(${e.maximum})`):t.push(`lte(${e.maximum})`):typeof e.exclusiveMaximum=="number"&&t.push(`lt(${e.exclusiveMaximum})`),e.multipleOf&&t.push(`multipleOf(${e.multipleOf})`),t.join("."))}o(oN,"getZodChainableNumberValidations");function sN(e){let t=[];return e.minItems&&t.push(`min(${e.minItems})`),e.maxItems&&t.push(`max(${e.maxItems})`),t.join(".")}o(sN,"getZodChainableArrayValidations");var Kr=o(e=>e.reduce((t,r)=>t+r,0),"sum");function ie(e,t){if(!t)return e;if(F(t))return e+2;if(Array.isArray(t.type))return t.type.length===1?Ee("oneOf")+ie(e,{...t,type:t.type[0]}):e+Ee("oneOf")+Kr(t.type.map(r=>ie(0,{...t,type:r})));if(t.oneOf)return t.oneOf.length===1?Ee("oneOf")+ie(e,t.oneOf[0]):e+Ee("oneOf")+Kr(t.oneOf.map(r=>ie(0,r)));if(t.anyOf)return t.anyOf.length===1?Ee("anyOf")+ie(e,t.anyOf[0]):e+Ee("anyOf")+Kr(t.anyOf.map(r=>ie(0,r)));if(t.allOf)return t.allOf.length===1?Ee("allOf")+ie(e,t.allOf[0]):e+Ee("allOf")+Kr(t.allOf.map(r=>ie(0,r)));if(!t.type)return e;if(qt(t.type))return t.enum?e+o_(t)+Ee("enum")+Kr(t.enum.map(r=>ie(0,r))):e+o_(t);if(t.type==="array")return t.items?Ee("array")+ie(e,t.items):Ee("array")+ie(e);if(t.type==="object"||t.properties||t.additionalProperties){if(t.additionalProperties)return t.additionalProperties===!0?Ee("record")+ie(e):Ee("record")+ie(e,t.additionalProperties);if(t.properties){let r=Object.values(t.properties);return e+Ee("object")+Kr(r.map(n=>ie(0,n)))}return Ee("empty-object")+ie(e)}return e}o(ie,"getOpenAPISchemaComplexity");function o_(e){return ge(e.type).with("string","number","integer","boolean",()=>1).otherwise(()=>0)}o(o_,"complexityByType");function Ee(e){return ge(e).with("oneOf",()=>2).with("anyOf",()=>3).with("allOf",()=>2).with("enum","array","record","empty-object",()=>1).with("object",()=>2).otherwise(()=>0)}o(Ee,"complexityByComposite");var Np=class Np{constructor(t,r,n={referencedBy:[]},i){this.schema=t;this.resolver=r;F(t)&&(this.ref=t.$ref),i&&(this.enumRef=i),this.meta={...n,referencedBy:[...(n==null?void 0:n.referencedBy)??[]]},this.ref&&this.meta.referencedBy.push(this)}code;ref;enumRef;children=[];meta;getCodeString(t,r){var s,a;if(!this.ref&&this.code)return this.code;if(!this.ref)throw new Error("Zod schema is missing both ref and code");let n=(s=this.resolver)==null?void 0:s.getZodSchemaNameByRef(this.ref);if(!n)return this.ref;let i=(a=this.resolver)==null?void 0:a.getTagByZodSchemaName(n);return r!=null&&r.includeNamespaces&&i&&i!==t?`${K({type:"models",tag:i,options:r})}.${n}`:n}get complexity(){return ie(0,this.schema)}assign(t){return this.code=t,this}inherit(t){return t&&t.children.push(this),this}};o(Np,"ZodSchema");var Ji=Np;function W({schema:e,resolver:t,meta:r,tag:n}){var g;let i=new Ji(e,t,r),s={parent:i.inherit(r==null?void 0:r.parent),referencedBy:[...i.meta.referencedBy]},a={resolver:t,meta:s,tag:n};if(F(e))return aN({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});let c=uN({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(c)return c;let u=cN({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(u)return u;let l=lN({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(l)return l;let f=pN({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(f)return f;let p=fN({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(p)return p;let d=t.options.allReadonly?".readonly()":"";if(Kv(e))return e.items?i.assign(`z.array(${W({...a,schema:e.items}).getCodeString(n,t.options)}${xt({schema:e.items,meta:{...s,isRequired:!0},options:t.options})})${d}`):i.assign(`z.array(z.any())${d}`);let m=e.type?e.type.toLowerCase():void 0;if(m==="object"||e.properties||e.additionalProperties){let y=t.options.additionalPropertiesDefaultValue!==void 0?t.options.additionalPropertiesDefaultValue:!0,_=(e.additionalProperties===null||e.additionalProperties===void 0?y:e.additionalProperties)===!1?"":".passthrough()";if(typeof e.additionalProperties=="object"&&Object.keys(e.additionalProperties).length>0)return i.assign(`z.record(${W({...a,schema:e.additionalProperties}).getCodeString(n,t.options)+xt({schema:e.additionalProperties,meta:{...s,isRequired:!0},options:t.options})})`);let b=e.required&&e.required.length>0,O=t.options.withImplicitRequiredProps?!1:!((g=e.required)!=null&&g.length),P="{}";e.properties&&(P="{ "+Object.entries(e.properties).map(([se,J])=>{var Ut;let G={...s,isRequired:O?!0:b?(Ut=e.required)==null?void 0:Ut.includes(se):t.options.withImplicitRequiredProps,name:se},ve=J;if(F(J)&&t&&(ve=t.getSchemaByRef(J.$ref),!ve))throw new Error(`Schema ${J.$ref} not found`);let _e=W({...a,schema:J,meta:G}).getCodeString(n,t.options)+xt({schema:ve,meta:G,options:t.options});return[se,_e]}).map(([se,J])=>`${Mv(se)}: ${J}`).join(", ")+" }");let S=O?".partial()":"",D=t.options.strictObjects?".strict()":"";return i.assign(`z.object(${P})${S}${D}${_}${d}`)}if(!m)return i.assign("z.unknown()");throw new Error(`Unsupported schema type: ${m}`)}o(W,"getZodSchema");function aN({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){if(!F(e))return;let s=t.meta.referencedBy.slice(0,-1).map(u=>u.ref?r.getZodSchemaNameByRef(u.ref)??u.ref:void 0).filter(Boolean),a=r.getZodSchemaNameByRef(e.$ref);if(s.length>1&&s.includes(a))return t.assign(r.getCodeByZodSchemaName(t.ref));let c=r.getCodeByZodSchemaName(e.$ref);if(!c){let u=r.getSchemaByRef(e.$ref);if(!u)throw new Error(`Schema ${e.$ref} not found`);c=W({schema:u,resolver:r,meta:n,tag:i}).getCodeString(i,r.options)}return r.getCodeByZodSchemaName(a)||r.setZodSchema(a,c,i),t}o(aN,"getReferenceZodSchema");function cN({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){var a;if(!Ce(e)||!e.oneOf)return;if(e.oneOf.length===1){let c=W({schema:e.oneOf[0],resolver:r,meta:n,tag:i});return t.assign(c.getCodeString(i,r.options))}let s=(a=e.oneOf)==null?void 0:a.some(c=>Ce(c)&&((c==null?void 0:c.allOf)||[]).length>1);if(e.discriminator&&!s){let c=e.discriminator.propertyName;return t.assign(`
75
75
  z.discriminatedUnion("${c}", [${e.oneOf.map(u=>W({schema:u,resolver:r,meta:n,tag:i}).getCodeString(i,r.options)).join(", ")}])
76
76
  `)}return t.assign(`z.union([${e.oneOf.map(c=>W({schema:c,resolver:r,meta:n,tag:i}).getCodeString(i,r.options)).join(", ")}])`)}o(cN,"getOneOfZodSchema");function uN({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){if(!(!Ce(e)||!Array.isArray(e.type)))return e.type.length===1?W({schema:{...e,type:e.type[0]},resolver:r,meta:n,tag:i}):t.assign(`z.union([${e.type.map(s=>W({schema:{...e,type:s},resolver:r,meta:n,tag:i}).getCodeString(i,r.options)).join(", ")}])`)}o(uN,"getArrayZodSchema");function lN({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){if(!Ce(e)||!e.anyOf)return;if(e.anyOf.length===1){let a=W({schema:e.anyOf[0],resolver:r,meta:n,tag:i});return t.assign(a.getCodeString(i,r.options))}let s=e.anyOf.map(a=>W({schema:a,resolver:r,meta:n,tag:i})).map(a=>a.getCodeString(i,r.options)).join(", ");return t.assign(`z.union([${s}])`)}o(lN,"getAnyOfZodSchema");function pN({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){if(!Ce(e)||!e.allOf)return;if(e.allOf.length===1){let p=W({schema:e.allOf[0],resolver:r,meta:n,tag:i});return t.assign(p.getCodeString(i,r.options))}let{patchRequiredSchemaInLoop:s,noRequiredOnlyAllof:a,composedRequiredSchema:c}=Yv(e),u=a.map(p=>{let d=W({schema:p,resolver:r,meta:n,tag:i});return r&&s(p,r.getSchemaByRef.bind(r)),d});c.required.length&&u.push(W({schema:c,resolver:r,meta:n,tag:i}));let l=u.at(0),f=u.slice(1).map(p=>`merge(${p.getCodeString(i,r.options)})`).join(".");return t.assign(`${l.getCodeString(i,r.options)}.${f}`)}o(pN,"getAllOfZodSchema");function fN({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){if(!Ce(e))return;let s=e.type?e.type.toLowerCase():void 0;if(s&&qt(s)){if(e.enum){if(s==="string")return dN({schema:e,zodSchema:t,resolver:r,meta:n,tag:i});if(e.enum.some(a=>typeof a=="string"))return t.assign("z.never()");if(e.enum.length===1){let a=e.enum[0];return t.assign(`z.literal(${a===null?"null":a})`)}return t.assign(`z.union([${e.enum.map(a=>`z.literal(${a===null?"null":a})`).join(", ")}])`)}return t.assign(ge(s).with("integer",()=>"z.number()").with("string",()=>ge(e.format).with("binary",()=>"z.instanceof(File)").otherwise(()=>"z.string()")).otherwise(a=>`z.${a}()`))}}o(fN,"getPrimitiveZodSchema");function dN({resolver:e,schema:t,zodSchema:r,meta:n,tag:i}){if(!Ce(t))return;let s=Rp(t),a=e.getEnumZodSchemaDataByCode(s);if(!e.options.extractEnums||!a)return r.assign(s);if(!a.zodSchemaName||!a.tag)throw new Error(`Enum zod schema name or tag not resolved for code: ${s}`);let c=e.options.includeNamespaces&&a.tag!==i?`${K({type:"models",tag:a.tag,options:e.options})}.`:"";return new Ji(t,e,n,a.zodSchemaName).inherit(r),r.assign(`${c}${a.zodSchemaName}`)}o(dN,"getEnumZodSchema");function Rp(e){var t;return`${Ps}([${(t=e.enum)==null?void 0:t.map(r=>r===null?"null":`"${r}"`).join(", ")}])`}o(Rp,"getEnumZodSchemaCode");function Un({schema:e,zodSchema:t,fallbackName:r,resolver:n,tag:i}){var c;let s=t.getCodeString();if((!Oe(s)||t.ref===void 0)&&r){if(t.complexity<$p)return s;let u=Mt(r,n.options.schemaSuffix);for(;n.getCodeByZodSchemaName(u);){if((c=n.getZodSchemaNamesByCompositeCode(s))!=null&&c.includes(u))return u;if(n.getCodeByZodSchemaName(u)===u)return u;throw new Error(`Can't uniquely resolve zod schema name: ${u}`)}return n.setZodSchema(u,s,i),n.addZodSchemaForCompositeCode(s,t,u,e),u}let a=n.getCodeByZodSchemaName(s);if(!a&&t.ref&&(a=n.getCodeByZodSchemaName(n.getZodSchemaNameByRef(t.ref))),t.ref&&a)return ie(0,n.getSchemaByRef(t.ref))<$p?n.getCodeByZodSchemaName(s):s;throw new Error(`Invalid ref: ${t.ref}`)}o(Un,"resolveZodSchemaName");function s_({resolver:e,endpoint:t,operation:r}){let n=r["x-acl"];return n==null?void 0:n.map(i=>{let s=Object.keys(i.conditions??{}).reduce((a,c)=>{let u=mN({resolver:e,endpoint:t,acl:n,name:c});return u?[...a,u]:(e.validationErrors.push(n_(c,r,t)),a)},[]);return{...i,conditionsTypes:s}})}o(s_,"getEndpointAcl");function mN({resolver:e,endpoint:t,acl:r,name:n}){var p,d,m,g,y,v,_,b,O,P;let i=(d=(p=r[0])==null?void 0:p.conditions)==null?void 0:d[n];if(!i)return;let s=i.replace(/^\$[^.]*\./,"").split("."),a,c,u,l=0,f=t.parameters.find(({name:S})=>S===s[l]);if(f)c=(m=f.parameterObject)==null?void 0:m.required,a=(g=f.parameterObject)==null?void 0:g.schema,u=`${f.name} ${Hr(f.type)} parameter`,l++;else{let S=t.parameters.find(({bodyObject:se})=>!!se),R=Object.keys(((y=S==null?void 0:S.bodyObject)==null?void 0:y.content)??{}).find(Ue);R&&(a=(b=(_=(v=S==null?void 0:S.bodyObject)==null?void 0:v.content)==null?void 0:_[R])==null?void 0:b.schema,u=`${Et(t)?"query":"mutation"} data`)}for(;a&&l<s.length;){let S=e.resolveObject(a);a=(O=Object.entries(S.properties??{}).find(([R])=>R===s[l]))==null?void 0:O[1],c=((P=S.required)==null?void 0:P.includes(s[l]))??!1,l++}if(a)return{name:n,type:F(a)?void 0:a.type,zodSchemaName:F(a)?e.getZodSchemaNameByRef(a.$ref):void 0,required:c,info:u}}o(mN,"getEndpointAclConditionPropertyType");function a_({resolver:e,operation:t,operationName:r,isUniqueOperationName:n,tag:i}){var m,g;let s=e.resolveObject(t.requestBody);if(!s)return;let c=Object.keys(s.content??{}).find(Ue);if(!c)return;let u=(g=(m=s.content)==null?void 0:m[c])==null?void 0:g.schema;if(!u)return;let l=W({schema:u,resolver:e,meta:{isRequired:s.required??!0},tag:i}),f=e.resolveObject(u),p=Un({schema:f,zodSchema:l,fallbackName:Ns(Gr(r,n,i)),resolver:e,tag:i}),d=xt({schema:f,meta:l.meta,options:e.options});return{endpointParameter:{name:Zv,type:"Body",description:s.description,zodSchema:p+d,bodyObject:s},requestFormat:c}}o(a_,"getEndpointBody");function c_({resolver:e,param:t,operationName:r,isUniqueOperationName:n,tag:i}){let s=e.resolveObject(t);if(!Nv.includes(s.in))return;let a={};if(s.content){let p=Object.keys(s.content??{}),d=p.find(Ue);if(!d)throw new Error(`Unsupported media type for param ${s.name}: ${p.join(", ")}`);let m=s.content[d];if(!m)throw new Error(`No content with media type for param ${s.name}: ${d}`);a=(m==null?void 0:m.schema)??m}else s.schema&&(a=s.schema);e.options.withDescription&&a&&(a.description=(s.description??"").trim());let c=W({schema:a,resolver:e,meta:{isRequired:s.in==="path"?!0:s.required??!1},tag:i}),u=e.resolveObject(a),l=xt({schema:u,meta:c.meta,options:e.options}),f=Un({schema:u,zodSchema:c.assign(c.getCodeString(i)+l),fallbackName:Hv(Gr(r,n,i),s.name),resolver:e,tag:i});return{name:ge(s.in).with("path",()=>wp(s.name)).otherwise(()=>s.name),type:ge(s.in).with("header",()=>"Header").with("query",()=>"Query").with("path",()=>"Path").run(),zodSchema:f,parameterObject:s}}o(c_,"getEndpointParameter");function l_(e){var r,n,i,s,a;let t=[];for(let c in e.openApiDoc.paths){let u=e.openApiDoc.paths[c],l=dr(u,fr),f=u_(u.parameters??[]);for(let p in l){let d=l[p];if(!d||d.deprecated&&!e.options.withDeprecatedEndpoints)continue;let m=d.operationId&&d.operationId!==bt(d.operationId);d.operationId&&m&&e.validationErrors.push(Xv(d.operationId));let g=Object.entries({...f,...u_(d.parameters??[])}).map(([,P])=>P),y=Ki({path:c,method:p,operation:d,operationsByTag:e.operationsByTag,options:e.options}),v=e.operationNames.filter(P=>P===y).length<=1,_=Ur(d,e.options),b={method:p,path:Vv(c),operationName:y,description:d.description,summary:d.summary,tags:(r=d.tags)==null?void 0:r.map(Ot),requestFormat:"application/json",parameters:[],response:"",errors:[],responseStatusCodes:[]};if(d.requestBody){let P=a_({resolver:e,operation:d,operationName:y,isUniqueOperationName:v,tag:_});P&&(b.parameters.push(P.endpointParameter),b.requestFormat=P.requestFormat)}for(let P of g){let S=c_({resolver:e,param:P,operationName:y,isUniqueOperationName:v,tag:_});S&&b.parameters.push(S)}let O=hN(b);O.forEach(P=>{b.parameters.push(P)}),O.length>0&&e.validationErrors.push(e_(O,c));for(let P in d.responses){b.responseStatusCodes.push(P);let S=e.resolveObject(d.responses[P]),R=Object.keys(S.content??{}).find(Bn),se,J;if(R?(b.responseFormat=R,se=(i=(n=S.content)==null?void 0:n[R])==null?void 0:i.schema):J=mp,se){let G=W({schema:se,resolver:e,meta:{isRequired:!0},tag:_}),ve=e.resolveObject(se);J=Un({schema:ve,zodSchema:G,fallbackName:G.ref?void 0:Rs({statusCode:P,operationName:y,isUniqueOperationName:v,tag:_}),resolver:e,tag:_})+xt({schema:ve,meta:G.meta,options:e.options})}if(J){let G=Number(P);Is(G)?(b.response=J,b.responseObject=S):P!=="default"&&Ts(G)&&b.errors.push({zodSchema:J,status:G,description:S.description})}}b.response||(b.response=mp),b.acl=s_({resolver:e,endpoint:b,operation:d}),(s=d.security)!=null&&s[0].Authorization&&!b.responseStatusCodes.includes("401")&&e.validationErrors.push(kp("401",d,b)),(a=b.acl)!=null&&a[0]&&!b.responseStatusCodes.includes("403")&&e.validationErrors.push(kp("403",d,b)),t.push(b)}}return t}o(l_,"getEndpointsFromOpenAPIDoc");function u_(e){return Object.fromEntries((e??[]).map(t=>[F(t)?t.$ref:t.name,t]))}o(u_,"getParameters");function hN(e){return[...e.path.matchAll(/:([a-zA-Z0-9_]+)/g)].map(r=>r[1]).filter(r=>e.parameters.findIndex(({name:n})=>n===r)===-1).map(r=>gN(r))}o(hN,"getMissingPathParameters");function gN(e){return{name:e,type:"Path",zodSchema:"z.string()",parameterObject:{name:e,required:!0,in:"path",schema:{type:"string"}}}}o(gN,"getPathParameterFromName");function ot(e,t){if(!e)return;let{data:r,onSchema:n}=t;if(F(e)&&n({type:"reference",schema:e,data:r})===!0)return;let i=e;if(As.some(s=>s in i&&i[s])){let s=i.allOf??i.anyOf??i.oneOf??[];for(let a of s){if((n==null?void 0:n({type:"composite",parentSchema:e,schema:a,data:r}))===!0)return;ot(a,{data:r,onSchema:n})}}if(i.properties)for(let[s,a]of Object.entries(i.properties)){if(n({type:"property",parentSchema:e,schema:a,data:r,propertyName:s})===!0)return;ot(a,t)}if(i.additionalProperties)for(let[s,a]of Object.entries(i.additionalProperties)){if(!(a instanceof Object)||n({type:"additionalProperty",parentSchema:e,schema:a,data:r,propertyName:s})===!0)return;ot(a,t)}if(i.type==="array"){let s=e.items;if(n({type:"array",parentSchema:e,schema:s,data:r})===!0)return;ot(s,t)}}o(ot,"iterateSchema");function p_(e,t){let r=yN(e,t),n=vN(e,r);return{refsDependencyGraph:r,deepDependencyGraph:n}}o(p_,"getOpenAPISchemaDependencyGraph");function yN(e,t){let r={},n={};return e.forEach(i=>_N({schema:t(i),fromRef:i,getSchemaByRef:t,visitedRefs:r,refsDependencyGraph:n})),n}o(yN,"getRefsDependencyGraph");function vN(e,t){let r={},n={},i=o((s,a)=>{n[a].add(s),t[s]&&a!==s&&t[s].forEach(c=>{let u=`${a}__${c}`;r[u]||(r[u]=!0,i(c,a))})},"visit");return e.forEach(s=>{let a=t[s];a&&(n[s]||(n[s]=new Set),a.forEach(c=>i(c,s)))}),n}o(vN,"getDeepRefsDependencyGraph");function _N({schema:e,fromRef:t,getSchemaByRef:r,visitedRefs:n={},refsDependencyGraph:i={}}){let s=o(a=>{if(a.type!=="reference"||!a.data)return;let{schema:c,data:u}=a;if(i[u.fromRef]||(i[u.fromRef]=new Set),i[u.fromRef].add(c.$ref),n[c.$ref])return!0;n[u.fromRef]=!0,ot(r(c.$ref),{data:{fromRef:c.$ref},onSchema:s})},"onSchema");return ot(e,{data:{fromRef:t},onSchema:s}),{visitedRefs:n,refsDependencyGraph:i}}o(_N,"getSchemaRefsDependencyGraph");function Ms(e,t,r){let n=[];return ot(t,{onSchema:o(i=>{i.type==="reference"?n.push(i.schema):F(i.parentSchema)&&(i.type==="property"||i.type==="additionalProperty"?e.validationErrors.push(qs(`${r} has both reference and properties`)):i.type==="array"?e.validationErrors.push(qs(`${r} is both reference and array schema`)):i.type==="composite"&&e.validationErrors.push(qs(`${r} has both reference and composite keyword`)))},"onSchema")}),n}o(Ms,"getSchemaRefObjs");function f_(e,t){return t.map(i=>zr(i.$ref)).reduce((i,s)=>{let a=e.dependencyGraph.deepDependencyGraph[s];return[...i,s,...Array.from(a??[])]},[])}o(f_,"getDeepSchemaRefObjs");function Xi({schema:e,nameSegments:t=[],includeSelf:r,...n}){r&&d_({schema:e,nameSegments:t,...n}),ot(e,{data:{nameSegments:t},onSchema:o(i=>{var a;if(i.type==="reference")return!0;let s=[...((a=i.data)==null?void 0:a.nameSegments)??[]];(i.type==="property"||i.type==="additionalProperty")&&s.push(i.propertyName),d_({schema:i.schema,nameSegments:[...s],...n})},"onSchema")})}o(Xi,"updateEnumZodSchemaData");function d_({resolver:e,schema:t,schemaRef:r,schemaInfo:n,tags:i,nameSegments:s=[]}){if(!t||F(t)||!t.enum)return;let a=Rp(t),c=e.enumZodSchemaData.find(u=>u.code===a);c?(c.meta.zodSchemaNameSegments.push(s),c.meta.tags.push(...i),c.meta.schemaRefs.push(...r?[r]:[])):e.enumZodSchemaData.push({code:a,meta:{zodSchemaNameSegments:[s],tags:[...i],schemaRefs:r?[r]:[]}}),e.validationErrors.push(t_(r?`schema ${Vn(r)} property ${s[s.length-1]}`:n??s.join("->")))}o(d_,"handleEnumZodSchemaDataUpdate");function m_(e){e.enumZodSchemaData.forEach(r=>{let n=r.meta.zodSchemaNameSegments.map(s=>s[s.length-1]).filter(Boolean),i=gp(n);if(!i)throw new Error(`No common last segment found for enum: ${r.code}`);r.zodSchemaName=Ap(i,e.options.enumSuffix,e.options.schemaSuffix)});let t=0;for(;t<5&&!Cp(e);)bN(e,t+2),t++;if(Cp(e)||e.enumZodSchemaData.filter(n=>!g_(e,n)).forEach(n=>{n.zodSchemaName=Ap(n.meta.zodSchemaNameSegments[0].map(i=>jp(Z(i))).join(""),e.options.enumSuffix,e.options.schemaSuffix)}),!Cp(e))throw new Error("Failed to resolve unique names for enum zod schemas")}o(m_,"resolveEnumZodSchemaNames");function Cp(e){return e.enumZodSchemaData.every(t=>g_(e,t))}o(Cp,"allEnumZodSchemaNamesAreUnique");function bN(e,t){e.enumZodSchemaData.forEach(r=>{let n=e.enumZodSchemaData.filter(({zodSchemaName:i})=>r.zodSchemaName===i);n.length!==1&&SN(n,t)})}o(bN,"additionalResolveEnumZodSchemaName");function SN(e,t=2){e.forEach(r=>{let n=r.meta.zodSchemaNameSegments.map(i=>i[i.length-t]).filter(Boolean);if(n.length===1){let i=[jp(Z(n[0])),r.zodSchemaName].filter(Boolean).join("");r.zodSchemaName=i}else{let i=gp(n),s=[i?jp(Z(i)):"",r.zodSchemaName].filter(Boolean).join("");r.zodSchemaName=s}})}o(SN,"suffixWithPreviousSegmentName");function h_(e){e.enumZodSchemaData.forEach(t=>{let r=$e(t.meta.tags);t.tag=r.length===1?r[0]:e.options.defaultTag})}o(h_,"resolveEnumZodSchemaTags");function g_(e,t){return e.enumZodSchemaData.filter(({zodSchemaName:r})=>t.zodSchemaName===r).length===1}o(g_,"isUnique");function jp(e){return e.replace(/(Dto|DTO|Response|Request)/g,"")}o(jp,"sanitizeName");var qp=class qp{constructor(t,r){this.openApiDoc=t;this.options=r;this.dependencyGraph=p_(this.schemaRefs,this.getSchemaByRef.bind(this)),this.operationsByTag=Cv(t,r),this.operationNames=Fv(t,this.operationsByTag,r),this.initialize()}schemaData=[];zodSchemaData=[];compositeZodSchemaData=[];enumZodSchemaData=[];dependencyGraph;operationsByTag={};operationNames=[];validationErrors=[];get docSchemas(){var t;return((t=this.openApiDoc.components)==null?void 0:t.schemas)??{}}get schemaRefs(){return Object.keys(this.docSchemas).map(qv)}getSchemaByRef(t){return this.docSchemas[Vn(t)]}getSchemaDataByRef(t){return this.schemaData.find(r=>r.ref===t)}getZodSchemaNameByRef(t){var n,i;let r=((n=this.getSchemaDataByRef(zr(t)))==null?void 0:n.zodSchemaName)??((i=this.enumZodSchemaData.find(s=>s.zodSchemaName===t))==null?void 0:i.zodSchemaName);if(!r)throw new Error(`Zod schema not found for ref: ${t}`);return r}getRefByZodSchemaName(t){var r;return(r=this.schemaData.find(n=>n.zodSchemaName===t))==null?void 0:r.ref}getTagByZodSchemaName(t){var u,l;if(!this.options.splitByTags)return this.options.defaultTag;let r=this.enumZodSchemaData.find(f=>f.zodSchemaName===t);if(r)return Ot(r.tag??this.options.defaultTag);let n=this.getRefByZodSchemaName(t),i=n?((u=this.getSchemaDataByRef(n))==null?void 0:u.tags)??[]:[],s=((l=this.zodSchemaData.find(f=>f.zodSchemaName===t))==null?void 0:l.tags)??[],a=$e(i,s),c=a.length===1?a[0]:this.options.defaultTag;return Ot(c??this.options.defaultTag)}getCodeByZodSchemaName(t){var r;return(r=this.zodSchemaData.find(n=>n.zodSchemaName===t))==null?void 0:r.code}getZodSchemaNamesByCompositeCode(t){var r;return(r=this.compositeZodSchemaData.find(n=>n.code===t))==null?void 0:r.zodSchemas.map(n=>n.zodSchemaName)}setZodSchema(t,r,n){let i=this.zodSchemaData.find(s=>s.zodSchemaName===t);i?(i.code=r,i.tags=(i.tags??[]).concat(n)):this.zodSchemaData.push({zodSchemaName:t,code:r,tags:[n]})}addZodSchemaForCompositeCode(t,r,n,i){let s={zodSchemaName:n,zodSchema:r,schema:i},a=this.compositeZodSchemaData.find(c=>c.code===t);a?a.zodSchemas.push(s):this.compositeZodSchemaData.push({code:t,zodSchemas:[s]})}getCompositeZodSchemaByZodSchemaName(t){var n;let r=this.compositeZodSchemaData.find(i=>i.zodSchemas.some(s=>s.zodSchemaName===t));return(n=r==null?void 0:r.zodSchemas.find(i=>i.zodSchemaName===t))==null?void 0:n.zodSchema}getSchemaByCompositeZodSchemaName(t){var r,n;return(n=(r=this.compositeZodSchemaData.find(i=>i.zodSchemas.some(s=>s.zodSchemaName===t)))==null?void 0:r.zodSchemas.find(i=>i.zodSchemaName===t))==null?void 0:n.schema}getEnumZodSchemaDataByCode(t){return this.enumZodSchemaData.find(r=>r.code===t)}getEnumZodSchemaNamesReferencedBySchemaRef(t){return this.enumZodSchemaData.reduce((r,{zodSchemaName:n,meta:i})=>(n&&i.schemaRefs.includes(t)&&r.push(n),r),[])}getZodSchemas(){return this.zodSchemaData.reduce((t,{zodSchemaName:r,code:n})=>({...t,[r]:n}),{})}getEnumZodSchemas(){return this.enumZodSchemaData.reduce((t,{zodSchemaName:r,code:n})=>r?{...t,[r]:n}:t,{})}resolveObject(t){return F(t)?this.getSchemaByRef(t.$ref):t}isSchemaCircular(t){var r;return(r=this.dependencyGraph.deepDependencyGraph[t])==null?void 0:r.has(t)}getCircularSchemaChain(t,r=t,n=[]){var i,s;return(i=this.dependencyGraph.refsDependencyGraph[r])!=null&&i.has(t)?[...n,r,t]:Array.from(((s=this.dependencyGraph.refsDependencyGraph[r])==null?void 0:s.values())??[]).map(a=>{let c=this.getCircularSchemaChain(t,a,n);return c.length>0?[r,...c]:c}).flat()}initialize(){var t,r,n,i,s,a;this.schemaRefs.forEach(c=>{let u=zr(c),l=Vn(u),f=Mt(l,this.options.schemaSuffix);this.schemaData.push({ref:u,name:l,zodSchemaName:f,tags:[]})});for(let c in this.openApiDoc.paths){let u=this.openApiDoc.paths[c],l=dr(u,fr);for(let f in l){let p=l[f];if(!p||p.deprecated&&!((t=this.options)!=null&&t.withDeprecatedEndpoints))continue;let d=Ur(p,this.options),m=Ki({path:c,method:f,operation:p,operationsByTag:this.operationsByTag,options:this.options}),g=this.operationNames.filter(b=>b===m).length<=1,y=ue(Gr(m,g,d)),v=[];if((r=p.parameters)==null||r.map(b=>{let O=b,P=O.schema,S=`operation ${p.operationId??c} parameter ${O.name}`;v.push(...Ms(this,P,S)),this.options.extractEnums&&Xi({resolver:this,schema:P,schemaInfo:S,tags:[d],nameSegments:[y,O.name],includeSelf:!0})}),p.requestBody){let b=this.resolveObject(p.requestBody),P=Object.keys(b.content??{}).find(Ue);if(P){let S=(i=(n=b.content)==null?void 0:n[P])==null?void 0:i.schema,D=`operation ${p.operationId} request body`;v.push(...Ms(this,S,D)),this.options.extractEnums&&Xi({resolver:this,schema:S,schemaInfo:D,tags:[d],nameSegments:[Ns(y)]})}}for(let b in p.responses){let O=this.resolveObject(p.responses[b]),S=Object.keys(O.content??{}).find(Bn);if(S){let D=(a=(s=O.content)==null?void 0:s[S])==null?void 0:a.schema,R=`operation ${p.operationId} response body`;v.push(...Ms(this,D,R)),this.options.extractEnums&&Xi({resolver:this,schema:D,schemaInfo:R,tags:[d],nameSegments:[Rs({statusCode:b,operationName:m,isUniqueOperationName:g,tag:d})]})}}f_(this,v).forEach(b=>{let O=this.getSchemaDataByRef(b);O&&O.tags.push(d)})}}this.options.extractEnums&&(this.schemaRefs.forEach(c=>{var l;let u=zr(c);Xi({resolver:this,schema:this.getSchemaByRef(u),schemaRef:u,tags:((l=this.getSchemaDataByRef(u))==null?void 0:l.tags)??[],nameSegments:[Vn(u)]})}),m_(this),h_(this))}};o(qp,"SchemaResolver");var Ds=qp;function y_(e){var r;let t={};return Object.entries(((r=e.openApiDoc.components)==null?void 0:r.schemas)??{}).forEach(([n,i])=>{let s=Mt(n,e.options.schemaSuffix);if(!t[s]){let a=e.getTagByZodSchemaName(s);t[s]=W({schema:i,resolver:e,tag:a}).getCodeString(a)}}),t}o(y_,"getZodSchemasFromOpenAPIDoc");function v_(e){let t=[],r={};function n(i,s){Array.isArray(s)||(s=[]),s.push(i),r[i]=!0,e[i]&&e[i].forEach(a=>{s.includes(a)||r[a]||n(a,s.slice(0))}),t.includes(i)||t.push(i)}return o(n,"visit"),Object.keys(e).forEach(i=>n(i,[])),t}o(v_,"topologicalSort");function __(e,t){let r=Object.entries(e),n=r.filter(([i])=>t.includes(i)).sort(([i],[s])=>t.indexOf(i)-t.indexOf(s)).concat(r.filter(([i])=>!t.includes(i)));return Object.fromEntries(n)}o(__,"sortObjKeysFromArray");function b_(e,t){let r=v_(e.dependencyGraph.deepDependencyGraph).map(i=>e.getZodSchemaNameByRef(i));return __(t,r)}o(b_,"sortZodSchemasByTopology");function S_(e,t){let r={};return Object.entries(t).forEach(([n,i])=>{let s=e.getRefByZodSchemaName(n);s&&e.isSchemaCircular(s)?(e.validationErrors.push(r_(e.getCircularSchemaChain(s).join(" -> "))),r[Mt(n,e.options.schemaSuffix)]=`z.lazy(() => ${i})`):r[Mt(n,e.options.schemaSuffix)]=i}),r}o(S_,"wrapCircularZodSchemas");function Ls(e,t){let r=new Ds(e,t),n=l_(r),s={...y_(r),...r.getZodSchemas()};return s=S_(r,s),s=b_(r,s),s={...r.getEnumZodSchemas(),...s},{resolver:r,data:PN({resolver:r,endpoints:n,zodSchemas:s,options:t})}}o(Ls,"getDataFromOpenAPIDoc");function PN({resolver:e,endpoints:t,zodSchemas:r,options:n}){let i=new Map;return n.splitByTags?(t.forEach(s=>{let a=Qi(s,n);P_(a,i).endpoints.push(s)}),Object.entries(r).forEach(([s,a])=>{let c=e.getTagByZodSchemaName(s);c&&(P_(c,i).zodSchemas[s]=a)}),i):(i.set(n.defaultTag,{endpoints:t,zodSchemas:r}),i)}o(PN,"splitDataByTags");function P_(e,t){return t.has(e)||t.set(e,{endpoints:[],zodSchemas:{}}),t.get(e)}o(P_,"getTagElement");async function $_(e,t){let{resolver:r,data:n}=await Ls(e,t),i=[],s=[];return n.forEach(({endpoints:c,zodSchemas:u},l)=>{var d;((d=t.excludeTags)==null?void 0:d.findIndex(m=>m.toLowerCase()===l.toLowerCase()))===-1&&(Object.keys(u).forEach(m=>{let g=r.getRefByZodSchemaName(m),y=g?r.getSchemaByRef(g):r.getSchemaByCompositeZodSchemaName(m),v=Hn({zodSchemaName:m,schema:y,resolver:r}),_;y&&(_=Zr({schema:y,parentTypes:[v],resolver:r})),i.push({...v,metaType:"primitive",..._})}),c.forEach(m=>{let g="queries",y=Ot(l);s.push({name:Es(m),filePath:Ct({type:g,tag:y,includeTagDir:!0,options:t}),namespace:t.includeNamespaces?K({type:g,tag:y,options:t}):void 0,isQuery:Et(m),isMutation:ks(m),params:$N({resolver:r,endpoint:m}),response:ON({resolver:r,endpoint:m})})}))}),{openApiDoc:e,models:i,queries:s}}o($_,"getMetadataFromOpenAPIDoc");function $N({resolver:e,endpoint:t}){return t.parameters.map(r=>{var a,c,u,l;let n;if((a=r.parameterObject)!=null&&a.schema)n=e.resolveObject(r.parameterObject.schema);else if(r.bodyObject){let p=Object.keys(r.bodyObject.content??{}).find(Ue);p&&(n=e.resolveObject((u=(c=r.bodyObject.content)==null?void 0:c[p])==null?void 0:u.schema))}let i=Hn({zodSchemaName:r.zodSchema,schema:n,resolver:e}),s;return n&&(s=Zr({schema:n,parentTypes:[i],resolver:e})),{name:bt(r.name),isRequired:((l=r.parameterObject)==null?void 0:l.required)??!0,...i,...s,paramType:r.type}}).sort((r,n)=>{if(r.isRequired===n.isRequired){let i=["Path","Body","Query","Header"];return i.indexOf(r.paramType)-i.indexOf(n.paramType)}return r.isRequired?-1:1}).map(({paramType:r,...n})=>n)}o($N,"getQueryMetadataParams");function ON({resolver:e,endpoint:t}){var a,c,u,l;let r,n=Object.keys(((a=t.responseObject)==null?void 0:a.content)??{}).find(Bn);n&&(r=e.resolveObject((l=(u=(c=t.responseObject)==null?void 0:c.content)==null?void 0:u[n])==null?void 0:l.schema));let i=Hn({zodSchemaName:t.response,schema:r,resolver:e}),s;return r&&(s=Zr({schema:r,parentTypes:[i],resolver:e})),{...i,metaType:"primitive",...s}}o(ON,"getQueryMetadataResponse");var O_="acl/app.ability",eo="AllAbilities",st={abilityTuple:"AbilityTuple",pureAbility:"PureAbility",forcedSubject:"ForcedSubject",subject:"subject"},Mp={bindings:[st.abilityTuple,st.pureAbility,st.forcedSubject,st.subject],from:"@casl/ability"};var E_=o(e=>`Use${Z(ue(e.operationName))}Ability`,"getAbilityTypeName"),x_=o(e=>`canUse${Z(ue(e.operationName))}`,"getAbilityFunctionName"),w_=o(e=>{var t;return(t=e.acl)==null?void 0:t[0].action},"getAbilityAction"),A_=o(e=>{var t;return(t=e.acl)==null?void 0:t[0].subject},"getAbilitySubject"),I_=o(e=>{var t;return!!((t=Dp(e))!=null&&t.length)},"hasAbilityConditions"),Dp=o(e=>{var t;return(t=e.acl)==null?void 0:t[0].conditionsTypes},"getAbilityConditionsTypes"),T_=o(e=>{var t;return(t=e.acl)==null?void 0:t[0].description},"getAbilityDescription"),Fs=o(e=>`${Z(e)}${eo}`,"getTagAllAbilitiesName");var Lp="src/data",Fp="@/data",Vp="AppRestClient",k_={bindings:[Vp],from:"@/util/rest/clients/app-rest-client"},to={query:"AppQueryOptions",mutation:"AppMutationOptions"},N_={bindings:[to.query,to.mutation],from:"@/types/react-query"};function mr({resolver:e,tag:t,zodSchemas:r=[],zodSchemasAsTypes:n=[]}){let i="models",s=o(u=>e.getTagByZodSchemaName(u),"getTag"),a=Bp({type:i,tag:t,entities:r,getTag:s,getEntityName:o(u=>u,"getEntityName"),options:e.options}),c=Bp({type:i,tag:t,entities:n,getTag:s,getEntityName:o(u=>Yi(u,e.options),"getEntityName"),options:e.options});return EN(e.options,a,c)}o(mr,"getModelsImports");function R_({tag:e,endpoints:t,options:r}){return Bp({type:"endpoints",tag:e,entities:t,getTag:o(n=>Qi(n,r),"getTag"),getEntityName:Wi,options:r})}o(R_,"getEndpointsImports");function C_({tags:e,entityName:t,getAliasEntityName:r,options:n}){let i=new Map;return e.forEach(s=>{let a=`${t}${r?` as ${r(s)}`:""}`;i.has(s)?n.includeNamespaces||i.get(s).bindings.push(a):i.set(s,{bindings:[n.includeNamespaces?K({type:"acl",tag:s,options:n}):a],from:`${j_(n)}${Ct({type:"acl",tag:s,includeTagDir:!0,options:n})}`})}),Array.from(i.values())}o(C_,"getAclImports");function j_(e){let t=Fp;return e.importPath==="relative"?t="../":e.importPath==="absolute"?t=e.output:new RegExp(`${Lp}`,"g").test(e.output)&&(t=e.output.replace(new RegExp(`.*${Lp}`,"g"),Fp)),`${t}/`.replace(/\/\//g,"/")}o(j_,"getImportPath");function Bp({type:e="models",tag:t,entities:r,getTag:n,getEntityName:i,options:s}){let a=new Map;return r.forEach(c=>{let u=n(c);if(a.has(u))s.includeNamespaces||a.get(u).bindings.push(i(c));else{let l=t===u;a.set(u,{bindings:[s.includeNamespaces?K({type:e,tag:u,options:s}):i(c)],from:`${l?"./":j_(s)}${Ct({type:e,tag:u,includeTagDir:!l,options:s})}`})}}),Array.from(a.values())}o(Bp,"getImports");function EN(e,...t){let r=new Map;return t.forEach(n=>{n.forEach(i=>{r.has(i.from)?e.includeNamespaces||r.get(i.from).bindings.push(...i.bindings):r.set(i.from,i)})}),Array.from(r.values()).map(n=>({...n,bindings:$e(n.bindings)}))}o(EN,"mergeImports");var Lf=ut(yr());var jf=ut(require("fs")),xS=ut(require("path"));function qf(e){let t=`src/generators/templates/${e}.hbs`;return jf.default.readFileSync(xS.default.join(__dirname,`../${t}`),"utf-8")}o(qf,"readHbsTemplateSync");function Mf({output:e,fileName:t}){return`${e}/${t}.ts`}o(Mf,"getOutputFileName");var Bt=ut(yr());function wS(){y3(),v3(),_3(),b3(),S3(),P3(),$3(),O3()}o(wS,"registerAclHbsHelpers");function y3(){Bt.default.registerHelper("abilityTypeName",E_)}o(y3,"registerAbilityTypeNameHelper");function v3(){Bt.default.registerHelper("abilityFunctionName",x_)}o(v3,"registerAbilityFunctionNameHelper");function _3(){Bt.default.registerHelper("ablityAction",w_)}o(_3,"registerAbilityActionHelper");function b3(){Bt.default.registerHelper("ablitySubject",A_)}o(b3,"registerAbilitySubjectHelper");function S3(){Bt.default.registerHelper("hasAbilityConditions",I_)}o(S3,"registerHasAbilityConditionsHelper");function P3(){Bt.default.registerHelper("abilityConditionsTypes",Dp)}o(P3,"registerAbilityConditionsTypesHelper");function $3(){Bt.default.registerHelper("abilityDescription",T_)}o($3,"registerAbilityDescriptionHelper");function O3(){Bt.default.registerHelper("tagAllAbilitiesName",Fs)}o(O3,"registerTagAllAbilitiesNameHelper");var $a=ut(yr());function AS(){E3(),x3(),w3()}o(AS,"registerCommonHbsHelpers");function E3(){$a.default.registerHelper("isEqual",(e,t)=>e===t)}o(E3,"registerIsEqualHelper");function x3(){$a.default.registerHelper("commaSeparated",e=>e.join(", "))}o(x3,"registerCommaSeparatedListHelper");function w3(){$a.default.registerHelper("addAsteriskAfterNewLine",e=>e.replace(/\n/g,`
77
- *`))}o(w3,"registerAddAsteriskAfterNewLineHelper");var vr=ut(yr());function IS(e){A3(),I3(e.options),N3(e),T3(),k3(),R3(e),C3()}o(IS,"registerEndpointsHbsHelpers");function A3(){vr.default.registerHelper("endpointName",Wi)}o(A3,"registerEndpointNameHelper");function I3(e){vr.default.registerHelper("importedEndpointName",t=>Wv(t,e))}o(I3,"registerImportedEndpointNameHelper");function T3(){vr.default.registerHelper("endpointPath",Qv)}o(T3,"registerEndpointPathHelper");function k3(){vr.default.registerHelper("endpointBody",e=>e.parameters.find(t=>t.type==="Body"))}o(k3,"registerEndpointBodyHelper");function N3(e){vr.default.registerHelper("endpointParams",t=>Tp(e,t))}o(N3,"registerEndpointParamsHelper");function R3(e){vr.default.registerHelper("endpointArgs",t=>Tp(e,t).map(r=>r.name).join(", "))}o(R3,"registerEndpointArgsHelper");function C3(){vr.default.registerHelper("endpointParamDescription",e=>{var s,a,c,u,l;let t=[`${e.paramType} parameter`],r=((s=e.parameterObject)==null?void 0:s.description)||((a=e.bodyObject)==null?void 0:a.description);r&&t.push(r);let n,i;if((c=e.parameterObject)!=null&&c.schema&&Ce(e.parameterObject.schema)&&(n=(u=e.parameterObject)==null?void 0:u.schema),(l=e.bodyObject)!=null&&l.content){let p=Object.keys(e.bodyObject.content??{}).find(Ue);p&&(i=e.bodyObject.content[p],i.schema&&Ce(i.schema)&&(n=i.schema))}return n&&["description","minimum","exclusiveMinimum","maximum","exclusiveMaximum","minItems","minLength","minProperties","maxItems","maxLength","maxProperties","example"].filter(p=>n[p]).forEach(p=>{t.push(`${Z(xv(p))}: \`${n[p]}\``)}),i!=null&&i.example&&t.push(`Example: \`${i.example}\``),t.join(". ")})}o(C3,"registerEndpointParamDescriptionHelper");var br=ut(yr());var _r={query:"useQuery",mutation:"useMutation"},TS={bindings:[_r.query,_r.mutation],from:"@tanstack/react-query"};function kS(){j3(),q3(),M3(),D3(),L3(),F3(),V3()}o(kS,"registerPartialsHbsHelpers");function j3(){br.default.registerHelper("genImport",e=>Sr("import")({import:e}))}o(j3,"registerImportHelper");function q3(){br.default.registerHelper("genEndpointParams",e=>Sr("endpoint-params")({endpoint:e}))}o(q3,"registerGenerateEndpointParamsHelper");function M3(){br.default.registerHelper("genEndpointConfig",e=>{let t=Jv(e);return Object.keys(t).length===0?"":Sr("endpoint-config")({endpointConfig:t})})}o(M3,"registerGenerateEndpointConfigHelper");function D3(){br.default.registerHelper("genQueryKeys",e=>e.length===0?"":Sr("query-keys")({endpoints:e}))}o(D3,"registerGenerateQueryKeysHelper");function L3(){br.default.registerHelper("genQuery",e=>{let t,r;return Et(e)?(t="query-use-query",r=_r.query):(t="query-use-mutation",r=_r.mutation),Sr(t)({endpoint:e,queryHook:r})})}o(L3,"registerGenerateQueryHelper");function F3(){br.default.registerHelper("genCaslAbilityType",e=>Sr("casl-ability-type")({endpoint:e,abilityTupleType:st.abilityTuple}))}o(F3,"registerGenerateCaslAbilityTypeHelper");function V3(){br.default.registerHelper("genCaslAbilityFunction",e=>Sr("casl-ability-function")({endpoint:e}))}o(V3,"registerGenerateCaslAbilityFunctionHelper");var go=ut(yr());function NS(){B3(),H3(),U3(),z3()}o(NS,"registerQueryHbsHelpers");function B3(){go.default.registerHelper("queryName",Es)}o(B3,"registerQueryNameHelper");function H3(){go.default.registerHelper("allQueryKeys",yp)}o(H3,"registerQueryKeysHelper");function U3(){go.default.registerHelper("endpointPathQueryKeys",wv)}o(U3,"registerEndpointPathQueryKeysHelper");function z3(){go.default.registerHelper("isQuery",Et)}o(z3,"registerIsQueryHelper");var Df=ut(yr());function RS(e){G3(e.options),Z3(e)}o(RS,"registerZodHbsHelpers");function G3(e){Df.default.registerHelper("zodInferedType",t=>Yi(t,e))}o(G3,"registerInferedTypeHelper");function Z3(e){Df.default.registerHelper("importedZodSchemaName",t=>Uv(e,t))}o(Z3,"registerImportedZodSchemaNameHelper");function Ht(e,t){let r=qf(t);return AS(),RS(e),IS(e),NS(),wS(),kS(),Lf.default.compile(r)}o(Ht,"getHbsTemplateDelegate");function Sr(e){let t=qf(`partials/${e}`);return Lf.default.compile(t)}o(Sr,"getHbsPartialTemplateDelegate");function CS({resolver:e,data:t,tag:r=""}){var u;let n=(u=t.get(r))==null?void 0:u.endpoints.filter(({acl:l})=>l&&l.length>0);if(!n||n.length===0)return;let i={...Mp,bindings:[st.abilityTuple,...n.filter(({acl:l})=>l==null?void 0:l[0].conditions).length>0?[st.forcedSubject,st.subject]:[]]},s=n.reduce((l,f)=>{var d,m;let p=(m=(d=f.acl)==null?void 0:d[0].conditionsTypes)==null?void 0:m.reduce((g,y)=>[...g,...y!=null&&y.zodSchemaName?[y.zodSchemaName]:[]],[]);return[...l,...p??[]]},[]),a=mr({resolver:e,tag:r,zodSchemasAsTypes:$e(s)});return Ht(e,"acl")({caslAbilityTupleImport:i,modelsImports:a,includeNamespace:e.options.includeNamespaces,namespace:K({type:"acl",tag:r,options:e.options}),endpoints:n})}o(CS,"generateAcl");function jS(e,t){if(!t||t.length===0)return;let r={...Mp,bindings:[st.pureAbility]},n=C_({tags:t,entityName:eo,getAliasEntityName:Fs,options:e.options}),i=t.map(a=>K({type:"acl",tag:a,options:e.options}));return Ht(e,"app-acl")({caslAbilityTupleImport:r,imports:n,allAbilities:eo,includeNamespace:e.options.includeNamespaces,tags:t,namespaces:i})}o(jS,"generateAppAcl");function qS({resolver:e,data:t,tag:r=""}){var l;let n=(l=t.get(r))==null?void 0:l.endpoints;if(!n||n.length===0)return;let i=n.map(f=>f.response),s=i.some(f=>!Oe(f)),a=n.reduce((f,p)=>[...f,...p.parameters],[]),c=mr({resolver:e,tag:r,zodSchemas:$e(i.filter(Oe)),zodSchemasAsTypes:$e(a.map(f=>f.zodSchema).filter(Oe))});return Ht(e,"endpoints")({restClientImport:k_,hasZodImport:s,zodImport:$s,modelsImports:c,includeNamespace:e.options.includeNamespaces,namespace:K({type:"endpoints",tag:r,options:e.options}),restClientName:Vp,endpoints:n})}o(qS,"generateEndpoints");function MS(e,t){let r=e.getRefByZodSchemaName(t);if(r){let i=Array.from(e.dependencyGraph.refsDependencyGraph[r]??[]).map(a=>e.getZodSchemaNameByRef(a)),s=e.getEnumZodSchemaNamesReferencedBySchemaRef(r);return[...i,...s]}let n=e.getCompositeZodSchemaByZodSchemaName(t);return n?Array.from(DS(n)).map(i=>e.getZodSchemaNameByRef(i)):[]}o(MS,"getZodSchemaRefs");function DS(e){return e.children.reduce((r,n)=>{let i=n.ref??n.enumRef;return i&&r.add(i),n.children.length>0&&DS(n).forEach(s=>r.add(s)),r},new Set)}o(DS,"getSchemaRefs");function LS({resolver:e,data:t,tag:r=""}){var u;let n=(u=t.get(r))==null?void 0:u.zodSchemas;if(!n||Object.keys(n).length===0)return;let i=Object.keys(n).reduce((l,f)=>[...l,...MS(e,f)],[]).filter(l=>!n[l]),s=mr({resolver:e,tag:r,zodSchemas:i}),a=Object.entries(n).reduce((l,[f,p])=>{let d=e.getRefByZodSchemaName(f);return{...l,[f]:{code:p,isCircular:!!d&&e.isSchemaCircular(d),isEnum:Bv(p)}}},{});return Ht(e,"models")({zodImport:$s,modelsImports:s,includeNamespace:e.options.includeNamespaces,namespace:K({type:"models",tag:r,options:e.options}),zodSchemasData:a})}o(LS,"generateModels");function FS({resolver:e,data:t,tag:r=""}){var d;let n=(d=t.get(r))==null?void 0:d.endpoints;if(!n||n.length===0)return;let i=n.filter(Et),s=n.filter(ks),a={...TS,bindings:[...i.length>0?[_r.query]:[],...s.length>0?[_r.mutation]:[]]},c={...N_,bindings:[...i.length>0?[to.query]:[],...s.length>0?[to.mutation]:[]]},u=[...i,...s].reduce((m,g)=>[...m,...g.parameters],[]),l=mr({resolver:e,tag:r,zodSchemasAsTypes:$e(u.map(m=>m.zodSchema).filter(Oe))}),f=R_({tag:r,endpoints:n,options:e.options});return Ht(e,"queries")({queryImport:a,queryTypesImport:c,modelsImports:l,endpointsImports:f,includeNamespace:e.options.includeNamespaces,namespace:K({type:"queries",tag:r,options:e.options}),endpoints:n,queryEndpoints:i})}o(FS,"generateQueries");function VS(e,t){let r={...zi,...t},{resolver:n,data:i}=Ls(e,r),s=[],a=[],c=["models","endpoints","queries","acl"],u={models:LS,endpoints:qS,queries:FS,acl:CS};i.forEach((f,p)=>{r.excludeTags.find(m=>m.toLowerCase()===p.toLowerCase())||c.forEach(m=>{let g=u[m]({resolver:n,data:i,tag:p});if(g){let y=Mf({output:r.output,fileName:Ct({tag:p,type:m,options:r})});s.push({fileName:y,content:g}),m==="acl"&&a.push(p)}})});let l=jS(n,a);if(l){let f=Mf({output:r.output,fileName:O_});s.push({fileName:f,content:l})}return s}o(VS,"generateCodeFromOpenAPIDoc");async function K3({input:e,options:t}){let r={...zi,...t},n=await Ff.default.bundle(e);return await $_(n,r)}o(K3,"getGenerateMetadata");async function Y3({input:e,options:t}){let r={...zi,...t},n=await Ff.default.bundle(e);return VS(n,r)}o(Y3,"getGenerateFilesData");0&&(module.exports={getGenerateFilesData,getGenerateMetadata});
77
+ *`))}o(w3,"registerAddAsteriskAfterNewLineHelper");var vr=ut(yr());function IS(e){A3(),I3(e.options),N3(e),T3(),k3(),R3(e),C3()}o(IS,"registerEndpointsHbsHelpers");function A3(){vr.default.registerHelper("endpointName",Wi)}o(A3,"registerEndpointNameHelper");function I3(e){vr.default.registerHelper("importedEndpointName",t=>Wv(t,e))}o(I3,"registerImportedEndpointNameHelper");function T3(){vr.default.registerHelper("endpointPath",Qv)}o(T3,"registerEndpointPathHelper");function k3(){vr.default.registerHelper("endpointBody",e=>e.parameters.find(t=>t.type==="Body"))}o(k3,"registerEndpointBodyHelper");function N3(e){vr.default.registerHelper("endpointParams",t=>Tp(e,t))}o(N3,"registerEndpointParamsHelper");function R3(e){vr.default.registerHelper("endpointArgs",t=>Tp(e,t).map(r=>r.name).join(", "))}o(R3,"registerEndpointArgsHelper");function C3(){vr.default.registerHelper("endpointParamDescription",e=>{var s,a,c,u,l;let t=[`${e.paramType} parameter`],r=((s=e.parameterObject)==null?void 0:s.description)||((a=e.bodyObject)==null?void 0:a.description);r&&t.push(r);let n,i;if((c=e.parameterObject)!=null&&c.schema&&Ce(e.parameterObject.schema)&&(n=(u=e.parameterObject)==null?void 0:u.schema),(l=e.bodyObject)!=null&&l.content){let p=Object.keys(e.bodyObject.content??{}).find(Ue);p&&(i=e.bodyObject.content[p],i.schema&&Ce(i.schema)&&(n=i.schema))}return n&&["description","minimum","exclusiveMinimum","maximum","exclusiveMaximum","minItems","minLength","minProperties","maxItems","maxLength","maxProperties","example"].filter(p=>n[p]).forEach(p=>{t.push(`${Z(xv(p))}: \`${n[p]}\``)}),i!=null&&i.example&&t.push(`Example: \`${i.example}\``),t.join(". ")})}o(C3,"registerEndpointParamDescriptionHelper");var br=ut(yr());var _r={query:"useQuery",mutation:"useMutation"},TS={bindings:[_r.query,_r.mutation],from:"@tanstack/react-query"};function kS(){j3(),q3(),M3(),D3(),L3(),F3(),V3()}o(kS,"registerPartialsHbsHelpers");function j3(){br.default.registerHelper("genImport",e=>Sr("import")({import:e}))}o(j3,"registerImportHelper");function q3(){br.default.registerHelper("genEndpointParams",e=>Sr("endpoint-params")({endpoint:e}))}o(q3,"registerGenerateEndpointParamsHelper");function M3(){br.default.registerHelper("genEndpointConfig",e=>{let t=Jv(e);return Object.keys(t).length===0?"":Sr("endpoint-config")({endpointConfig:t})})}o(M3,"registerGenerateEndpointConfigHelper");function D3(){br.default.registerHelper("genQueryKeys",e=>e.length===0?"":Sr("query-keys")({endpoints:e}))}o(D3,"registerGenerateQueryKeysHelper");function L3(){br.default.registerHelper("genQuery",e=>{let t,r;return Et(e)?(t="query-use-query",r=_r.query):(t="query-use-mutation",r=_r.mutation),Sr(t)({endpoint:e,queryHook:r})})}o(L3,"registerGenerateQueryHelper");function F3(){br.default.registerHelper("genCaslAbilityType",e=>Sr("casl-ability-type")({endpoint:e,abilityTupleType:st.abilityTuple}))}o(F3,"registerGenerateCaslAbilityTypeHelper");function V3(){br.default.registerHelper("genCaslAbilityFunction",e=>Sr("casl-ability-function")({endpoint:e}))}o(V3,"registerGenerateCaslAbilityFunctionHelper");var go=ut(yr());function NS(){B3(),H3(),U3(),z3()}o(NS,"registerQueryHbsHelpers");function B3(){go.default.registerHelper("queryName",Es)}o(B3,"registerQueryNameHelper");function H3(){go.default.registerHelper("allQueryKeys",yp)}o(H3,"registerQueryKeysHelper");function U3(){go.default.registerHelper("endpointPathQueryKeys",wv)}o(U3,"registerEndpointPathQueryKeysHelper");function z3(){go.default.registerHelper("isQuery",Et)}o(z3,"registerIsQueryHelper");var Df=ut(yr());function RS(e){G3(e.options),Z3(e)}o(RS,"registerZodHbsHelpers");function G3(e){Df.default.registerHelper("zodInferedType",t=>Yi(t,e))}o(G3,"registerInferedTypeHelper");function Z3(e){Df.default.registerHelper("importedZodSchemaName",t=>Uv(e,t))}o(Z3,"registerImportedZodSchemaNameHelper");function Ht(e,t){let r=qf(t);return AS(),RS(e),IS(e),NS(),wS(),kS(),Lf.default.compile(r)}o(Ht,"getHbsTemplateDelegate");function Sr(e){let t=qf(`partials/${e}`);return Lf.default.compile(t)}o(Sr,"getHbsPartialTemplateDelegate");function CS({resolver:e,data:t,tag:r=""}){var l;let n=(l=t.get(r))==null?void 0:l.endpoints.filter(({acl:f})=>f&&f.length>0);if(!n||n.length===0)return;let i=n.some(({acl:f})=>(f==null?void 0:f[0].conditions)&&Object.keys(f[0].conditions).length>0),s={...Mp,bindings:[st.abilityTuple,...i?[st.forcedSubject,st.subject]:[]]},a=n.reduce((f,p)=>{var m,g;let d=(g=(m=p.acl)==null?void 0:m[0].conditionsTypes)==null?void 0:g.reduce((y,v)=>[...y,...v!=null&&v.zodSchemaName?[v.zodSchemaName]:[]],[]);return[...f,...d??[]]},[]),c=mr({resolver:e,tag:r,zodSchemasAsTypes:$e(a)});return Ht(e,"acl")({caslAbilityTupleImport:s,modelsImports:c,includeNamespace:e.options.includeNamespaces,namespace:K({type:"acl",tag:r,options:e.options}),endpoints:n})}o(CS,"generateAcl");function jS(e,t){if(!t||t.length===0)return;let r={...Mp,bindings:[st.pureAbility]},n=C_({tags:t,entityName:eo,getAliasEntityName:Fs,options:e.options}),i=t.map(a=>K({type:"acl",tag:a,options:e.options}));return Ht(e,"app-acl")({caslAbilityTupleImport:r,imports:n,allAbilities:eo,includeNamespace:e.options.includeNamespaces,tags:t,namespaces:i})}o(jS,"generateAppAcl");function qS({resolver:e,data:t,tag:r=""}){var l;let n=(l=t.get(r))==null?void 0:l.endpoints;if(!n||n.length===0)return;let i=n.map(f=>f.response),s=i.some(f=>!Oe(f)),a=n.reduce((f,p)=>[...f,...p.parameters],[]),c=mr({resolver:e,tag:r,zodSchemas:$e(i.filter(Oe)),zodSchemasAsTypes:$e(a.map(f=>f.zodSchema).filter(Oe))});return Ht(e,"endpoints")({restClientImport:k_,hasZodImport:s,zodImport:$s,modelsImports:c,includeNamespace:e.options.includeNamespaces,namespace:K({type:"endpoints",tag:r,options:e.options}),restClientName:Vp,endpoints:n})}o(qS,"generateEndpoints");function MS(e,t){let r=e.getRefByZodSchemaName(t);if(r){let i=Array.from(e.dependencyGraph.refsDependencyGraph[r]??[]).map(a=>e.getZodSchemaNameByRef(a)),s=e.getEnumZodSchemaNamesReferencedBySchemaRef(r);return[...i,...s]}let n=e.getCompositeZodSchemaByZodSchemaName(t);return n?Array.from(DS(n)).map(i=>e.getZodSchemaNameByRef(i)):[]}o(MS,"getZodSchemaRefs");function DS(e){return e.children.reduce((r,n)=>{let i=n.ref??n.enumRef;return i&&r.add(i),n.children.length>0&&DS(n).forEach(s=>r.add(s)),r},new Set)}o(DS,"getSchemaRefs");function LS({resolver:e,data:t,tag:r=""}){var u;let n=(u=t.get(r))==null?void 0:u.zodSchemas;if(!n||Object.keys(n).length===0)return;let i=Object.keys(n).reduce((l,f)=>[...l,...MS(e,f)],[]).filter(l=>!n[l]),s=mr({resolver:e,tag:r,zodSchemas:i}),a=Object.entries(n).reduce((l,[f,p])=>{let d=e.getRefByZodSchemaName(f);return{...l,[f]:{code:p,isCircular:!!d&&e.isSchemaCircular(d),isEnum:Bv(p)}}},{});return Ht(e,"models")({zodImport:$s,modelsImports:s,includeNamespace:e.options.includeNamespaces,namespace:K({type:"models",tag:r,options:e.options}),zodSchemasData:a})}o(LS,"generateModels");function FS({resolver:e,data:t,tag:r=""}){var d;let n=(d=t.get(r))==null?void 0:d.endpoints;if(!n||n.length===0)return;let i=n.filter(Et),s=n.filter(ks),a={...TS,bindings:[...i.length>0?[_r.query]:[],...s.length>0?[_r.mutation]:[]]},c={...N_,bindings:[...i.length>0?[to.query]:[],...s.length>0?[to.mutation]:[]]},u=[...i,...s].reduce((m,g)=>[...m,...g.parameters],[]),l=mr({resolver:e,tag:r,zodSchemasAsTypes:$e(u.map(m=>m.zodSchema).filter(Oe))}),f=R_({tag:r,endpoints:n,options:e.options});return Ht(e,"queries")({queryImport:a,queryTypesImport:c,modelsImports:l,endpointsImports:f,includeNamespace:e.options.includeNamespaces,namespace:K({type:"queries",tag:r,options:e.options}),endpoints:n,queryEndpoints:i})}o(FS,"generateQueries");function VS(e,t){let r={...zi,...t},{resolver:n,data:i}=Ls(e,r),s=[],a=[],c=["models","endpoints","queries","acl"],u={models:LS,endpoints:qS,queries:FS,acl:CS};i.forEach((f,p)=>{r.excludeTags.find(m=>m.toLowerCase()===p.toLowerCase())||c.forEach(m=>{let g=u[m]({resolver:n,data:i,tag:p});if(g){let y=Mf({output:r.output,fileName:Ct({tag:p,type:m,options:r})});s.push({fileName:y,content:g}),m==="acl"&&a.push(p)}})});let l=jS(n,a);if(l){let f=Mf({output:r.output,fileName:O_});s.push({fileName:f,content:l})}return s}o(VS,"generateCodeFromOpenAPIDoc");async function K3({input:e,options:t}){let r={...zi,...t},n=await Ff.default.bundle(e);return await $_(n,r)}o(K3,"getGenerateMetadata");async function Y3({input:e,options:t}){let r={...zi,...t},n=await Ff.default.bundle(e);return VS(n,r)}o(Y3,"getGenerateFilesData");0&&(module.exports={getGenerateFilesData,getGenerateMetadata});
package/dist/sh.js CHANGED
@@ -137,7 +137,7 @@ ${y.join(`
137
137
  `:`
138
138
  `)+r,i=n+1,n=e.indexOf(`
139
139
  `,i)}while(n!==-1);return s+=e.slice(i),s}o(xy,"stringEncaseCRLFWithFirstIndex");var{stdout:Ay,stderr:Iy}=$y,Ul=Symbol("GENERATOR"),ro=Symbol("STYLER"),us=Symbol("IS_EMPTY"),Cy=["ansi","ansi","ansi256","ansi16m"],no=Object.create(null),L$=o((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=Ay?Ay.level:0;e.level=t.level===void 0?r:t.level},"applyOptions"),Zl=class Zl{constructor(t){return Ty(t)}};o(Zl,"Chalk");var Ja=Zl,Ty=o(e=>{let t=o((...r)=>r.join(" "),"chalk");return L$(t,e),Object.setPrototypeOf(t,ls.prototype),t},"chalkFactory");function ls(e){return Ty(e)}o(ls,"createChalk");Object.setPrototypeOf(ls.prototype,Function.prototype);for(let[e,t]of Object.entries(gr))no[e]={get(){let r=Xa(this,Gl(t.open,t.close,this[ro]),this[us]);return Object.defineProperty(this,e,{value:r}),r}};no.visible={get(){let e=Xa(this,this[ro],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var zl=o((e,t,r,...n)=>e==="rgb"?t==="ansi16m"?gr[r].ansi16m(...n):t==="ansi256"?gr[r].ansi256(gr.rgbToAnsi256(...n)):gr[r].ansi(gr.rgbToAnsi(...n)):e==="hex"?zl("rgb",t,r,...gr.hexToRgb(...n)):gr[r][e](...n),"getModelAnsi"),F$=["rgb","hex","ansi256"];for(let e of F$){no[e]={get(){let{level:r}=this;return function(...n){let i=Gl(zl(e,Cy[r],"color",...n),gr.color.close,this[ro]);return Xa(this,i,this[us])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);no[t]={get(){let{level:r}=this;return function(...n){let i=Gl(zl(e,Cy[r],"bgColor",...n),gr.bgColor.close,this[ro]);return Xa(this,i,this[us])}}}}var B$=Object.defineProperties(()=>{},{...no,level:{enumerable:!0,get(){return this[Ul].level},set(e){this[Ul].level=e}}}),Gl=o((e,t,r)=>{let n,i;return r===void 0?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},"createStyler"),Xa=o((e,t,r)=>{let n=o((...i)=>V$(n,i.length===1?""+i[0]:i.join(" ")),"builder");return Object.setPrototypeOf(n,B$),n[Ul]=e,n[ro]=t,n[us]=r,n},"createBuilder"),V$=o((e,t)=>{if(e.level<=0||!t)return e[us]?"":t;let r=e[ro];if(r===void 0)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=wy(t,r.close,r.open),r=r.parent;let s=t.indexOf(`
140
- `);return s!==-1&&(t=xy(t,i,n,s)),n+t+i},"applyStyle");Object.defineProperties(ls.prototype,no);var bF=ls(),vF=ls({level:Iy?Iy.level:0});var Nr=new Ja;function fs(e,t,r){console.log(r!==void 0&&r!==t?`${Nr.yellow(`${e}:`.padEnd(20))}${Nr.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}o(fs,"logVariable");function rr(e){console.log(`[INFO] ${e}`)}o(rr,"logInfo");function vn(e){console.log(Nr.green(`[SUCCESS] ${e}`))}o(vn,"logSuccess");function ps(e,t){e instanceof Error?(console.log(Nr.red(`[ERROR] ${t||e.message}`)),process.env.VERBOSE&&console.error(e)):console.log(Nr.red(`[ERROR] ${e}`))}o(ps,"logError");function ec(e){console.log(Nr.bgYellow(`==== ${e} ====`))}o(ec,"logBanner");var jy=gt(require("fs"));function io(){return"0.4.11"}o(io,"getVersion");var jF=gt(Ny());var Wl=Symbol("options_key");function ut(e){return(t,r)=>{var n,i;if(e!=null){let s={...Reflect.getMetadata(Wl,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(Wl,s,t)}}}o(ut,"YargOption");function ky(e){let t=Reflect.getMetadata(Wl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}o(ky,"getYargsOption");function tc(e){return async t=>t.options(H$(e)).middleware(async r=>await U$(e,r),!0)}o(tc,"getBuilder");function H$(e){return Object.entries(ky(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}o(H$,"getYargsOptions");async function U$(e,t){let r=new e;for(let[n,i]of Object.entries(ky(e)))r[n]=t[n]??i.default;return r}o(U$,"loadYargsConfig");var v1=gt(Lh());var lP="Schema",fP="Enum",pP="Body",dP="Param",hP="Response",mP="ErrorResponse",Fh="z.void()",au="z.enum",cu={bindings:["z"],from:"zod"};var uu={input:"input.yaml",output:"output",splitByTags:!0,defaultTag:"Common",excludeTags:[],includeNamespaces:!0,importPath:"ts",extractEnums:!0,configs:{models:{outputFileNameSuffix:"models",namespaceSuffix:"Models"},endpoints:{outputFileNameSuffix:"api",namespaceSuffix:"Api"},queries:{outputFileNameSuffix:"queries",namespaceSuffix:"Queries"},acl:{outputFileNameSuffix:"acl",namespaceSuffix:"Acl"}},schemaSuffix:lP,enumSuffix:fP,additionalPropertiesDefaultValue:!1,removeOperationPrefixEndingWith:"Controller_"};var gP={"invalid-schema":"Invalid Schemas","invalid-operation-id":"Invalid Operation IDs","missing-path-parameter":"Missing Path Parameters","not-allowed-inline-enum":"Not Allowed Inline Enums","not-allowed-circular-schema":"Not Allowed Circular Schemas","missing-acl-condition-property":"Missing x-acl Condition Properties","missing-status-code":"Missing Status Codes"};var Bh={"Content-Type":"application/json",Accept:"application/json"},yP="data";var bP=o(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),Mn=o(e=>e.replace(/^[^a-zA-Z_$]*/g,"").replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var on=Symbol.for("@ts-pattern/matcher"),L3=Symbol.for("@ts-pattern/isVariadic"),fu="@ts-pattern/anonymous-select-key",Vh=o(e=>!!(e&&typeof e=="object"),"r"),lu=o(e=>e&&!!e[on],"i"),Zr=o((e,t,r)=>{if(lu(e)){let n=e[on](),{matched:i,selections:s}=n.match(t);return i&&s&&Object.keys(s).forEach(a=>r(a,s[a])),i}if(Vh(e)){if(!Vh(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],s=[];for(let a of e.keys()){let c=e[a];lu(c)&&c[L3]?s.push(c):s.length?i.push(c):n.push(c)}if(s.length){if(s.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<n.length+i.length)return!1;let a=t.slice(0,n.length),c=i.length===0?[]:t.slice(-i.length),u=t.slice(n.length,i.length===0?1/0:-i.length);return n.every((l,p)=>Zr(l,a[p],r))&&i.every((l,p)=>Zr(l,c[p],r))&&(s.length===0||Zr(s[0],u,r))}return e.length===t.length&&e.every((a,c)=>Zr(a,t[c],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||lu(s=i)&&s[on]().matcherType==="optional")&&Zr(i,t[n],r);var s})}return Object.is(t,e)},"s"),Bn=o(e=>{var t,r,n;return Vh(e)?lu(e)?(t=(r=(n=e[on]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?ia(e,Bn):ia(Object.values(e),Bn):[]},"o"),ia=o((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function ur(e){return Object.assign(e,{optional:o(()=>F3(e),"optional"),and:o(t=>Fe(e,t),"and"),or:o(t=>B3(e,t),"or"),select:o(t=>t===void 0?vP(e):vP(t,e),"select")})}o(ur,"u");function F3(e){return ur({[on]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return t===void 0?(Bn(e).forEach(i=>n(i,void 0)),{matched:!0,selections:r}):{matched:Zr(e,t,n),selections:r}},"match"),getSelectionKeys:o(()=>Bn(e),"getSelectionKeys"),matcherType:"optional"})})}o(F3,"h");function Fe(...e){return ur({[on]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return{matched:e.every(i=>Zr(i,t,n)),selections:r}},"match"),getSelectionKeys:o(()=>ia(e,Bn),"getSelectionKeys"),matcherType:"and"})})}o(Fe,"m");function B3(...e){return ur({[on]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return ia(e,Bn).forEach(i=>n(i,void 0)),{matched:e.some(i=>Zr(i,t,n)),selections:r}},"match"),getSelectionKeys:o(()=>ia(e,Bn),"getSelectionKeys"),matcherType:"or"})})}o(B3,"d");function Pe(e){return{[on]:()=>({match:o(t=>({matched:!!e(t)}),"match")})}}o(Pe,"p");function vP(...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 ur({[on]:()=>({match:o(n=>{let i={[t??fu]:n};return{matched:r===void 0||Zr(r,n,(s,a)=>{i[s]=a}),selections:i}},"match"),getSelectionKeys:o(()=>[t??fu].concat(r===void 0?[]:Bn(r)),"getSelectionKeys")})})}o(vP,"y");function zr(e){return typeof e=="number"}o(zr,"v");function qn(e){return typeof e=="string"}o(qn,"b");function Dn(e){return typeof e=="bigint"}o(Dn,"w");var J9=ur(Pe(function(e){return!0}));var Ln=o(e=>Object.assign(ur(e),{startsWith:o(t=>{return Ln(Fe(e,(r=t,Pe(n=>qn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:o(t=>{return Ln(Fe(e,(r=t,Pe(n=>qn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:o(t=>Ln(Fe(e,(r=>Pe(n=>qn(n)&&n.length>=r))(t))),"minLength"),length:o(t=>Ln(Fe(e,(r=>Pe(n=>qn(n)&&n.length===r))(t))),"length"),maxLength:o(t=>Ln(Fe(e,(r=>Pe(n=>qn(n)&&n.length<=r))(t))),"maxLength"),includes:o(t=>{return Ln(Fe(e,(r=t,Pe(n=>qn(n)&&n.includes(r)))));var r},"includes"),regex:o(t=>{return Ln(Fe(e,(r=t,Pe(n=>qn(n)&&!!n.match(r)))));var r},"regex")}),"j"),X9=Ln(Pe(qn)),Gr=o(e=>Object.assign(ur(e),{between:o((t,r)=>Gr(Fe(e,((n,i)=>Pe(s=>zr(s)&&n<=s&&i>=s))(t,r))),"between"),lt:o(t=>Gr(Fe(e,(r=>Pe(n=>zr(n)&&n<r))(t))),"lt"),gt:o(t=>Gr(Fe(e,(r=>Pe(n=>zr(n)&&n>r))(t))),"gt"),lte:o(t=>Gr(Fe(e,(r=>Pe(n=>zr(n)&&n<=r))(t))),"lte"),gte:o(t=>Gr(Fe(e,(r=>Pe(n=>zr(n)&&n>=r))(t))),"gte"),int:o(()=>Gr(Fe(e,Pe(t=>zr(t)&&Number.isInteger(t)))),"int"),finite:o(()=>Gr(Fe(e,Pe(t=>zr(t)&&Number.isFinite(t)))),"finite"),positive:o(()=>Gr(Fe(e,Pe(t=>zr(t)&&t>0))),"positive"),negative:o(()=>Gr(Fe(e,Pe(t=>zr(t)&&t<0))),"negative")}),"x"),eH=Gr(Pe(zr)),Fn=o(e=>Object.assign(ur(e),{between:o((t,r)=>Fn(Fe(e,((n,i)=>Pe(s=>Dn(s)&&n<=s&&i>=s))(t,r))),"between"),lt:o(t=>Fn(Fe(e,(r=>Pe(n=>Dn(n)&&n<r))(t))),"lt"),gt:o(t=>Fn(Fe(e,(r=>Pe(n=>Dn(n)&&n>r))(t))),"gt"),lte:o(t=>Fn(Fe(e,(r=>Pe(n=>Dn(n)&&n<=r))(t))),"lte"),gte:o(t=>Fn(Fe(e,(r=>Pe(n=>Dn(n)&&n>=r))(t))),"gte"),positive:o(()=>Fn(Fe(e,Pe(t=>Dn(t)&&t>0))),"positive"),negative:o(()=>Fn(Fe(e,Pe(t=>Dn(t)&&t<0))),"negative")}),"A"),tH=Fn(Pe(Dn)),rH=ur(Pe(function(e){return typeof e=="boolean"})),nH=ur(Pe(function(e){return typeof e=="symbol"})),iH=ur(Pe(function(e){return e==null})),oH=ur(Pe(function(e){return e!=null}));var Gh=class Gh extends Error{constructor(t){let r;try{r=JSON.stringify(t)}catch{r=t}super(`Pattern matching error: no pattern matches value ${r}`),this.input=void 0,this.input=t}};o(Gh,"W");var Hh=Gh,Uh={matched:!1,value:void 0};function Ot(e){return new zh(e,Uh)}o(Ot,"z");var na=class na{constructor(t,r){this.input=void 0,this.state=void 0,this.input=t,this.state=r}with(...t){if(this.state.matched)return this;let r=t[t.length-1],n=[t[0]],i;t.length===3&&typeof t[1]=="function"?i=t[1]:t.length>2&&n.push(...t.slice(1,t.length-1));let s=!1,a={},c=o((l,p)=>{s=!0,a[l]=p},"a"),u=!n.some(l=>Zr(l,this.input,c))||i&&!i(this.input)?Uh:{matched:!0,value:r(s?fu in a?a[fu]:a:this.input,this.input)};return new na(this.input,u)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new na(this.input,n?{matched:!0,value:r(this.input,this.input)}:Uh)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new Hh(this.input)}run(){return this.exhaustive()}returnType(){return this}};o(na,"I");var zh=na;var _P=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with"];var Zh=2,SP=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],OP=["query","header","path"],Vn=["get","put","post","delete","options","head","patch","trace"],PP=["string","number","integer","boolean"],Wh=["allOf","anyOf","oneOf"];function Hn(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}o(Hn,"pick");var Ve=o(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),Mi=o(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),pu=o(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),ht=o(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),EP=o(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),Kh=o((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),$P=o((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix"),V3=o(e=>{var n;let t=e.reduce((i,s)=>({...i,[s]:(i[s]??0)+1}),{});return(n=Object.entries(t).sort((i,s)=>i[1]===s[1]?s[0].length-i[0].length:s[1]-i[1])[0])==null?void 0:n[0]},"getLongestMostCommon"),Yh=o(e=>{let t=e.map(Ve).map(wP).map(r=>H3(r)).flat();return V3(t)},"getMostCommonAdjacentCombinationSplit"),wP=o(e=>e.split(/(?<![A-Z])(?=[A-Z])/).filter(Boolean),"splitByUppercase"),xP=o(e=>wP(e).join(" "),"camelToSpaceSeparated"),H3=o((e,t=["dto","by","for","of","in","to","and","with"])=>{var n;let r=[];for(let i=0;i<e.length;i++)if(!t.includes(e[i].toLowerCase()))for(let s=i+1;s<=e.length;s++)t.includes((n=e[s-1])==null?void 0:n.toLowerCase())||r.push(e.slice(i,s).join(""));return r},"getAdjacentStringCombinations");function Un(e){return EP(e)}o(Un,"formatTag");function qi(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return Un(r??t.defaultTag)}o(qi,"getOperationTag");function AP(e,t){let r={};for(let n in e.paths){let i=e.paths[n],s=Hn(i,Vn);for(let a in s){let c=s[a];if(!c||c.deprecated&&!(t!=null&&t.withDeprecatedEndpoints))continue;let u=t.splitByTags?qi(c,t):t.defaultTag;r[u]||(r[u]=[]),r[u].push(c)}}return r}o(AP,"getOperationsByTag");var CP=o(e=>`#/components/schemas/${e}`,"getSchemaRef"),Di=o(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),Uo=o(e=>Di(e).split("/").at(-1),"getSchemaNameByRef");function Ie(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}o(Ie,"isReferenceObject");function Xh(e){let t=U3(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/--+/g,"-").replace(/-+/g,"_").replace(/[^\w-]+/g,"_");return ht(t)}o(Xh,"normalizeString");function TP(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}o(TP,"wrapWithQuotesIfNeeded");function jP(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}o(jP,"unwrapQuotesIfNeeded");function U3(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}o(U3,"prefixStringStartingWithNumberIfNeeded");function em(e){let t=e.replaceAll("_","#");return ht(t.replaceAll("-","_")).replaceAll("#","_")}o(em,"pathParamToVariableName");var Li=o(e=>PP.includes(e),"isPrimitiveType");function RP(e){return e.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/([\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\uFFFE\uFFFF])/g,(t,r)=>{let n=r.codePointAt(),i=n.toString(16);return n<=255?`\\x${`00${i}`.slice(-2)}`:`\\u${`0000${i}`.slice(-4)}`}).replace(/\//g,"\\/")}o(RP,"escapeControlCharacters");function Wr(e){return e.includes("application/")&&e.includes("json")||SP.includes(e)||e.includes("text/")}o(Wr,"isParamMediaTypeAllowed");function du(e){return e>=200&&e<300}o(du,"isMainResponseStatus");function hu(e){return!(e>=200&&e<300)}o(hu,"isErrorStatus");function mu(e){return e==="application/json"}o(mu,"isMediaTypeAllowed");function Qh({path:e,method:t,operation:r,options:n,keepOperationPrefixWithoutEnding:i}){let s=`${t}${G3(e)}`,a=r.operationId?Mn(r.operationId):s;if(n.removeOperationPrefixEndingWith&&i)return a.split(n.removeOperationPrefixEndingWith).map((u,l)=>l===0?u:Ve(u)).join("");if(n.removeOperationPrefixEndingWith&&!i){let c=new RegExp(`^.*${n.removeOperationPrefixEndingWith}`);a=a.replace(c,"")}return _P.includes(a)?s:a}o(Qh,"getOperationName");function oa({path:e,method:t,operation:r,operationsByTag:n,options:i}){let s=i.splitByTags?qi(r,i):i.defaultTag,a=Qh({path:e,method:t,operation:r,options:i});return n[s].filter(u=>Qh({path:e,method:t,operation:u,options:i})===a).length===1?a:Qh({path:e,method:t,operation:r,options:i,keepOperationPrefixWithoutEnding:!0})}o(oa,"getUniqueOperationName");function NP(e,t,r){let n=[];for(let i in e.paths){let s=e.paths[i],a=Hn(s,Vn);for(let c in a){let u=a[c];if(!u||u.deprecated&&!(r!=null&&r.withDeprecatedEndpoints))continue;let l=oa({path:i,method:c,operation:u,operationsByTag:t,options:r});n.push(l)}}return n}o(NP,"getUniqueOperationNamesWithoutSplitByTags");var IP=/({\w+})/g,z3=/[^\w\-]+/g;function G3(e){e=Ve(pu(e.replaceAll("/","-")).replaceAll("-",""));let t=[...e.matchAll(IP)];if(t.length>0){let r=t.sort((n,i)=>n.index-i.index)[t.length-1][0];e=`${e.replace(IP,"")}By${Ve(r.slice(1,-1))}`}return e.replace(z3,"_")}o(G3,"pathToVariableName");var Jh=/{(\b\w+(?:-\w+)*\b)}/g;function kP(e){let t=e.match(Jh);return t===null?e.replaceAll(Jh,":$1"):(t.forEach(r=>{let n=em(r.replaceAll(Jh,":$1"));e=e.replaceAll(r,n)}),e)}o(kP,"replaceHyphenatedPath");function Gt(e){return!Ie(e)}o(Gt,"isSchemaObject");function MP(e){return e.type==="array"}o(MP,"isArraySchemaObject");function qP(e){if(!e.allOf)throw new Error("Function inferRequiredSchema is specialized to handle item with required only in an allOf array.");let[t,r]=e.allOf.reduce((i,s)=>{if(Z3(s)){let a=s.required;i[0].push(...a??[])}else i[1].push(s);return i},[[],[]]),n={properties:t.reduce((i,s)=>(i[s]={},i),{}),type:"object",required:t};return{noRequiredOnlyAllof:r,composedRequiredSchema:n,patchRequiredSchemaInLoop:o((i,s)=>{if(Ie(i)){let a=s(i.$ref);a&&n.required.forEach(c=>{var u;n.properties[c]=((u=a==null?void 0:a.properties)==null?void 0:u[c])??{}})}else{let a=i.properties??{};n.required.forEach(c=>{a[c]&&(n.properties[c]=a[c]??{})})}},"patchRequiredSchemaInLoop")}}o(qP,"inferRequiredSchema");var Z3=o(e=>!Ie(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function zn({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${Mi(t)}/`:""}${Mi(t)}.${i}`:i}o(zn,"getTagFileName");var Je=o(({type:e,tag:t,options:r})=>`${Ve(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var sn=o((e,t)=>Kh(Ve(Xh(e)),t),"getZodSchemaName"),tm=o((e,t,r)=>Kh(Ve(Xh(e)),`${t}${r}`),"getEnumZodSchemaName"),Dt=o(e=>!e.startsWith("z."),"isNamedZodSchema"),DP=o(e=>e.startsWith(au),"isEnumZodSchema"),Fi=o((e,t,r)=>t?e:`${r}_${e}`,"getZodSchemaOperationName"),gu=o(e=>ht(`${e}_${pP}`),"getBodyZodSchemaName"),LP=o((e,t)=>ht(`${e}_${t}${dP}`),"getParamZodSchemaName"),W3=o(e=>ht(`${e}${hP}`),"getMainResponseZodSchemaName"),K3=o((e,t)=>ht(`${e}_${t}_${mP}`),"getErrorResponseZodSchemaName");function yu({statusCode:e,operationName:t,isUniqueOperationName:r,tag:n}){let i=Number(e),s=Fi(t,r,n);return!du(i)&&e!=="default"&&hu(i)?K3(s,e):W3(s)}o(yu,"getResponseZodSchemaName");var sa=o((e,t)=>$P(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),FP=o((e,t)=>Dt(t)?`${e.options.includeNamespaces?`${Je({type:"models",tag:e.getTagByZodSchemaName(t),options:e.options})}.`:""}${t}`:t,"getImportedZodSchemaName"),rm=o((e,t)=>Dt(t)?`${e.options.includeNamespaces?`${Je({type:"models",tag:e.getTagByZodSchemaName(t),options:e.options})}.`:""}${sa(t,e.options)}`:t,"getImportedZodSchemaInferedTypeName");function BP(e){return Ot(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}o(BP,"primitiveTypeToTsType");var aa=o(e=>Mi(ht(e.operationName)),"getEndpointName");function VP(e,t){return`${t.includeNamespaces?`${Je({type:"endpoints",tag:ca(e,t),options:t})}.`:""}${aa(e)}`}o(VP,"getImportedEndpointName");var HP=o(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function ca(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return Un(r??t.defaultTag)}o(ca,"getEndpointTag");function nm(e,t){return t.parameters.map(r=>{var i,s,a,c;let n="string";if(Dt(r.zodSchema))n=rm(e,r.zodSchema);else if((i=r.parameterObject)!=null&&i.schema&&Gt(r.parameterObject.schema)){let u=(a=(s=r.parameterObject)==null?void 0:s.schema)==null?void 0:a.type;u&&Li(u)&&(n=BP(u))}return{name:Mn(r.name),type:n,paramType:r.type,required:((c=r.parameterObject)==null?void 0:c.required)??!0,parameterObject:r.parameterObject,bodyObject:r.bodyObject}}).sort((r,n)=>{if(r.required===n.required){let i=["Path","Body","Query","Header"];return i.indexOf(r.paramType)-i.indexOf(n.paramType)}return r.required?-1:1})}o(nm,"mapEndpointParamsToFunctionParams");function UP(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let s=bP(i.name)?i.name:`"${i.name}"`,a=Mn(i.name);return{...i,name:s,value:a}}),r={};return e.requestFormat!==Bh["Content-Type"]&&(r["Content-Type"]=`'${e.requestFormat}'`),e.responseFormat&&e.responseFormat!==Bh.Accept&&(r.Accept=`'${e.responseFormat}'`),e.parameters.filter(i=>i.type==="Header").forEach(i=>{r[i.name]=Mn(i.name)}),{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}o(UP,"getEndpointConfig");function bu(e){return{type:"invalid-schema",message:e}}o(bu,"getInvalidSchemaError");function zP(e){return{type:"invalid-operation-id",message:`Operation ${e}`}}o(zP,"getInvalidOperationIdError");function GP(e,t){return{type:"missing-path-parameter",message:`Path ${t} is missing [${e.map(({name:r})=>r).join(", ")}]`}}o(GP,"getMissingPathParameterError");function ZP(e){return{type:"not-allowed-inline-enum",message:e}}o(ZP,"getNotAllowedInlineEnumError");function WP(e){return{type:"not-allowed-circular-schema",message:e}}o(WP,"getNotAllowedCircularSchemaError");function KP(e,t,r){return{type:"missing-acl-condition-property",message:`Condition property ${e} is not found in parameters or body in operation ${YP(t,r)}`}}o(KP,"getMissingAclConditionPropertyError");function im(e,t,r){return{type:"missing-status-code",message:`Missing status code ${e} in operation ${YP(t,r)}`}}o(im,"getMissingStatusCodeError");function YP(e,t){return e.operationId??`${t.method} ${t.path}`}o(YP,"getOperationDescriptor");function QP(e){return e.reduce((t,r)=>({...t,[r.type]:[...t[r.type]??[],r.message]}),{})}o(QP,"groupByType");function Kr({schema:e,meta:t,options:r}){let n=[];Ot(e.type).with("string",()=>n.push(J3(e))).with("number","integer",()=>n.push(eq(e))).with("array",()=>n.push(tq(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
140
+ `);return s!==-1&&(t=xy(t,i,n,s)),n+t+i},"applyStyle");Object.defineProperties(ls.prototype,no);var bF=ls(),vF=ls({level:Iy?Iy.level:0});var Nr=new Ja;function fs(e,t,r){console.log(r!==void 0&&r!==t?`${Nr.yellow(`${e}:`.padEnd(20))}${Nr.magenta(t)}`:`${`${e}:`.padEnd(20)}${t}`)}o(fs,"logVariable");function rr(e){console.log(`[INFO] ${e}`)}o(rr,"logInfo");function vn(e){console.log(Nr.green(`[SUCCESS] ${e}`))}o(vn,"logSuccess");function ps(e,t){e instanceof Error?(console.log(Nr.red(`[ERROR] ${t||e.message}`)),process.env.VERBOSE&&console.error(e)):console.log(Nr.red(`[ERROR] ${e}`))}o(ps,"logError");function ec(e){console.log(Nr.bgYellow(`==== ${e} ====`))}o(ec,"logBanner");var jy=gt(require("fs"));function io(){return"0.4.12"}o(io,"getVersion");var jF=gt(Ny());var Wl=Symbol("options_key");function ut(e){return(t,r)=>{var n,i;if(e!=null){let s={...Reflect.getMetadata(Wl,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(Wl,s,t)}}}o(ut,"YargOption");function ky(e){let t=Reflect.getMetadata(Wl,e.prototype);if(!t)throw new Error(`Options for ${e.name} were not defined`);return t}o(ky,"getYargsOption");function tc(e){return async t=>t.options(H$(e)).middleware(async r=>await U$(e,r),!0)}o(tc,"getBuilder");function H$(e){return Object.entries(ky(e)).reduce((t,[r,n])=>(t[r]=Object.fromEntries(Object.entries(n).filter(([i])=>!["envAlias","default"].includes(i))),t),{})}o(H$,"getYargsOptions");async function U$(e,t){let r=new e;for(let[n,i]of Object.entries(ky(e)))r[n]=t[n]??i.default;return r}o(U$,"loadYargsConfig");var v1=gt(Lh());var lP="Schema",fP="Enum",pP="Body",dP="Param",hP="Response",mP="ErrorResponse",Fh="z.void()",au="z.enum",cu={bindings:["z"],from:"zod"};var uu={input:"input.yaml",output:"output",splitByTags:!0,defaultTag:"Common",excludeTags:[],includeNamespaces:!0,importPath:"ts",extractEnums:!0,configs:{models:{outputFileNameSuffix:"models",namespaceSuffix:"Models"},endpoints:{outputFileNameSuffix:"api",namespaceSuffix:"Api"},queries:{outputFileNameSuffix:"queries",namespaceSuffix:"Queries"},acl:{outputFileNameSuffix:"acl",namespaceSuffix:"Acl"}},schemaSuffix:lP,enumSuffix:fP,additionalPropertiesDefaultValue:!1,removeOperationPrefixEndingWith:"Controller_"};var gP={"invalid-schema":"Invalid Schemas","invalid-operation-id":"Invalid Operation IDs","missing-path-parameter":"Missing Path Parameters","not-allowed-inline-enum":"Not Allowed Inline Enums","not-allowed-circular-schema":"Not Allowed Circular Schemas","missing-acl-condition-property":"Missing x-acl Condition Properties","missing-status-code":"Missing Status Codes"};var Bh={"Content-Type":"application/json",Accept:"application/json"},yP="data";var bP=o(e=>/^(?:[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+)$/.test(e),"isValidPropertyName"),Mn=o(e=>e.replace(/^[^a-zA-Z_$]*/g,"").replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var on=Symbol.for("@ts-pattern/matcher"),L3=Symbol.for("@ts-pattern/isVariadic"),fu="@ts-pattern/anonymous-select-key",Vh=o(e=>!!(e&&typeof e=="object"),"r"),lu=o(e=>e&&!!e[on],"i"),Zr=o((e,t,r)=>{if(lu(e)){let n=e[on](),{matched:i,selections:s}=n.match(t);return i&&s&&Object.keys(s).forEach(a=>r(a,s[a])),i}if(Vh(e)){if(!Vh(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],s=[];for(let a of e.keys()){let c=e[a];lu(c)&&c[L3]?s.push(c):s.length?i.push(c):n.push(c)}if(s.length){if(s.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<n.length+i.length)return!1;let a=t.slice(0,n.length),c=i.length===0?[]:t.slice(-i.length),u=t.slice(n.length,i.length===0?1/0:-i.length);return n.every((l,p)=>Zr(l,a[p],r))&&i.every((l,p)=>Zr(l,c[p],r))&&(s.length===0||Zr(s[0],u,r))}return e.length===t.length&&e.every((a,c)=>Zr(a,t[c],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||lu(s=i)&&s[on]().matcherType==="optional")&&Zr(i,t[n],r);var s})}return Object.is(t,e)},"s"),Bn=o(e=>{var t,r,n;return Vh(e)?lu(e)?(t=(r=(n=e[on]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?ia(e,Bn):ia(Object.values(e),Bn):[]},"o"),ia=o((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function ur(e){return Object.assign(e,{optional:o(()=>F3(e),"optional"),and:o(t=>Fe(e,t),"and"),or:o(t=>B3(e,t),"or"),select:o(t=>t===void 0?vP(e):vP(t,e),"select")})}o(ur,"u");function F3(e){return ur({[on]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return t===void 0?(Bn(e).forEach(i=>n(i,void 0)),{matched:!0,selections:r}):{matched:Zr(e,t,n),selections:r}},"match"),getSelectionKeys:o(()=>Bn(e),"getSelectionKeys"),matcherType:"optional"})})}o(F3,"h");function Fe(...e){return ur({[on]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return{matched:e.every(i=>Zr(i,t,n)),selections:r}},"match"),getSelectionKeys:o(()=>ia(e,Bn),"getSelectionKeys"),matcherType:"and"})})}o(Fe,"m");function B3(...e){return ur({[on]:()=>({match:o(t=>{let r={},n=o((i,s)=>{r[i]=s},"r");return ia(e,Bn).forEach(i=>n(i,void 0)),{matched:e.some(i=>Zr(i,t,n)),selections:r}},"match"),getSelectionKeys:o(()=>ia(e,Bn),"getSelectionKeys"),matcherType:"or"})})}o(B3,"d");function Pe(e){return{[on]:()=>({match:o(t=>({matched:!!e(t)}),"match")})}}o(Pe,"p");function vP(...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 ur({[on]:()=>({match:o(n=>{let i={[t??fu]:n};return{matched:r===void 0||Zr(r,n,(s,a)=>{i[s]=a}),selections:i}},"match"),getSelectionKeys:o(()=>[t??fu].concat(r===void 0?[]:Bn(r)),"getSelectionKeys")})})}o(vP,"y");function zr(e){return typeof e=="number"}o(zr,"v");function qn(e){return typeof e=="string"}o(qn,"b");function Dn(e){return typeof e=="bigint"}o(Dn,"w");var J9=ur(Pe(function(e){return!0}));var Ln=o(e=>Object.assign(ur(e),{startsWith:o(t=>{return Ln(Fe(e,(r=t,Pe(n=>qn(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:o(t=>{return Ln(Fe(e,(r=t,Pe(n=>qn(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:o(t=>Ln(Fe(e,(r=>Pe(n=>qn(n)&&n.length>=r))(t))),"minLength"),length:o(t=>Ln(Fe(e,(r=>Pe(n=>qn(n)&&n.length===r))(t))),"length"),maxLength:o(t=>Ln(Fe(e,(r=>Pe(n=>qn(n)&&n.length<=r))(t))),"maxLength"),includes:o(t=>{return Ln(Fe(e,(r=t,Pe(n=>qn(n)&&n.includes(r)))));var r},"includes"),regex:o(t=>{return Ln(Fe(e,(r=t,Pe(n=>qn(n)&&!!n.match(r)))));var r},"regex")}),"j"),X9=Ln(Pe(qn)),Gr=o(e=>Object.assign(ur(e),{between:o((t,r)=>Gr(Fe(e,((n,i)=>Pe(s=>zr(s)&&n<=s&&i>=s))(t,r))),"between"),lt:o(t=>Gr(Fe(e,(r=>Pe(n=>zr(n)&&n<r))(t))),"lt"),gt:o(t=>Gr(Fe(e,(r=>Pe(n=>zr(n)&&n>r))(t))),"gt"),lte:o(t=>Gr(Fe(e,(r=>Pe(n=>zr(n)&&n<=r))(t))),"lte"),gte:o(t=>Gr(Fe(e,(r=>Pe(n=>zr(n)&&n>=r))(t))),"gte"),int:o(()=>Gr(Fe(e,Pe(t=>zr(t)&&Number.isInteger(t)))),"int"),finite:o(()=>Gr(Fe(e,Pe(t=>zr(t)&&Number.isFinite(t)))),"finite"),positive:o(()=>Gr(Fe(e,Pe(t=>zr(t)&&t>0))),"positive"),negative:o(()=>Gr(Fe(e,Pe(t=>zr(t)&&t<0))),"negative")}),"x"),eH=Gr(Pe(zr)),Fn=o(e=>Object.assign(ur(e),{between:o((t,r)=>Fn(Fe(e,((n,i)=>Pe(s=>Dn(s)&&n<=s&&i>=s))(t,r))),"between"),lt:o(t=>Fn(Fe(e,(r=>Pe(n=>Dn(n)&&n<r))(t))),"lt"),gt:o(t=>Fn(Fe(e,(r=>Pe(n=>Dn(n)&&n>r))(t))),"gt"),lte:o(t=>Fn(Fe(e,(r=>Pe(n=>Dn(n)&&n<=r))(t))),"lte"),gte:o(t=>Fn(Fe(e,(r=>Pe(n=>Dn(n)&&n>=r))(t))),"gte"),positive:o(()=>Fn(Fe(e,Pe(t=>Dn(t)&&t>0))),"positive"),negative:o(()=>Fn(Fe(e,Pe(t=>Dn(t)&&t<0))),"negative")}),"A"),tH=Fn(Pe(Dn)),rH=ur(Pe(function(e){return typeof e=="boolean"})),nH=ur(Pe(function(e){return typeof e=="symbol"})),iH=ur(Pe(function(e){return e==null})),oH=ur(Pe(function(e){return e!=null}));var Gh=class Gh extends Error{constructor(t){let r;try{r=JSON.stringify(t)}catch{r=t}super(`Pattern matching error: no pattern matches value ${r}`),this.input=void 0,this.input=t}};o(Gh,"W");var Hh=Gh,Uh={matched:!1,value:void 0};function Ot(e){return new zh(e,Uh)}o(Ot,"z");var na=class na{constructor(t,r){this.input=void 0,this.state=void 0,this.input=t,this.state=r}with(...t){if(this.state.matched)return this;let r=t[t.length-1],n=[t[0]],i;t.length===3&&typeof t[1]=="function"?i=t[1]:t.length>2&&n.push(...t.slice(1,t.length-1));let s=!1,a={},c=o((l,p)=>{s=!0,a[l]=p},"a"),u=!n.some(l=>Zr(l,this.input,c))||i&&!i(this.input)?Uh:{matched:!0,value:r(s?fu in a?a[fu]:a:this.input,this.input)};return new na(this.input,u)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new na(this.input,n?{matched:!0,value:r(this.input,this.input)}:Uh)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new Hh(this.input)}run(){return this.exhaustive()}returnType(){return this}};o(na,"I");var zh=na;var _P=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with"];var Zh=2,SP=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],OP=["query","header","path"],Vn=["get","put","post","delete","options","head","patch","trace"],PP=["string","number","integer","boolean"],Wh=["allOf","anyOf","oneOf"];function Hn(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}o(Hn,"pick");var Ve=o(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),Mi=o(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),pu=o(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),ht=o(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),EP=o(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),Kh=o((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),$P=o((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix"),V3=o(e=>{var n;let t=e.reduce((i,s)=>({...i,[s]:(i[s]??0)+1}),{});return(n=Object.entries(t).sort((i,s)=>i[1]===s[1]?s[0].length-i[0].length:s[1]-i[1])[0])==null?void 0:n[0]},"getLongestMostCommon"),Yh=o(e=>{let t=e.map(Ve).map(wP).map(r=>H3(r)).flat();return V3(t)},"getMostCommonAdjacentCombinationSplit"),wP=o(e=>e.split(/(?<![A-Z])(?=[A-Z])/).filter(Boolean),"splitByUppercase"),xP=o(e=>wP(e).join(" "),"camelToSpaceSeparated"),H3=o((e,t=["dto","by","for","of","in","to","and","with"])=>{var n;let r=[];for(let i=0;i<e.length;i++)if(!t.includes(e[i].toLowerCase()))for(let s=i+1;s<=e.length;s++)t.includes((n=e[s-1])==null?void 0:n.toLowerCase())||r.push(e.slice(i,s).join(""));return r},"getAdjacentStringCombinations");function Un(e){return EP(e)}o(Un,"formatTag");function qi(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return Un(r??t.defaultTag)}o(qi,"getOperationTag");function AP(e,t){let r={};for(let n in e.paths){let i=e.paths[n],s=Hn(i,Vn);for(let a in s){let c=s[a];if(!c||c.deprecated&&!(t!=null&&t.withDeprecatedEndpoints))continue;let u=t.splitByTags?qi(c,t):t.defaultTag;r[u]||(r[u]=[]),r[u].push(c)}}return r}o(AP,"getOperationsByTag");var CP=o(e=>`#/components/schemas/${e}`,"getSchemaRef"),Di=o(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),Uo=o(e=>Di(e).split("/").at(-1),"getSchemaNameByRef");function Ie(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}o(Ie,"isReferenceObject");function Xh(e){let t=U3(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/--+/g,"-").replace(/-+/g,"_").replace(/[^\w-]+/g,"_");return ht(t)}o(Xh,"normalizeString");function TP(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}o(TP,"wrapWithQuotesIfNeeded");function jP(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}o(jP,"unwrapQuotesIfNeeded");function U3(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}o(U3,"prefixStringStartingWithNumberIfNeeded");function em(e){let t=e.replaceAll("_","#");return ht(t.replaceAll("-","_")).replaceAll("#","_")}o(em,"pathParamToVariableName");var Li=o(e=>PP.includes(e),"isPrimitiveType");function RP(e){return e.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/([\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\uFFFE\uFFFF])/g,(t,r)=>{let n=r.codePointAt(),i=n.toString(16);return n<=255?`\\x${`00${i}`.slice(-2)}`:`\\u${`0000${i}`.slice(-4)}`}).replace(/\//g,"\\/")}o(RP,"escapeControlCharacters");function Wr(e){return e.includes("application/")&&e.includes("json")||SP.includes(e)||e.includes("text/")}o(Wr,"isParamMediaTypeAllowed");function du(e){return e>=200&&e<300}o(du,"isMainResponseStatus");function hu(e){return!(e>=200&&e<300)}o(hu,"isErrorStatus");function mu(e){return e==="application/json"}o(mu,"isMediaTypeAllowed");function Qh({path:e,method:t,operation:r,options:n,keepOperationPrefixWithoutEnding:i}){let s=`${t}${G3(e)}`,a=r.operationId?Mn(r.operationId):s;if(n.removeOperationPrefixEndingWith&&i)return a.split(n.removeOperationPrefixEndingWith).map((u,l)=>l===0?u:Ve(u)).join("");if(n.removeOperationPrefixEndingWith&&!i){let c=new RegExp(`^.*${n.removeOperationPrefixEndingWith}`);a=a.replace(c,"")}return _P.includes(a)?s:a}o(Qh,"getOperationName");function oa({path:e,method:t,operation:r,operationsByTag:n,options:i}){let s=i.splitByTags?qi(r,i):i.defaultTag,a=Qh({path:e,method:t,operation:r,options:i});return n[s].filter(u=>Qh({path:e,method:t,operation:u,options:i})===a).length===1?a:Qh({path:e,method:t,operation:r,options:i,keepOperationPrefixWithoutEnding:!0})}o(oa,"getUniqueOperationName");function NP(e,t,r){let n=[];for(let i in e.paths){let s=e.paths[i],a=Hn(s,Vn);for(let c in a){let u=a[c];if(!u||u.deprecated&&!(r!=null&&r.withDeprecatedEndpoints))continue;let l=oa({path:i,method:c,operation:u,operationsByTag:t,options:r});n.push(l)}}return n}o(NP,"getUniqueOperationNamesWithoutSplitByTags");var IP=/({\w+})/g,z3=/[^\w\-]+/g;function G3(e){e=Ve(pu(e.replaceAll("/","-")).replaceAll("-",""));let t=[...e.matchAll(IP)];if(t.length>0){let r=t.sort((n,i)=>n.index-i.index)[t.length-1][0];e=`${e.replace(IP,"")}By${Ve(r.slice(1,-1))}`}return e.replace(z3,"_")}o(G3,"pathToVariableName");var Jh=/{(\b\w+(?:-\w+)*\b)}/g;function kP(e){let t=e.match(Jh);return t===null?e.replaceAll(Jh,":$1"):(t.forEach(r=>{let n=em(r.replaceAll(Jh,":$1"));e=e.replaceAll(r,n)}),e)}o(kP,"replaceHyphenatedPath");function Gt(e){return!Ie(e)}o(Gt,"isSchemaObject");function MP(e){return e.type==="array"}o(MP,"isArraySchemaObject");function qP(e){if(!e.allOf)throw new Error("Function inferRequiredSchema is specialized to handle item with required only in an allOf array.");let[t,r]=e.allOf.reduce((i,s)=>{if(Z3(s)){let a=s.required;i[0].push(...a??[])}else i[1].push(s);return i},[[],[]]),n={properties:t.reduce((i,s)=>(i[s]={},i),{}),type:"object",required:t};return{noRequiredOnlyAllof:r,composedRequiredSchema:n,patchRequiredSchemaInLoop:o((i,s)=>{if(Ie(i)){let a=s(i.$ref);a&&n.required.forEach(c=>{var u;n.properties[c]=((u=a==null?void 0:a.properties)==null?void 0:u[c])??{}})}else{let a=i.properties??{};n.required.forEach(c=>{a[c]&&(n.properties[c]=a[c]??{})})}},"patchRequiredSchemaInLoop")}}o(qP,"inferRequiredSchema");var Z3=o(e=>!Ie(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function zn({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${Mi(t)}/`:""}${Mi(t)}.${i}`:i}o(zn,"getTagFileName");var Je=o(({type:e,tag:t,options:r})=>`${Ve(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var sn=o((e,t)=>Kh(Ve(Xh(e)),t),"getZodSchemaName"),tm=o((e,t,r)=>Kh(Ve(Xh(e)),`${t}${r}`),"getEnumZodSchemaName"),Dt=o(e=>!e.startsWith("z."),"isNamedZodSchema"),DP=o(e=>e.startsWith(au),"isEnumZodSchema"),Fi=o((e,t,r)=>t?e:`${r}_${e}`,"getZodSchemaOperationName"),gu=o(e=>ht(`${e}_${pP}`),"getBodyZodSchemaName"),LP=o((e,t)=>ht(`${e}_${t}${dP}`),"getParamZodSchemaName"),W3=o(e=>ht(`${e}${hP}`),"getMainResponseZodSchemaName"),K3=o((e,t)=>ht(`${e}_${t}_${mP}`),"getErrorResponseZodSchemaName");function yu({statusCode:e,operationName:t,isUniqueOperationName:r,tag:n}){let i=Number(e),s=Fi(t,r,n);return!du(i)&&e!=="default"&&hu(i)?K3(s,e):W3(s)}o(yu,"getResponseZodSchemaName");var sa=o((e,t)=>$P(e,t.schemaSuffix),"getZodSchemaInferedTypeName"),FP=o((e,t)=>Dt(t)?`${e.options.includeNamespaces?`${Je({type:"models",tag:e.getTagByZodSchemaName(t),options:e.options})}.`:""}${t}`:t,"getImportedZodSchemaName"),rm=o((e,t)=>Dt(t)?`${e.options.includeNamespaces?`${Je({type:"models",tag:e.getTagByZodSchemaName(t),options:e.options})}.`:""}${sa(t,e.options)}`:t,"getImportedZodSchemaInferedTypeName");function BP(e){return Ot(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}o(BP,"primitiveTypeToTsType");var aa=o(e=>Mi(ht(e.operationName)),"getEndpointName");function VP(e,t){return`${t.includeNamespaces?`${Je({type:"endpoints",tag:ca(e,t),options:t})}.`:""}${aa(e)}`}o(VP,"getImportedEndpointName");var HP=o(e=>e.path.replace(/:([a-zA-Z0-9_]+)/g,"${$1}"),"getEndpointPath");function ca(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return Un(r??t.defaultTag)}o(ca,"getEndpointTag");function nm(e,t){return t.parameters.map(r=>{var i,s,a,c;let n="string";if(Dt(r.zodSchema))n=rm(e,r.zodSchema);else if((i=r.parameterObject)!=null&&i.schema&&Gt(r.parameterObject.schema)){let u=(a=(s=r.parameterObject)==null?void 0:s.schema)==null?void 0:a.type;u&&Li(u)&&(n=BP(u))}return{name:Mn(r.name),type:n,paramType:r.type,required:((c=r.parameterObject)==null?void 0:c.required)??!0,parameterObject:r.parameterObject,bodyObject:r.bodyObject}}).sort((r,n)=>{if(r.required===n.required){let i=["Path","Body","Query","Header"];return i.indexOf(r.paramType)-i.indexOf(n.paramType)}return r.required?-1:1})}o(nm,"mapEndpointParamsToFunctionParams");function UP(e){let t=e.parameters.filter(i=>i.type==="Query").map(i=>{let s=bP(i.name)?i.name:`"${i.name}"`,a=Mn(i.name);return{...i,name:s,value:a}}),r={};return e.requestFormat!==Bh["Content-Type"]&&(r["Content-Type"]=`'${e.requestFormat}'`),e.responseFormat&&e.responseFormat!==Bh.Accept&&(r.Accept=`'${e.responseFormat}'`),e.parameters.filter(i=>i.type==="Header").forEach(i=>{r[i.name]=Mn(i.name)}),{...t.length>0?{params:t}:{},...Object.keys(r).length?{headers:r}:{}}}o(UP,"getEndpointConfig");function bu(e){return{type:"invalid-schema",message:e}}o(bu,"getInvalidSchemaError");function zP(e){return{type:"invalid-operation-id",message:`Operation ${e}`}}o(zP,"getInvalidOperationIdError");function GP(e,t){return{type:"missing-path-parameter",message:`Path ${t} is missing [${e.map(({name:r})=>r).join(", ")}]`}}o(GP,"getMissingPathParameterError");function ZP(e){return{type:"not-allowed-inline-enum",message:e}}o(ZP,"getNotAllowedInlineEnumError");function WP(e){return{type:"not-allowed-circular-schema",message:e}}o(WP,"getNotAllowedCircularSchemaError");function KP(e,t,r){return{type:"missing-acl-condition-property",message:`Condition property ${e} is not found in parameters or body in operation ${YP(t,r)}`}}o(KP,"getMissingAclConditionPropertyError");function im(e,t,r){return{type:"missing-status-code",message:`Missing status code ${e} in operation ${YP(t,r)}`}}o(im,"getMissingStatusCodeError");function YP(e,t){return e.operationId??`${t.method} ${t.path}`}o(YP,"getOperationDescriptor");function QP(e){return e.reduce((t,r)=>({...t,[r.type]:[...t[r.type]??[],r.message]}),{})}o(QP,"groupByType");function Kr({schema:e,meta:t,options:r}){let n=[];Ot(e.type).with("string",()=>n.push(J3(e))).with("number","integer",()=>n.push(eq(e))).with("array",()=>n.push(tq(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
141
141
  `,"\r",`\r
142
142
  `].some(s=>String.prototype.includes.call(e.description,s))?n.push(`describe(\`${e.description}\`)`):n.push(`describe("${e.description}")`));let i=n.concat(Y3(e,t),(r==null?void 0:r.withDefaultValues)!==!1?Q3(e):[]).filter(Boolean).join(".");return i?`.${i}`:""}o(Kr,"getZodChain");function Y3(e,t){return e.nullable&&!(t!=null&&t.isRequired)?"nullish()":e.nullable?"nullable()":t!=null&&t.isRequired?"":"optional()"}o(Y3,"getZodChainablePresence");function Q3(e){return e.default!==void 0?`default(${Ot(e.type).with("number","integer",()=>jP(e.default)).otherwise(()=>JSON.stringify(e.default))})`:""}o(Q3,"getZodChainableDefault");function J3(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(${X3(e.pattern)})`),e.format){let r=Ot(e.format).with("email",()=>"email()").with("hostname","uri",()=>"url()").with("uuid",()=>"uuid()").with("date-time",()=>"datetime({ offset: true })").otherwise(()=>"");r&&t.push(r)}return t.join(".")}o(J3,"getZodChainableStringValidations");function X3(e){return e.startsWith("/")&&e.endsWith("/")&&(e=e.slice(1,-1)),e=RP(e),`/${e}/`}o(X3,"formatPatternIfNeeded");function eq(e){let t=[];return e.enum?"":(e.type==="integer"&&t.push("int()"),e.minimum!==void 0?e.exclusiveMinimum===!0?t.push(`gt(${e.minimum})`):t.push(`gte(${e.minimum})`):typeof e.exclusiveMinimum=="number"&&t.push(`gt(${e.exclusiveMinimum})`),e.maximum!==void 0?e.exclusiveMaximum===!0?t.push(`lt(${e.maximum})`):t.push(`lte(${e.maximum})`):typeof e.exclusiveMaximum=="number"&&t.push(`lt(${e.exclusiveMaximum})`),e.multipleOf&&t.push(`multipleOf(${e.multipleOf})`),t.join("."))}o(eq,"getZodChainableNumberValidations");function tq(e){let t=[];return e.minItems&&t.push(`min(${e.minItems})`),e.maxItems&&t.push(`max(${e.maxItems})`),t.join(".")}o(tq,"getZodChainableArrayValidations");var Bi=o(e=>e.reduce((t,r)=>t+r,0),"sum");function ot(e,t){if(!t)return e;if(Ie(t))return e+2;if(Array.isArray(t.type))return t.type.length===1?At("oneOf")+ot(e,{...t,type:t.type[0]}):e+At("oneOf")+Bi(t.type.map(r=>ot(0,{...t,type:r})));if(t.oneOf)return t.oneOf.length===1?At("oneOf")+ot(e,t.oneOf[0]):e+At("oneOf")+Bi(t.oneOf.map(r=>ot(0,r)));if(t.anyOf)return t.anyOf.length===1?At("anyOf")+ot(e,t.anyOf[0]):e+At("anyOf")+Bi(t.anyOf.map(r=>ot(0,r)));if(t.allOf)return t.allOf.length===1?At("allOf")+ot(e,t.allOf[0]):e+At("allOf")+Bi(t.allOf.map(r=>ot(0,r)));if(!t.type)return e;if(Li(t.type))return t.enum?e+JP(t)+At("enum")+Bi(t.enum.map(r=>ot(0,r))):e+JP(t);if(t.type==="array")return t.items?At("array")+ot(e,t.items):At("array")+ot(e);if(t.type==="object"||t.properties||t.additionalProperties){if(t.additionalProperties)return t.additionalProperties===!0?At("record")+ot(e):At("record")+ot(e,t.additionalProperties);if(t.properties){let r=Object.values(t.properties);return e+At("object")+Bi(r.map(n=>ot(0,n)))}return At("empty-object")+ot(e)}return e}o(ot,"getOpenAPISchemaComplexity");function JP(e){return Ot(e.type).with("string","number","integer","boolean",()=>1).otherwise(()=>0)}o(JP,"complexityByType");function At(e){return Ot(e).with("oneOf",()=>2).with("anyOf",()=>3).with("allOf",()=>2).with("enum","array","record","empty-object",()=>1).with("object",()=>2).otherwise(()=>0)}o(At,"complexityByComposite");var om=class om{constructor(t,r,n={referencedBy:[]},i){this.schema=t;this.resolver=r;Ie(t)&&(this.ref=t.$ref),i&&(this.enumRef=i),this.meta={...n,referencedBy:[...(n==null?void 0:n.referencedBy)??[]]},this.ref&&this.meta.referencedBy.push(this)}code;ref;enumRef;children=[];meta;getCodeString(t,r){var s,a;if(!this.ref&&this.code)return this.code;if(!this.ref)throw new Error("Zod schema is missing both ref and code");let n=(s=this.resolver)==null?void 0:s.getZodSchemaNameByRef(this.ref);if(!n)return this.ref;let i=(a=this.resolver)==null?void 0:a.getTagByZodSchemaName(n);return r!=null&&r.includeNamespaces&&i&&i!==t?`${Je({type:"models",tag:i,options:r})}.${n}`:n}get complexity(){return ot(0,this.schema)}assign(t){return this.code=t,this}inherit(t){return t&&t.children.push(this),this}};o(om,"ZodSchema");var ua=om;function Ge({schema:e,resolver:t,meta:r,tag:n}){var y;let i=new ua(e,t,r),s={parent:i.inherit(r==null?void 0:r.parent),referencedBy:[...i.meta.referencedBy]},a={resolver:t,meta:s,tag:n};if(Ie(e))return rq({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});let c=iq({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(c)return c;let u=nq({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(u)return u;let l=oq({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(l)return l;let p=sq({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(p)return p;let f=aq({schema:e,zodSchema:i,resolver:t,meta:s,tag:n});if(f)return f;let d=t.options.allReadonly?".readonly()":"";if(MP(e))return e.items?i.assign(`z.array(${Ge({...a,schema:e.items}).getCodeString(n,t.options)}${Kr({schema:e.items,meta:{...s,isRequired:!0},options:t.options})})${d}`):i.assign(`z.array(z.any())${d}`);let h=e.type?e.type.toLowerCase():void 0;if(h==="object"||e.properties||e.additionalProperties){let b=t.options.additionalPropertiesDefaultValue!==void 0?t.options.additionalPropertiesDefaultValue:!0,$=(e.additionalProperties===null||e.additionalProperties===void 0?b:e.additionalProperties)===!1?"":".passthrough()";if(typeof e.additionalProperties=="object"&&Object.keys(e.additionalProperties).length>0)return i.assign(`z.record(${Ge({...a,schema:e.additionalProperties}).getCodeString(n,t.options)+Kr({schema:e.additionalProperties,meta:{...s,isRequired:!0},options:t.options})})`);let w=e.required&&e.required.length>0,T=t.options.withImplicitRequiredProps?!1:!((y=e.required)!=null&&y.length),I="{}";e.properties&&(I="{ "+Object.entries(e.properties).map(([we,Oe])=>{var M;let J={...s,isRequired:T?!0:w?(M=e.required)==null?void 0:M.includes(we):t.options.withImplicitRequiredProps,name:we},k=Oe;if(Ie(Oe)&&t&&(k=t.getSchemaByRef(Oe.$ref),!k))throw new Error(`Schema ${Oe.$ref} not found`);let j=Ge({...a,schema:Oe,meta:J}).getCodeString(n,t.options)+Kr({schema:k,meta:J,options:t.options});return[we,j]}).map(([we,Oe])=>`${TP(we)}: ${Oe}`).join(", ")+" }");let C=T?".partial()":"",ce=t.options.strictObjects?".strict()":"";return i.assign(`z.object(${I})${C}${ce}${$}${d}`)}if(!h)return i.assign("z.unknown()");throw new Error(`Unsupported schema type: ${h}`)}o(Ge,"getZodSchema");function rq({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){if(!Ie(e))return;let s=t.meta.referencedBy.slice(0,-1).map(u=>u.ref?r.getZodSchemaNameByRef(u.ref)??u.ref:void 0).filter(Boolean),a=r.getZodSchemaNameByRef(e.$ref);if(s.length>1&&s.includes(a))return t.assign(r.getCodeByZodSchemaName(t.ref));let c=r.getCodeByZodSchemaName(e.$ref);if(!c){let u=r.getSchemaByRef(e.$ref);if(!u)throw new Error(`Schema ${e.$ref} not found`);c=Ge({schema:u,resolver:r,meta:n,tag:i}).getCodeString(i,r.options)}return r.getCodeByZodSchemaName(a)||r.setZodSchema(a,c,i),t}o(rq,"getReferenceZodSchema");function nq({schema:e,zodSchema:t,resolver:r,meta:n,tag:i}){var a;if(!Gt(e)||!e.oneOf)return;if(e.oneOf.length===1){let c=Ge({schema:e.oneOf[0],resolver:r,meta:n,tag:i});return t.assign(c.getCodeString(i,r.options))}let s=(a=e.oneOf)==null?void 0:a.some(c=>Gt(c)&&((c==null?void 0:c.allOf)||[]).length>1);if(e.discriminator&&!s){let c=e.discriminator.propertyName;return t.assign(`
143
143
  z.discriminatedUnion("${c}", [${e.oneOf.map(u=>Ge({schema:u,resolver:r,meta:n,tag:i}).getCodeString(i,r.options)).join(", ")}])
@@ -148,7 +148,7 @@ ${c.map(u=>`- ${u}`).join(`
148
148
  ${s.map(a=>`- ${a}`).join(`
149
149
  `)}
150
150
  `)}return n.validationErrors}o(b1,"checkOpenAPIDoc");function _q(e,t){return["models","endpoints","queries"].map(r=>fa({output:t.output,fileName:zn({tag:e,type:r,options:t})}))}o(_q,"getOutputFileNames");async function _1({input:e,excludeTags:t,verbose:r,...n}){let i=Date.now();r&&rr("Parsing OpenAPI spec...");let s=await v1.default.bundle(e);r&&vn("Parsing finished."),r&&rr("Running check...");let a=b1(s,{input:e,excludeTags:t.split(","),...n});if(r&&rr(`TIME: ${Date.now()-i}ms`),a.length===0)vn("Check finished.");else throw new Error(`Check finished. Found ${a.length} issues.`)}o(_1,"check");var Zn=class Zn{input;splitByTags;defaultTag;excludeTags;verbose};o(Zn,"CheckOptions"),at([ut({envAlias:"input",demandOption:!0})],Zn.prototype,"input",2),at([ut({envAlias:"splitByTags",default:!0,type:"boolean"})],Zn.prototype,"splitByTags",2),at([ut({envAlias:"defaultTag",default:"Common"})],Zn.prototype,"defaultTag",2),at([ut({envAlias:"excludeTags",default:""})],Zn.prototype,"excludeTags",2),at([ut({envAlias:"verbose",default:!1,type:"boolean"})],Zn.prototype,"verbose",2);var pm=Zn,S1={command:"check",describe:"Check OpenAPI spec",builder:tc(pm),handler:o(async e=>{let t=await e;return t.verbose&&(ec(`OpenAPI CodeGen ${io()}`),fs("input",t.input)),_1(t)},"handler")};var B2=gt(Lh()),V2=require("child_process");var O1="acl/app.ability",pa="AllAbilities",Ir={abilityTuple:"AbilityTuple",pureAbility:"PureAbility",forcedSubject:"ForcedSubject",subject:"subject"},dm={bindings:[Ir.abilityTuple,Ir.pureAbility,Ir.forcedSubject,Ir.subject],from:"@casl/ability"};var P1=o(e=>`Use${Ve(ht(e.operationName))}Ability`,"getAbilityTypeName"),E1=o(e=>`canUse${Ve(ht(e.operationName))}`,"getAbilityFunctionName"),$1=o(e=>{var t;return(t=e.acl)==null?void 0:t[0].action},"getAbilityAction"),w1=o(e=>{var t;return(t=e.acl)==null?void 0:t[0].subject},"getAbilitySubject"),x1=o(e=>{var t;return!!((t=hm(e))!=null&&t.length)},"hasAbilityConditions"),hm=o(e=>{var t;return(t=e.acl)==null?void 0:t[0].conditionsTypes},"getAbilityConditionsTypes"),A1=o(e=>{var t;return(t=e.acl)==null?void 0:t[0].description},"getAbilityDescription"),Ou=o(e=>`${Ve(e)}${pa}`,"getTagAllAbilitiesName");var mm="src/data",gm="@/data",ym="AppRestClient",I1={bindings:[ym],from:"@/util/rest/clients/app-rest-client"},da={query:"AppQueryOptions",mutation:"AppMutationOptions"},C1={bindings:[da.query,da.mutation],from:"@/types/react-query"};function Wn({resolver:e,tag:t,zodSchemas:r=[],zodSchemasAsTypes:n=[]}){let i="models",s=o(u=>e.getTagByZodSchemaName(u),"getTag"),a=bm({type:i,tag:t,entities:r,getTag:s,getEntityName:o(u=>u,"getEntityName"),options:e.options}),c=bm({type:i,tag:t,entities:n,getTag:s,getEntityName:o(u=>sa(u,e.options),"getEntityName"),options:e.options});return Sq(e.options,a,c)}o(Wn,"getModelsImports");function T1({tag:e,endpoints:t,options:r}){return bm({type:"endpoints",tag:e,entities:t,getTag:o(n=>ca(n,r),"getTag"),getEntityName:aa,options:r})}o(T1,"getEndpointsImports");function j1({tags:e,entityName:t,getAliasEntityName:r,options:n}){let i=new Map;return e.forEach(s=>{let a=`${t}${r?` as ${r(s)}`:""}`;i.has(s)?n.includeNamespaces||i.get(s).bindings.push(a):i.set(s,{bindings:[n.includeNamespaces?Je({type:"acl",tag:s,options:n}):a],from:`${R1(n)}${zn({type:"acl",tag:s,includeTagDir:!0,options:n})}`})}),Array.from(i.values())}o(j1,"getAclImports");function R1(e){let t=gm;return e.importPath==="relative"?t="../":e.importPath==="absolute"?t=e.output:new RegExp(`${mm}`,"g").test(e.output)&&(t=e.output.replace(new RegExp(`.*${mm}`,"g"),gm)),`${t}/`.replace(/\/\//g,"/")}o(R1,"getImportPath");function bm({type:e="models",tag:t,entities:r,getTag:n,getEntityName:i,options:s}){let a=new Map;return r.forEach(c=>{let u=n(c);if(a.has(u))s.includeNamespaces||a.get(u).bindings.push(i(c));else{let l=t===u;a.set(u,{bindings:[s.includeNamespaces?Je({type:e,tag:u,options:s}):i(c)],from:`${l?"./":R1(s)}${zn({type:e,tag:u,includeTagDir:!l,options:s})}`})}}),Array.from(a.values())}o(bm,"getImports");function Sq(e,...t){let r=new Map;return t.forEach(n=>{n.forEach(i=>{r.has(i.from)?e.includeNamespaces||r.get(i.from).bindings.push(...i.bindings):r.set(i.from,i)})}),Array.from(r.values()).map(n=>({...n,bindings:It(n.bindings)}))}o(Sq,"mergeImports");var pg=gt(Qn());var fn=gt(Qn());function E2(){dL(),hL(),mL(),gL(),yL(),bL(),vL(),_L()}o(E2,"registerAclHbsHelpers");function dL(){fn.default.registerHelper("abilityTypeName",P1)}o(dL,"registerAbilityTypeNameHelper");function hL(){fn.default.registerHelper("abilityFunctionName",E1)}o(hL,"registerAbilityFunctionNameHelper");function mL(){fn.default.registerHelper("ablityAction",$1)}o(mL,"registerAbilityActionHelper");function gL(){fn.default.registerHelper("ablitySubject",w1)}o(gL,"registerAbilitySubjectHelper");function yL(){fn.default.registerHelper("hasAbilityConditions",x1)}o(yL,"registerHasAbilityConditionsHelper");function bL(){fn.default.registerHelper("abilityConditionsTypes",hm)}o(bL,"registerAbilityConditionsTypesHelper");function vL(){fn.default.registerHelper("abilityDescription",A1)}o(vL,"registerAbilityDescriptionHelper");function _L(){fn.default.registerHelper("tagAllAbilitiesName",Ou)}o(_L,"registerTagAllAbilitiesNameHelper");var ol=gt(Qn());function $2(){SL(),OL(),PL()}o($2,"registerCommonHbsHelpers");function SL(){ol.default.registerHelper("isEqual",(e,t)=>e===t)}o(SL,"registerIsEqualHelper");function OL(){ol.default.registerHelper("commaSeparated",e=>e.join(", "))}o(OL,"registerCommaSeparatedListHelper");function PL(){ol.default.registerHelper("addAsteriskAfterNewLine",e=>e.replace(/\n/g,`
151
- *`))}o(PL,"registerAddAsteriskAfterNewLineHelper");var Jn=gt(Qn());function w2(e){EL(),$L(e.options),AL(e),wL(),xL(),IL(e),CL()}o(w2,"registerEndpointsHbsHelpers");function EL(){Jn.default.registerHelper("endpointName",aa)}o(EL,"registerEndpointNameHelper");function $L(e){Jn.default.registerHelper("importedEndpointName",t=>VP(t,e))}o($L,"registerImportedEndpointNameHelper");function wL(){Jn.default.registerHelper("endpointPath",HP)}o(wL,"registerEndpointPathHelper");function xL(){Jn.default.registerHelper("endpointBody",e=>e.parameters.find(t=>t.type==="Body"))}o(xL,"registerEndpointBodyHelper");function AL(e){Jn.default.registerHelper("endpointParams",t=>nm(e,t))}o(AL,"registerEndpointParamsHelper");function IL(e){Jn.default.registerHelper("endpointArgs",t=>nm(e,t).map(r=>r.name).join(", "))}o(IL,"registerEndpointArgsHelper");function CL(){Jn.default.registerHelper("endpointParamDescription",e=>{var s,a,c,u,l;let t=[`${e.paramType} parameter`],r=((s=e.parameterObject)==null?void 0:s.description)||((a=e.bodyObject)==null?void 0:a.description);r&&t.push(r);let n,i;if((c=e.parameterObject)!=null&&c.schema&&Gt(e.parameterObject.schema)&&(n=(u=e.parameterObject)==null?void 0:u.schema),(l=e.bodyObject)!=null&&l.content){let f=Object.keys(e.bodyObject.content??{}).find(Wr);f&&(i=e.bodyObject.content[f],i.schema&&Gt(i.schema)&&(n=i.schema))}return n&&["description","minimum","exclusiveMinimum","maximum","exclusiveMaximum","minItems","minLength","minProperties","maxItems","maxLength","maxProperties","example"].filter(f=>n[f]).forEach(f=>{t.push(`${Ve(xP(f))}: \`${n[f]}\``)}),i!=null&&i.example&&t.push(`Example: \`${i.example}\``),t.join(". ")})}o(CL,"registerEndpointParamDescriptionHelper");var ei=gt(Qn());var Xn={query:"useQuery",mutation:"useMutation"},x2={bindings:[Xn.query,Xn.mutation],from:"@tanstack/react-query"};function A2(){TL(),jL(),RL(),NL(),kL(),ML(),qL()}o(A2,"registerPartialsHbsHelpers");function TL(){ei.default.registerHelper("genImport",e=>ti("import")({import:e}))}o(TL,"registerImportHelper");function jL(){ei.default.registerHelper("genEndpointParams",e=>ti("endpoint-params")({endpoint:e}))}o(jL,"registerGenerateEndpointParamsHelper");function RL(){ei.default.registerHelper("genEndpointConfig",e=>{let t=UP(e);return Object.keys(t).length===0?"":ti("endpoint-config")({endpointConfig:t})})}o(RL,"registerGenerateEndpointConfigHelper");function NL(){ei.default.registerHelper("genQueryKeys",e=>e.length===0?"":ti("query-keys")({endpoints:e}))}o(NL,"registerGenerateQueryKeysHelper");function kL(){ei.default.registerHelper("genQuery",e=>{let t,r;return Gn(e)?(t="query-use-query",r=Xn.query):(t="query-use-mutation",r=Xn.mutation),ti(t)({endpoint:e,queryHook:r})})}o(kL,"registerGenerateQueryHelper");function ML(){ei.default.registerHelper("genCaslAbilityType",e=>ti("casl-ability-type")({endpoint:e,abilityTupleType:Ir.abilityTuple}))}o(ML,"registerGenerateCaslAbilityTypeHelper");function qL(){ei.default.registerHelper("genCaslAbilityFunction",e=>ti("casl-ability-function")({endpoint:e}))}o(qL,"registerGenerateCaslAbilityFunctionHelper");var xa=gt(Qn());var I2=o(e=>`use${Ve(ht(e.operationName))}`,"getQueryName"),lg=o(e=>{let t=e.map(({path:s})=>s),r=/^\/[^\/]*/g,n=It(t.map(s=>s.match(r)).flat()),i=o(s=>n.length===1?"all":`all${Ve(pu(s.replace(/\//g,"")??""))}`,"getQueryKeyName");return n.filter(s=>s!==null).map(s=>({path:s,name:i(s??"")}))},"getAllQueryKeys"),C2=o((e,t)=>{let n=lg(t).find(({path:s})=>e.path.startsWith(s));if(!n)return[e.path];let i=e.path.substring(n.path.length);return[`...keys.${n.name}`,...i?[`"${i}"`]:[]]},"getEndpointPathQueryKeys");function T2(){DL(),LL(),FL(),BL()}o(T2,"registerQueryHbsHelpers");function DL(){xa.default.registerHelper("queryName",I2)}o(DL,"registerQueryNameHelper");function LL(){xa.default.registerHelper("allQueryKeys",lg)}o(LL,"registerQueryKeysHelper");function FL(){xa.default.registerHelper("endpointPathQueryKeys",C2)}o(FL,"registerEndpointPathQueryKeysHelper");function BL(){xa.default.registerHelper("isQuery",Gn)}o(BL,"registerIsQueryHelper");var fg=gt(Qn());function j2(e){VL(e.options),HL(e)}o(j2,"registerZodHbsHelpers");function VL(e){fg.default.registerHelper("zodInferedType",t=>sa(t,e))}o(VL,"registerInferedTypeHelper");function HL(e){fg.default.registerHelper("importedZodSchemaName",t=>FP(e,t))}o(HL,"registerImportedZodSchemaNameHelper");function pn(e,t){let r=fm(t);return $2(),j2(e),w2(e),T2(),E2(),A2(),pg.default.compile(r)}o(pn,"getHbsTemplateDelegate");function ti(e){let t=fm(`partials/${e}`);return pg.default.compile(t)}o(ti,"getHbsPartialTemplateDelegate");function R2({resolver:e,data:t,tag:r=""}){var u;let n=(u=t.get(r))==null?void 0:u.endpoints.filter(({acl:l})=>l&&l.length>0);if(!n||n.length===0)return;let i={...dm,bindings:[Ir.abilityTuple,...n.filter(({acl:l})=>l==null?void 0:l[0].conditions).length>0?[Ir.forcedSubject,Ir.subject]:[]]},s=n.reduce((l,p)=>{var d,h;let f=(h=(d=p.acl)==null?void 0:d[0].conditionsTypes)==null?void 0:h.reduce((y,b)=>[...y,...b!=null&&b.zodSchemaName?[b.zodSchemaName]:[]],[]);return[...l,...f??[]]},[]),a=Wn({resolver:e,tag:r,zodSchemasAsTypes:It(s)});return pn(e,"acl")({caslAbilityTupleImport:i,modelsImports:a,includeNamespace:e.options.includeNamespaces,namespace:Je({type:"acl",tag:r,options:e.options}),endpoints:n})}o(R2,"generateAcl");function N2(e,t){if(!t||t.length===0)return;let r={...dm,bindings:[Ir.pureAbility]},n=j1({tags:t,entityName:pa,getAliasEntityName:Ou,options:e.options}),i=t.map(a=>Je({type:"acl",tag:a,options:e.options}));return pn(e,"app-acl")({caslAbilityTupleImport:r,imports:n,allAbilities:pa,includeNamespace:e.options.includeNamespaces,tags:t,namespaces:i})}o(N2,"generateAppAcl");function k2({resolver:e,data:t,tag:r=""}){var l;let n=(l=t.get(r))==null?void 0:l.endpoints;if(!n||n.length===0)return;let i=n.map(p=>p.response),s=i.some(p=>!Dt(p)),a=n.reduce((p,f)=>[...p,...f.parameters],[]),c=Wn({resolver:e,tag:r,zodSchemas:It(i.filter(Dt)),zodSchemasAsTypes:It(a.map(p=>p.zodSchema).filter(Dt))});return pn(e,"endpoints")({restClientImport:I1,hasZodImport:s,zodImport:cu,modelsImports:c,includeNamespace:e.options.includeNamespaces,namespace:Je({type:"endpoints",tag:r,options:e.options}),restClientName:ym,endpoints:n})}o(k2,"generateEndpoints");function M2(e,t){let r=e.getRefByZodSchemaName(t);if(r){let i=Array.from(e.dependencyGraph.refsDependencyGraph[r]??[]).map(a=>e.getZodSchemaNameByRef(a)),s=e.getEnumZodSchemaNamesReferencedBySchemaRef(r);return[...i,...s]}let n=e.getCompositeZodSchemaByZodSchemaName(t);return n?Array.from(q2(n)).map(i=>e.getZodSchemaNameByRef(i)):[]}o(M2,"getZodSchemaRefs");function q2(e){return e.children.reduce((r,n)=>{let i=n.ref??n.enumRef;return i&&r.add(i),n.children.length>0&&q2(n).forEach(s=>r.add(s)),r},new Set)}o(q2,"getSchemaRefs");function D2({resolver:e,data:t,tag:r=""}){var u;let n=(u=t.get(r))==null?void 0:u.zodSchemas;if(!n||Object.keys(n).length===0)return;let i=Object.keys(n).reduce((l,p)=>[...l,...M2(e,p)],[]).filter(l=>!n[l]),s=Wn({resolver:e,tag:r,zodSchemas:i}),a=Object.entries(n).reduce((l,[p,f])=>{let d=e.getRefByZodSchemaName(p);return{...l,[p]:{code:f,isCircular:!!d&&e.isSchemaCircular(d),isEnum:DP(f)}}},{});return pn(e,"models")({zodImport:cu,modelsImports:s,includeNamespace:e.options.includeNamespaces,namespace:Je({type:"models",tag:r,options:e.options}),zodSchemasData:a})}o(D2,"generateModels");function L2({resolver:e,data:t,tag:r=""}){var d;let n=(d=t.get(r))==null?void 0:d.endpoints;if(!n||n.length===0)return;let i=n.filter(Gn),s=n.filter(XP),a={...x2,bindings:[...i.length>0?[Xn.query]:[],...s.length>0?[Xn.mutation]:[]]},c={...C1,bindings:[...i.length>0?[da.query]:[],...s.length>0?[da.mutation]:[]]},u=[...i,...s].reduce((h,y)=>[...h,...y.parameters],[]),l=Wn({resolver:e,tag:r,zodSchemasAsTypes:It(u.map(h=>h.zodSchema).filter(Dt))}),p=T1({tag:r,endpoints:n,options:e.options});return pn(e,"queries")({queryImport:a,queryTypesImport:c,modelsImports:l,endpointsImports:p,includeNamespace:e.options.includeNamespaces,namespace:Je({type:"queries",tag:r,options:e.options}),endpoints:n,queryEndpoints:i})}o(L2,"generateQueries");function F2(e,t){let r={...uu,...t},{resolver:n,data:i}=Su(e,r),s=[],a=[],c=["models","endpoints","queries","acl"],u={models:D2,endpoints:k2,queries:L2,acl:R2};i.forEach((p,f)=>{r.excludeTags.find(h=>h.toLowerCase()===f.toLowerCase())||c.forEach(h=>{let y=u[h]({resolver:n,data:i,tag:f});if(y){let b=fa({output:r.output,fileName:zn({tag:f,type:h,options:r})});s.push({fileName:b,content:y}),h==="acl"&&a.push(f)}})});let l=N2(n,a);if(l){let p=fa({output:r.output,fileName:O1});s.push({fileName:p,content:l})}return s}o(F2,"generateCodeFromOpenAPIDoc");async function H2({input:e,excludeTags:t,prettier:r,verbose:n,...i}){let s=Date.now();n&&rr("Parsing OpenAPI spec...");let a=await B2.default.bundle(e);n&&vn("Parsing finished."),n&&rr("Generating code...");let c=F2(a,{input:e,excludeTags:t.split(","),...i});n&&vn("Generation finished."),n&&rr("Writing files..."),y1(c),n&&vn("Writing finished."),r&&UL({output:i.output,verbose:n}),n&&rr(`TIME: ${Date.now()-s}ms`)}o(H2,"generate");function UL({output:e,verbose:t}){t&&rr("Running Prettier..."),(0,V2.exec)(`prettier --write ${e}`,r=>{t&&(r?ps(r,"Prettier error"):vn("Prettier finished."))})}o(UL,"execPrettier");var Lt=class Lt{input;output;includeNamespaces;splitByTags;defaultTag;excludeTags;importPath;extractEnums;removeOperationPrefixEndingWith;prettier;verbose};o(Lt,"GenerateOptions"),at([ut({envAlias:"input",demandOption:!0})],Lt.prototype,"input",2),at([ut({envAlias:"output",default:"output"})],Lt.prototype,"output",2),at([ut({envAlias:"includeNamespaces",default:!0,type:"boolean"})],Lt.prototype,"includeNamespaces",2),at([ut({envAlias:"splitByTags",default:!0,type:"boolean"})],Lt.prototype,"splitByTags",2),at([ut({envAlias:"defaultTag",default:"Common"})],Lt.prototype,"defaultTag",2),at([ut({envAlias:"excludeTags",default:""})],Lt.prototype,"excludeTags",2),at([ut({envAlias:"importPath",default:"ts",type:"string"})],Lt.prototype,"importPath",2),at([ut({envAlias:"extractEnums",default:!0,type:"boolean"})],Lt.prototype,"extractEnums",2),at([ut({envAlias:"removeOperationPrefixEndingWith",default:"Controller_"})],Lt.prototype,"removeOperationPrefixEndingWith",2),at([ut({envAlias:"prettier",default:!0,type:"boolean"})],Lt.prototype,"prettier",2),at([ut({envAlias:"verbose",default:!1,type:"boolean"})],Lt.prototype,"verbose",2);var dg=Lt,U2={command:"generate",describe:"Generate code from OpenAPI spec",builder:tc(dg),handler:o(async e=>{let t=await e;return t.verbose&&(ec(`OpenAPI CodeGen ${io()}`),fs("input",t.input),fs("output",t.output)),H2(t)},"handler")};vy(bl(process.argv)).version(io()||"unknown").scriptName("openapi-codegen").command(U2).command(S1).help().demandCommand(1).strictCommands(!0).showHelpOnFail(!0).fail((e,t)=>{e&&ps(e),t&&ps(t),rr("Use '--help' for more info"),process.exit(1)}).parse();
151
+ *`))}o(PL,"registerAddAsteriskAfterNewLineHelper");var Jn=gt(Qn());function w2(e){EL(),$L(e.options),AL(e),wL(),xL(),IL(e),CL()}o(w2,"registerEndpointsHbsHelpers");function EL(){Jn.default.registerHelper("endpointName",aa)}o(EL,"registerEndpointNameHelper");function $L(e){Jn.default.registerHelper("importedEndpointName",t=>VP(t,e))}o($L,"registerImportedEndpointNameHelper");function wL(){Jn.default.registerHelper("endpointPath",HP)}o(wL,"registerEndpointPathHelper");function xL(){Jn.default.registerHelper("endpointBody",e=>e.parameters.find(t=>t.type==="Body"))}o(xL,"registerEndpointBodyHelper");function AL(e){Jn.default.registerHelper("endpointParams",t=>nm(e,t))}o(AL,"registerEndpointParamsHelper");function IL(e){Jn.default.registerHelper("endpointArgs",t=>nm(e,t).map(r=>r.name).join(", "))}o(IL,"registerEndpointArgsHelper");function CL(){Jn.default.registerHelper("endpointParamDescription",e=>{var s,a,c,u,l;let t=[`${e.paramType} parameter`],r=((s=e.parameterObject)==null?void 0:s.description)||((a=e.bodyObject)==null?void 0:a.description);r&&t.push(r);let n,i;if((c=e.parameterObject)!=null&&c.schema&&Gt(e.parameterObject.schema)&&(n=(u=e.parameterObject)==null?void 0:u.schema),(l=e.bodyObject)!=null&&l.content){let f=Object.keys(e.bodyObject.content??{}).find(Wr);f&&(i=e.bodyObject.content[f],i.schema&&Gt(i.schema)&&(n=i.schema))}return n&&["description","minimum","exclusiveMinimum","maximum","exclusiveMaximum","minItems","minLength","minProperties","maxItems","maxLength","maxProperties","example"].filter(f=>n[f]).forEach(f=>{t.push(`${Ve(xP(f))}: \`${n[f]}\``)}),i!=null&&i.example&&t.push(`Example: \`${i.example}\``),t.join(". ")})}o(CL,"registerEndpointParamDescriptionHelper");var ei=gt(Qn());var Xn={query:"useQuery",mutation:"useMutation"},x2={bindings:[Xn.query,Xn.mutation],from:"@tanstack/react-query"};function A2(){TL(),jL(),RL(),NL(),kL(),ML(),qL()}o(A2,"registerPartialsHbsHelpers");function TL(){ei.default.registerHelper("genImport",e=>ti("import")({import:e}))}o(TL,"registerImportHelper");function jL(){ei.default.registerHelper("genEndpointParams",e=>ti("endpoint-params")({endpoint:e}))}o(jL,"registerGenerateEndpointParamsHelper");function RL(){ei.default.registerHelper("genEndpointConfig",e=>{let t=UP(e);return Object.keys(t).length===0?"":ti("endpoint-config")({endpointConfig:t})})}o(RL,"registerGenerateEndpointConfigHelper");function NL(){ei.default.registerHelper("genQueryKeys",e=>e.length===0?"":ti("query-keys")({endpoints:e}))}o(NL,"registerGenerateQueryKeysHelper");function kL(){ei.default.registerHelper("genQuery",e=>{let t,r;return Gn(e)?(t="query-use-query",r=Xn.query):(t="query-use-mutation",r=Xn.mutation),ti(t)({endpoint:e,queryHook:r})})}o(kL,"registerGenerateQueryHelper");function ML(){ei.default.registerHelper("genCaslAbilityType",e=>ti("casl-ability-type")({endpoint:e,abilityTupleType:Ir.abilityTuple}))}o(ML,"registerGenerateCaslAbilityTypeHelper");function qL(){ei.default.registerHelper("genCaslAbilityFunction",e=>ti("casl-ability-function")({endpoint:e}))}o(qL,"registerGenerateCaslAbilityFunctionHelper");var xa=gt(Qn());var I2=o(e=>`use${Ve(ht(e.operationName))}`,"getQueryName"),lg=o(e=>{let t=e.map(({path:s})=>s),r=/^\/[^\/]*/g,n=It(t.map(s=>s.match(r)).flat()),i=o(s=>n.length===1?"all":`all${Ve(pu(s.replace(/\//g,"")??""))}`,"getQueryKeyName");return n.filter(s=>s!==null).map(s=>({path:s,name:i(s??"")}))},"getAllQueryKeys"),C2=o((e,t)=>{let n=lg(t).find(({path:s})=>e.path.startsWith(s));if(!n)return[e.path];let i=e.path.substring(n.path.length);return[`...keys.${n.name}`,...i?[`"${i}"`]:[]]},"getEndpointPathQueryKeys");function T2(){DL(),LL(),FL(),BL()}o(T2,"registerQueryHbsHelpers");function DL(){xa.default.registerHelper("queryName",I2)}o(DL,"registerQueryNameHelper");function LL(){xa.default.registerHelper("allQueryKeys",lg)}o(LL,"registerQueryKeysHelper");function FL(){xa.default.registerHelper("endpointPathQueryKeys",C2)}o(FL,"registerEndpointPathQueryKeysHelper");function BL(){xa.default.registerHelper("isQuery",Gn)}o(BL,"registerIsQueryHelper");var fg=gt(Qn());function j2(e){VL(e.options),HL(e)}o(j2,"registerZodHbsHelpers");function VL(e){fg.default.registerHelper("zodInferedType",t=>sa(t,e))}o(VL,"registerInferedTypeHelper");function HL(e){fg.default.registerHelper("importedZodSchemaName",t=>FP(e,t))}o(HL,"registerImportedZodSchemaNameHelper");function pn(e,t){let r=fm(t);return $2(),j2(e),w2(e),T2(),E2(),A2(),pg.default.compile(r)}o(pn,"getHbsTemplateDelegate");function ti(e){let t=fm(`partials/${e}`);return pg.default.compile(t)}o(ti,"getHbsPartialTemplateDelegate");function R2({resolver:e,data:t,tag:r=""}){var l;let n=(l=t.get(r))==null?void 0:l.endpoints.filter(({acl:p})=>p&&p.length>0);if(!n||n.length===0)return;let i=n.some(({acl:p})=>(p==null?void 0:p[0].conditions)&&Object.keys(p[0].conditions).length>0),s={...dm,bindings:[Ir.abilityTuple,...i?[Ir.forcedSubject,Ir.subject]:[]]},a=n.reduce((p,f)=>{var h,y;let d=(y=(h=f.acl)==null?void 0:h[0].conditionsTypes)==null?void 0:y.reduce((b,g)=>[...b,...g!=null&&g.zodSchemaName?[g.zodSchemaName]:[]],[]);return[...p,...d??[]]},[]),c=Wn({resolver:e,tag:r,zodSchemasAsTypes:It(a)});return pn(e,"acl")({caslAbilityTupleImport:s,modelsImports:c,includeNamespace:e.options.includeNamespaces,namespace:Je({type:"acl",tag:r,options:e.options}),endpoints:n})}o(R2,"generateAcl");function N2(e,t){if(!t||t.length===0)return;let r={...dm,bindings:[Ir.pureAbility]},n=j1({tags:t,entityName:pa,getAliasEntityName:Ou,options:e.options}),i=t.map(a=>Je({type:"acl",tag:a,options:e.options}));return pn(e,"app-acl")({caslAbilityTupleImport:r,imports:n,allAbilities:pa,includeNamespace:e.options.includeNamespaces,tags:t,namespaces:i})}o(N2,"generateAppAcl");function k2({resolver:e,data:t,tag:r=""}){var l;let n=(l=t.get(r))==null?void 0:l.endpoints;if(!n||n.length===0)return;let i=n.map(p=>p.response),s=i.some(p=>!Dt(p)),a=n.reduce((p,f)=>[...p,...f.parameters],[]),c=Wn({resolver:e,tag:r,zodSchemas:It(i.filter(Dt)),zodSchemasAsTypes:It(a.map(p=>p.zodSchema).filter(Dt))});return pn(e,"endpoints")({restClientImport:I1,hasZodImport:s,zodImport:cu,modelsImports:c,includeNamespace:e.options.includeNamespaces,namespace:Je({type:"endpoints",tag:r,options:e.options}),restClientName:ym,endpoints:n})}o(k2,"generateEndpoints");function M2(e,t){let r=e.getRefByZodSchemaName(t);if(r){let i=Array.from(e.dependencyGraph.refsDependencyGraph[r]??[]).map(a=>e.getZodSchemaNameByRef(a)),s=e.getEnumZodSchemaNamesReferencedBySchemaRef(r);return[...i,...s]}let n=e.getCompositeZodSchemaByZodSchemaName(t);return n?Array.from(q2(n)).map(i=>e.getZodSchemaNameByRef(i)):[]}o(M2,"getZodSchemaRefs");function q2(e){return e.children.reduce((r,n)=>{let i=n.ref??n.enumRef;return i&&r.add(i),n.children.length>0&&q2(n).forEach(s=>r.add(s)),r},new Set)}o(q2,"getSchemaRefs");function D2({resolver:e,data:t,tag:r=""}){var u;let n=(u=t.get(r))==null?void 0:u.zodSchemas;if(!n||Object.keys(n).length===0)return;let i=Object.keys(n).reduce((l,p)=>[...l,...M2(e,p)],[]).filter(l=>!n[l]),s=Wn({resolver:e,tag:r,zodSchemas:i}),a=Object.entries(n).reduce((l,[p,f])=>{let d=e.getRefByZodSchemaName(p);return{...l,[p]:{code:f,isCircular:!!d&&e.isSchemaCircular(d),isEnum:DP(f)}}},{});return pn(e,"models")({zodImport:cu,modelsImports:s,includeNamespace:e.options.includeNamespaces,namespace:Je({type:"models",tag:r,options:e.options}),zodSchemasData:a})}o(D2,"generateModels");function L2({resolver:e,data:t,tag:r=""}){var d;let n=(d=t.get(r))==null?void 0:d.endpoints;if(!n||n.length===0)return;let i=n.filter(Gn),s=n.filter(XP),a={...x2,bindings:[...i.length>0?[Xn.query]:[],...s.length>0?[Xn.mutation]:[]]},c={...C1,bindings:[...i.length>0?[da.query]:[],...s.length>0?[da.mutation]:[]]},u=[...i,...s].reduce((h,y)=>[...h,...y.parameters],[]),l=Wn({resolver:e,tag:r,zodSchemasAsTypes:It(u.map(h=>h.zodSchema).filter(Dt))}),p=T1({tag:r,endpoints:n,options:e.options});return pn(e,"queries")({queryImport:a,queryTypesImport:c,modelsImports:l,endpointsImports:p,includeNamespace:e.options.includeNamespaces,namespace:Je({type:"queries",tag:r,options:e.options}),endpoints:n,queryEndpoints:i})}o(L2,"generateQueries");function F2(e,t){let r={...uu,...t},{resolver:n,data:i}=Su(e,r),s=[],a=[],c=["models","endpoints","queries","acl"],u={models:D2,endpoints:k2,queries:L2,acl:R2};i.forEach((p,f)=>{r.excludeTags.find(h=>h.toLowerCase()===f.toLowerCase())||c.forEach(h=>{let y=u[h]({resolver:n,data:i,tag:f});if(y){let b=fa({output:r.output,fileName:zn({tag:f,type:h,options:r})});s.push({fileName:b,content:y}),h==="acl"&&a.push(f)}})});let l=N2(n,a);if(l){let p=fa({output:r.output,fileName:O1});s.push({fileName:p,content:l})}return s}o(F2,"generateCodeFromOpenAPIDoc");async function H2({input:e,excludeTags:t,prettier:r,verbose:n,...i}){let s=Date.now();n&&rr("Parsing OpenAPI spec...");let a=await B2.default.bundle(e);n&&vn("Parsing finished."),n&&rr("Generating code...");let c=F2(a,{input:e,excludeTags:t.split(","),...i});n&&vn("Generation finished."),n&&rr("Writing files..."),y1(c),n&&vn("Writing finished."),r&&UL({output:i.output,verbose:n}),n&&rr(`TIME: ${Date.now()-s}ms`)}o(H2,"generate");function UL({output:e,verbose:t}){t&&rr("Running Prettier..."),(0,V2.exec)(`prettier --write ${e}`,r=>{t&&(r?ps(r,"Prettier error"):vn("Prettier finished."))})}o(UL,"execPrettier");var Lt=class Lt{input;output;includeNamespaces;splitByTags;defaultTag;excludeTags;importPath;extractEnums;removeOperationPrefixEndingWith;prettier;verbose};o(Lt,"GenerateOptions"),at([ut({envAlias:"input",demandOption:!0})],Lt.prototype,"input",2),at([ut({envAlias:"output",default:"output"})],Lt.prototype,"output",2),at([ut({envAlias:"includeNamespaces",default:!0,type:"boolean"})],Lt.prototype,"includeNamespaces",2),at([ut({envAlias:"splitByTags",default:!0,type:"boolean"})],Lt.prototype,"splitByTags",2),at([ut({envAlias:"defaultTag",default:"Common"})],Lt.prototype,"defaultTag",2),at([ut({envAlias:"excludeTags",default:""})],Lt.prototype,"excludeTags",2),at([ut({envAlias:"importPath",default:"ts",type:"string"})],Lt.prototype,"importPath",2),at([ut({envAlias:"extractEnums",default:!0,type:"boolean"})],Lt.prototype,"extractEnums",2),at([ut({envAlias:"removeOperationPrefixEndingWith",default:"Controller_"})],Lt.prototype,"removeOperationPrefixEndingWith",2),at([ut({envAlias:"prettier",default:!0,type:"boolean"})],Lt.prototype,"prettier",2),at([ut({envAlias:"verbose",default:!1,type:"boolean"})],Lt.prototype,"verbose",2);var dg=Lt,U2={command:"generate",describe:"Generate code from OpenAPI spec",builder:tc(dg),handler:o(async e=>{let t=await e;return t.verbose&&(ec(`OpenAPI CodeGen ${io()}`),fs("input",t.input),fs("output",t.output)),H2(t)},"handler")};vy(bl(process.argv)).version(io()||"unknown").scriptName("openapi-codegen").command(U2).command(S1).help().demandCommand(1).strictCommands(!0).showHelpOnFail(!0).fail((e,t)=>{e&&ps(e),t&&ps(t),rr("Use '--help' for more info"),process.exit(1)}).parse();
152
152
  /*! Bundled license information:
153
153
 
154
154
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/openapi-codegen-cli",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "main": "./dist/index.js",
5
5
  "bin": {
6
6
  "openapi-codegen": "./dist/sh.js"