openapi-sync 5.0.6 → 6.0.0

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.
@@ -0,0 +1,856 @@
1
+ import {o,c as c$1,n,d as d$1,f as f$1,h,g,j,i}from'./chunk-L52BXDAC.mjs';import {d,c,b,a,f}from'./chunk-VLACEFT4.mjs';import Z from'path';import ue from'fs';import Gt from'lodash.isequal';import Le from'lodash.get';import Bt from'axios';import zt from'axios-retry';import Dt from'@apidevtools/swagger-parser';import {CurlGenerator}from'curl-generator';var ke,_e,Oe,gt,ht,$t,Ne,We=d(()=>{ke=Z.join(__dirname,"../","../db.json");ue.existsSync(ke)||ue.writeFileSync(ke,"{}");_e={};try{_e=c(ke);}catch(l){_e={};}Oe=_e||{},gt=l=>{ue.writeFileSync(ke,JSON.stringify(l));},ht=(l,c)=>{Oe[l]=c,gt(Oe);},$t=l=>Oe[l],Ne=()=>{Oe={},gt(Oe);};});var Ct,It,Ue,Ke=d(()=>{Ct={},It=(l,c)=>{Ct[l]=c;},Ue=l=>Ct[l]||[];});var Ce,He,bt,xe,xt,_t,Fe,Et=d(()=>{o();We();Ke();Ce=process.cwd(),He={},bt=Bt.create({timeout:6e4});zt(bt,{retries:20,retryCondition:l=>l.code==="ECONNABORTED"||l.message.includes("Network Error"),retryDelay:l=>l*1e3});xe=(l,c,m)=>f(null,null,function*(){var r,C,i,y;if(!(((r=m==null?void 0:m.customCode)==null?void 0:r.enabled)!==false)){yield ue.promises.writeFile(l,c);return}let s=null;try{s=yield ue.promises.readFile(l,"utf-8");}catch(A){}let n$1=l.endsWith(".py")?"#":"//",d=n(c,s,{position:((C=m==null?void 0:m.customCode)==null?void 0:C.position)||"bottom",markerText:(i=m==null?void 0:m.customCode)==null?void 0:i.markerText,includeInstructions:(y=m==null?void 0:m.customCode)==null?void 0:y.includeInstructions,commentPrefix:n$1});yield ue.promises.writeFile(l,d);}),xt=(l,c,m,e)=>f(null,null,function*(){let s=yield _t(l,c,m,e);return e&&!isNaN(e)&&e>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(He[c]&&clearTimeout(He[c]),He[c]=setTimeout(()=>{console.info(`\u{1F504} Auto syncing ${c}`),xt(l,c,m,e);},e))),s}),_t=(...l)=>f(null,null,function*(){var on,an,ln,pn,un,mn,cn,dn,fn,yn;let[c,m,e]=l,s=t=>t.startsWith("http://")||t.startsWith("https://"),n;try{if(s(c))n=(yield bt.get(c)).data;else {let t=Z.isAbsolute(c)?c:Z.join(Ce,c);`${t}`,n=yield ue.promises.readFile(t,"utf-8");}}catch(t){throw process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||console.error(`Failed to load OpenAPI spec for ${m}:`,t),t}if(!n)return;let d=d$1(n)?n:f$1(n),r;try{r=yield Dt.parse(d);}catch(t){let o=t instanceof Error?t.message:String(t);throw new Error(`Failed to parse OpenAPI spec for ${m}: ${o}`)}let C=Z.join((e==null?void 0:e.folder)||"",m),i$1=(e==null?void 0:e.language)==="python",y=i$1?"py":"ts",A={},F=t=>{var o,I;if((o=e==null?void 0:e.folderSplit)!=null&&o.customFolder){let $=e.folderSplit.customFolder(t);if($)return $}return (I=e==null?void 0:e.folderSplit)!=null&&I.byTags&&t.tags&&t.tags.length>0?t.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},R=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((an=(on=r==null?void 0:r.servers)==null?void 0:on[(e==null?void 0:e.server)||0])==null?void 0:an.url)||"",S=typeof((pn=(ln=e==null?void 0:e.types)==null?void 0:ln.name)==null?void 0:pn.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",U=typeof((mn=(un=e==null?void 0:e.endpoints)==null?void 0:un.name)==null?void 0:mn.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",G=(t,o)=>{var $,p;let I=g(t);if((p=($=e==null?void 0:e.types)==null?void 0:$.name)!=null&&p.format){let f=e==null?void 0:e.types.name.format("shared",{name:t},I);if(f)return `${S}${f}`}return `${S}${I}`},j$1=(t,o,I,$,p,f=0)=>{let u="",h="",g="";if(o)if(o.$ref)if(o.$ref[0]==="#"){let x=(o.$ref||"").split("/");x.shift();x[0]==="definitions";[...x].pop();let k=Le(t,x,null);if(k){k!=null&&k.name&&(u=k.name),h=x[x.length-1];let K=G(h);K.includes(".")&&(K=K.split(".").map((Ie,ye)=>ye===0?Ie:`["${Ie}"]`).join("")),g+=`${p!=null&&p.noSharedImport?"":"Shared."}${K}`;}}else g+="";else if(o.anyOf)g+=`(${o.anyOf.map(x=>j$1(t,x,"",$,b(a({},p),{useComponentName:false}))).filter(x=>!!x).join("|")})`;else if(o.oneOf)g+=`(${o.oneOf.map(x=>j$1(t,x,"",$,b(a({},p),{useComponentName:false}))).filter(x=>!!x).join("|")})`;else if(o.allOf)g+=`(${o.allOf.map(x=>j$1(t,x,"",$,b(a({},p),{useComponentName:false}))).filter(x=>!!x).join("&")})`;else if(o.items)g+=`${j$1(t,o.items,"",false,b(a({},p),{useComponentName:false}))}[]`;else if(o.properties){let x=Object.keys(o.properties),T=o.required||[],P="";x.forEach(N=>{var K,Ae,Ie,ye,ge,he;let k="";!((Ae=(K=e==null?void 0:e.types)==null?void 0:K.doc)!=null&&Ae.disable)&&((ye=(Ie=o.properties)==null?void 0:Ie[N])!=null&&ye.description)&&(k=" * "+((ge=o.properties)==null?void 0:ge[N].description.split(`
2
+ `).filter(Be=>Be.trim()!=="").join(`
3
+ *${" ".repeat(1)}`))),P+=(k?`/**
4
+ ${k}
5
+ */
6
+ `:"")+`${j$1(t,(he=o.properties)==null?void 0:he[N],N,T.includes(N),p,f+1)}`;}),P.length>0?g+=`{
7
+ ${" ".repeat(f)}${P}${" ".repeat(f)}}`:g+="{[k: string]: any}";}else if(o.enum&&o.enum.length>0){let x=o.enum.includes(null),T=o.enum.filter(N=>N!==null).map(N=>JSON.stringify(N)).filter(N=>N!==void 0),P=T.length>1||T.length>0&&x;P&&(g+="("),T.forEach((N,k)=>{g+=`${k===0?"":"|"}${N}`;}),x&&(g+=`${T.length>0?"|":""}null`),P&&(g+=")");}else if(o.type){let x=T=>{let P="";if(typeof T=="string")["string","integer","number","array","boolean","null"].includes(T)?["integer","number"].includes(T)?P+="number":T==="array"?P+="any[]":P+=T:T==="object"&&(o.additionalProperties?P+=`{[k: string]: ${j$1(t,o.additionalProperties,"",true,b(a({},p),{useComponentName:false}))||"any"}}`:P+="{[k: string]: any}");else if(Array.isArray(T)){let N=T.map(k=>x(k));N.filter(k=>k!==""),N.length>1&&(P+="("+N.join("|")+")");}else P+="any";return P};g=x(o.type);}else g+="any";else g="string";let v=u||I;p!=null&&p.useComponentName&&!v&&(v=h);let B=v?` "${v}"${$?"":"?"}: `:"",a$1=(o==null?void 0:o.enum)&&o.enum.includes(null),z=o!=null&&o.nullable&&!a$1?" | null":"";return g.length>0?`${B}${g}${z}${v?`;
8
+ `:""}`:""},_=(t,o,I,$,p,f=0)=>{let u="",h="",g="";if(o)if(o.$ref)if(o.$ref[0]==="#"){let x=(o.$ref||"").split("/");x.shift();x[0]==="definitions";[...x].pop();let k=Le(t,x,null);if(k){k!=null&&k.name&&(u=k.name),h=x[x.length-1];let K=G(h);K.includes(".")&&(K=K.split(".").join("_")),g+=`${p!=null&&p.noSharedImport?"":"Shared."}${K}`;}}else g+="Any";else if(o.anyOf)g+=`Union[${o.anyOf.map(x=>_(t,x,"",$,b(a({},p),{useComponentName:false}))).filter(x=>!!x).join(", ")}]`;else if(o.oneOf)g+=`Union[${o.oneOf.map(x=>_(t,x,"",$,b(a({},p),{useComponentName:false}))).filter(x=>!!x).join(", ")}]`;else if(o.allOf)g+="Dict[str, Any]";else if(o.items)g+=`List[${_(t,o.items,"",false,b(a({},p),{useComponentName:false}))}]`;else if(o.properties){let x=Object.keys(o.properties),T=o.required||[],P="";x.forEach(N=>{var k;P+=_(t,(k=o.properties)==null?void 0:k[N],N,T.includes(N),p,f+1);}),P.length>0?I?g+="Dict[str, Any]":g+=`
9
+ ${P}`:g+="Dict[str, Any]";}else if(o.enum&&o.enum.length>0){let x=o.enum.filter(T=>T!==null).map(T=>JSON.stringify(T));x.length>0?g+=`Literal[${x.join(", ")}]`:g+="Any";}else if(o.type){let x=T=>{let P="";if(typeof T=="string")["integer","number"].includes(T)?P+=T==="number"?"float":"int":T==="string"?P+="str":T==="boolean"?P+="bool":T==="array"?P+="List[Any]":T==="object"?P+="Dict[str, Any]":T==="null"?P+="None":P+="Any";else if(Array.isArray(T)){let N=T.map(k=>x(k)).filter(k=>k!=="");N.length>1?P+=`Union[${N.join(", ")}]`:P+=N[0]||"Any";}else P+="Any";return P};g=x(o.type);}else g+="Any";else g="str";let v=u||I;p!=null&&p.useComponentName&&!v&&(v=h);let B="";v&&(B=` ${v.replace(/[^a-zA-Z0-9_]/g,"_")}: `);let a$1=g,z=!v&&g.includes(`
10
+ `);return o!=null&&o.nullable&&!z&&(g.startsWith("Union[")?a$1=g.replace("Union[","Union[None, "):a$1=`Optional[${g}]`),g.length>0?`${B}${a$1}${v?`
11
+ `:""}`:""},q=t=>{let o=(t||"").replace(/^\n+/,"").trimEnd();if(!o)return ` pass
12
+ `;let I=o.split(`
13
+ `),$=/^[A-Za-z_][A-Za-z0-9_]*\s*:\s*.+$/,p=I.map(h=>h.trim()).filter(h=>!!h).filter(h=>!h.startsWith('"""')&&!h.endsWith('"""'));return !p.some(h=>$.test(h))&&p.length===1?` value: ${p[0]}
14
+ `:`${o.split(`
15
+ `).map(h=>h.trim()?/^\s/.test(h)?h:` ${h}`:h).join(`
16
+ `)}
17
+ `},w=t=>{let o=(t||"").replace(/^\n+/,"").trimEnd();if(!o)return null;let I=o.split(`
18
+ `),$=/^[A-Za-z_][A-Za-z0-9_]*\s*:\s*.+$/,p=I.map(u=>u.trim()).filter(u=>!!u).filter(u=>!u.startsWith('"""')&&!u.endsWith('"""'));return !p.some(u=>$.test(u))&&p.length===1?p[0]:null},ne=(t,o,I)=>{let $=w(o);return (I==null?void 0:I.inheritSingleTypeExpression)===true&&!!$?`@dataclass
19
+ class ${t}(${$}):
20
+ pass
21
+ `:`@dataclass
22
+ class ${t}:
23
+ ${q(o)}`},Q=t=>{let I=["Any","List","Dict","Union","Optional","Literal"].filter($=>new RegExp(`\\b${$}\\b`).test(t));return I.length>0?`from typing import ${I.join(", ")}
24
+ `:""},W=(t,o=72)=>{let I=(t||"").replace(/\s+/g," ").trim().split(" ");if(!I[0])return [];let $=[],p="";return I.forEach(f=>{let u=p?`${p} ${f}`:f;u.length>o&&p?($.push(p),p=f):p=u;}),p&&$.push(p),$},de=t=>{var p,f;if(!t||(f=(p=e==null?void 0:e.types)==null?void 0:p.doc)!=null&&f.disable)return "";let o=(t.description||"").trim(),I=Object.entries(t.properties||{}).map(([u,h])=>({name:u,desc:((h==null?void 0:h.description)||"").trim()})).filter(u=>u.desc.length>0);if(!o&&I.length===0)return "";let $=[' """'];return o&&W(o).forEach(u=>$.push(` ${u}`)),I.length>0&&(o&&$.push(""),$.push(" Attributes:"),I.forEach(u=>{let h=W(u.desc);h.length&&($.push(` ${u.name}: ${h[0]}`),h.slice(1).forEach(g=>$.push(` ${g}`)));})),$.push(' """'),`${$.join(`
25
+ `)}
26
+ `},ae=(t,o)=>{let p="";if(o)if(o.$ref)if(o.$ref[0]==="#"){let f=(o.$ref||"").split("/");f.shift();let h=Le(t,f,null);h&&(h!=null&&h.name&&(h.name),f[f.length-1],p+=ae(t,h));}else p+="";else if(o.anyOf)p+=ae(t,o.anyOf[0]);else if(o.oneOf)p+=ae(t,o.oneOf[0]);else if(o.allOf)p+=`{${o.allOf.map(f=>`...(${ae(t,f)})`).join(",")}}`;else if(o.items)p+=`[${ae(t,o.items)}]`;else if(o.properties){let h=Object.keys(o.properties).map(g=>{var v;return ` "${g}": ${ae(t,(v=o.properties)==null?void 0:v[g])}`}).join(`,
27
+ `);h.length>0?p+=`{
28
+ ${h}
29
+ }`:p+="{}";}else if(o.enum&&o.enum.length>0)o.enum.length>1&&(p+=o.enum[0]);else if(o.type)if(o.example)p+=JSON.stringify(o.example);else {let f=u=>{let h="";if(typeof u=="string")["string","integer","number","array","boolean","null"].includes(u)?["integer","number"].includes(u)?h+="123":u==="array"?h+="[]":u==="boolean"?h+="true":u==="null"?h+="null":h+=`"${u}"`:u==="object"&&(h+="{}");else if(Array.isArray(u)){let g=u.map(v=>f(v));g.filter(v=>v!==""),g.length>1&&(h+=g.join("|"));}else h+="any";return h};p=f(o.type);}else p+="any";else p="string";return p},ie=$t(m);if(Gt(ie,r))return;ht(m,r);let pe="",fe="",le={},ve=[],rn=(t,o)=>{let I={},$={};Object.keys(t).forEach(f=>{var g;let u=(g=t[f])!=null&&g.schema?t[f].schema:t[f],h=i$1?`${_(r,u,"",true,{noSharedImport:true,useComponentName:false})}`:`${j$1(r,u,"",true,{noSharedImport:true,useComponentName:false})}`;if(h){let v=f.split("."),B=I,a=$;for(let z=0;z<v.length;z++){let x=v[z];z<v.length-1?(x in B||(B[x]={},a[x]={}),B=B[x],a=a[x]):(B[x]=h,a[x]=u);}}}),Object.keys(I).forEach(f=>{var z,x,T,P,N;let u=G(f),h=I[f],g=t[f],v=g!=null&&g.schema?g.schema:g,B="",a="";!((x=(z=e==null?void 0:e.types)==null?void 0:z.doc)!=null&&x.disable)&&f in t&&((T=t[f])!=null&&T.description)&&(B=" * "+t[f].description.split(`
30
+ `).filter(K=>K.trim()!=="").join(`
31
+ *${" ".repeat(1)}`)),a=de(v),i$1?le[f]=((P=le[f])!=null?P:"")+`@dataclass
32
+ class ${u}:
33
+ `+(a||"")+q(typeof h=="string"?h:"")+`
34
+ `:le[f]=((N=le[f])!=null?N:"")+(B?`/**
35
+ ${B}
36
+ */
37
+ `:"")+"export type "+u+" = "+(typeof h=="string"?h:i(h))+`;
38
+ `;});};r.definitions&&rn(r.definitions),r.components&&Object.keys(r.components).forEach(t=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(t)){let o=r.components[t];rn(o);}});let sn=t=>{let o="";if(t.content){let I=Object.keys(t.content);I[0]&&t.content[I[0]].schema&&(o+=i$1?`${_(r,t.content[I[0]].schema,"")}`:`${j$1(r,t.content[I[0]].schema,"")}`);}return o},me=(t,o,I=0)=>{if(!t)return o==="joi"?"Joi.any()":o==="yup"?"yup.mixed()":"z.any()";if(t.$ref){if(t.$ref[0]==="#"){let $=t.$ref.split("/");$.shift();let p=$.join("."),f=Le(r,p);if(f)return me(f,o,I)}return o==="joi"?"Joi.any()":o==="yup"?"yup.mixed()":"z.any()"}if(t.anyOf||t.oneOf){let $=t.anyOf||t.oneOf;if($.every(f=>f.enum!==void 0&&Array.isArray(f.enum))){let f=[],u=false;if($.forEach(h=>{h.enum&&h.enum.forEach(g=>{g===null?u=true:f.includes(g)||f.push(g);});}),f.length>0){let h=f.map(g=>JSON.stringify(g)).join(", ");if(o==="zod"){let g=`z.enum([${h}])`;return u&&(g+=".nullable()"),g}else if(o==="yup"){let g=`yup.mixed().oneOf([${h}])`;return u&&(g+=".nullable()"),g}else return u?`Joi.valid(${h}, null)`:`Joi.valid(${h})`}else if(u)return o==="zod"?"z.null()":o==="yup"?"yup.mixed().nullable()":"Joi.valid(null)"}return o==="zod"?`z.union([${$.map(h=>me(h,o,I+1)).join(", ")}])`:o==="yup"?`yup.mixed().oneOf([${$.map(h=>me(h,o,I+1)).join(", ")}])`:`Joi.alternatives().try(${$.map(u=>me(u,o,I+1)).join(", ")})`}if(t.allOf)if(o==="zod"){let $=t.allOf.map(f=>me(f,o,I+1)),p=$[0];for(let f=1;f<$.length;f++)p=`${p}.merge(${$[f]})`;return p}else return me(t.allOf[0],o,I+1);if(t.items){let $=me(t.items,o,I+1);if(o==="zod"){let p=`z.array(${$})`;return t.minItems!==void 0&&(p+=`.min(${t.minItems})`),t.maxItems!==void 0&&(p+=`.max(${t.maxItems})`),p}else if(o==="yup"){let p=`yup.array().of(${$})`;return t.minItems!==void 0&&(p+=`.min(${t.minItems})`),t.maxItems!==void 0&&(p+=`.max(${t.maxItems})`),p}else {let p=`Joi.array().items(${$})`;return t.minItems!==void 0&&(p+=`.min(${t.minItems})`),t.maxItems!==void 0&&(p+=`.max(${t.maxItems})`),p}}if(t.properties){let $=t.required||[],p=" ".repeat(I+1),f=Object.entries(t.properties).map(([u,h])=>{let g=$.includes(u),v=me(h,o,I+1);return g||(v+=".optional()"),`${p}${u}: ${v}`}).join(`,
39
+ `);return o==="zod"?`z.object({
40
+ ${f}
41
+ ${" ".repeat(I)}})`:o==="yup"?`yup.object({
42
+ ${f}
43
+ ${" ".repeat(I)}})`:`Joi.object({
44
+ ${f}
45
+ ${" ".repeat(I)}})`}if(t.enum&&t.enum.length>0){let $=[],p=false;t.enum.forEach(u=>{u===null?p=true:$.includes(u)||$.push(u);});let f=$.map(u=>JSON.stringify(u)).join(", ");if(o==="zod"){let u=`z.enum([${f}])`;return p&&(u+=".nullable()"),u}else if(o==="yup"){let u=`yup.mixed().oneOf([${f}])`;return p&&(u+=".nullable()"),u}else {let u=`Joi.valid(${f})`;return p&&(u+=".allow(null)"),u}}if(t.type){let p=(f=>{switch(f){case "string":if(o==="zod"){let u="z.string()";return t.format==="email"?u+=".email()":t.format==="uuid"?u+=".uuid()":t.format==="url"||t.format==="uri"?u+=".url()":t.format==="date-time"?u+=".datetime()":t.format==="date"&&(u+=".date()"),t.minLength&&(u+=`.min(${t.minLength})`),t.maxLength&&(u+=`.max(${t.maxLength})`),t.pattern&&(u+=`.regex(/${t.pattern}/)`),u}else if(o==="yup"){let u="yup.string()";return t.format==="email"?u+=".email()":(t.format==="url"||t.format==="uri")&&(u+=".url()"),t.minLength&&(u+=`.min(${t.minLength})`),t.maxLength&&(u+=`.max(${t.maxLength})`),t.pattern&&(u+=`.matches(/${t.pattern}/)`),u}else {let u="Joi.string()";return t.format==="email"?u+=".email()":t.format==="url"||t.format==="uri"?u+=".uri()":t.format==="uuid"?u+=".guid({ version: 'uuidv4' })":t.format==="date-time"&&(u+=".isoDate()"),t.minLength&&(u+=`.min(${t.minLength})`),t.maxLength&&(u+=`.max(${t.maxLength})`),t.pattern&&(u+=`.pattern(/${t.pattern}/)`),u}case "integer":case "number":if(o==="zod"){let u="z.number()";return f==="integer"&&(u+=".int()"),t.minimum!==void 0&&(t.exclusiveMinimum?u+=`.gt(${t.minimum})`:u+=`.min(${t.minimum})`),t.maximum!==void 0&&(t.exclusiveMaximum?u+=`.lt(${t.maximum})`:u+=`.max(${t.maximum})`),u}else if(o==="yup"){let u="yup.number()";return f==="integer"&&(u+=".integer()"),t.minimum!==void 0&&(u+=`.min(${t.minimum})`),t.maximum!==void 0&&(u+=`.max(${t.maximum})`),u}else {let u="Joi.number()";return f==="integer"&&(u+=".integer()"),t.minimum!==void 0&&(t.exclusiveMinimum?u+=`.greater(${t.minimum})`:u+=`.min(${t.minimum})`),t.maximum!==void 0&&(t.exclusiveMaximum?u+=`.less(${t.maximum})`:u+=`.max(${t.maximum})`),u}case "boolean":return o==="joi"?"Joi.boolean()":o==="yup"?"yup.boolean()":"z.boolean()";case "null":return o==="joi"?"Joi.any().allow(null)":o==="yup"?"yup.mixed().nullable()":"z.null()";default:return o==="joi"?"Joi.any()":o==="yup"?"yup.mixed()":"z.any()"}})(typeof t.type=="string"?t.type:t.type[0]);return t.nullable&&o!=="joi"?p+=".nullable()":t.nullable&&o==="joi"&&(p+=".allow(null)"),p}return o==="joi"?"Joi.any()":o==="yup"?"yup.mixed()":"z.any()"},kt=t=>{var o,I,$,p,f;if((I=(o=e==null?void 0:e.endpoints)==null?void 0:o.value)!=null&&I.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let u=t;return (f=(p=($=e==null?void 0:e.endpoints)==null?void 0:$.value)==null?void 0:p.replaceWords)==null||f.forEach((h,g)=>{let v=new RegExp(h.replace,"g");u=u.replace(v,h.with||"");}),u}else return t},Nt=(t,o,I=[])=>{var f,u;let $=(f=e==null?void 0:e.endpoints)==null?void 0:f.exclude,p=(u=e==null?void 0:e.endpoints)==null?void 0:u.include;if(p){let h=p.tags&&p.tags.length>0?I.some(v=>p.tags.includes(v)):true,g=p.endpoints&&p.endpoints.length>0?p.endpoints.some(v=>{let B=!v.method||v.method.toLowerCase()===o.toLowerCase();return v.path?t===v.path&&B:v.regex?new RegExp(v.regex).test(t)&&B:false}):true;if(!h||!g)return true}return !!($&&($.tags&&$.tags.length>0&&I.some(g=>$.tags.includes(g))||$.endpoints&&$.endpoints.length>0&&$.endpoints.some(g=>{let v=!g.method||g.method.toLowerCase()===o.toLowerCase();return g.path?t===g.path&&v:g.regex?new RegExp(g.regex).test(t)&&v:false})))};if(Object.keys(r.paths||{}).forEach(t=>{let o=r.paths[t];Object.keys(o).forEach($=>{var hn,$n,Cn,In,bn,xn,En,An,wn,On,Tn,Pn,Sn,vn,qn,Rn,jn,kn,Nn,Un,Ln,Fn,Mn,Qn,Gn,Bn,zn,Dn,Jn,_n,Wn,Kn,Hn,Vn,Yn,Zn,Xn,et,nt,tt,rt,st,ot,at,it,lt,pt,ut,mt,ct;let p=$,f=h(t,p),u=((hn=o[p])==null?void 0:hn.tags)||[];if(Nt(t,p,u))return;let h$1=o[p],g$1=F({method:p,path:t,summary:h$1==null?void 0:h$1.summary,operationId:h$1==null?void 0:h$1.operationId,tags:u,parameters:h$1==null?void 0:h$1.parameters,requestBody:h$1==null?void 0:h$1.requestBody,responses:h$1==null?void 0:h$1.responses});A[g$1]||(A[g$1]={endpoints:"",types:"",validation:""});let v=((Cn=($n=e==null?void 0:e.endpoints)==null?void 0:$n.value)!=null&&Cn.includeServer?R:"")+f.pathParts.map(E=>(E[0]==="{"&&E[E.length-1]==="}"?E=`\${${E.replace(/{/,"").replace(/}/,"")}}`:E[0]==="<"&&E[E.length-1]===">"?E=`\${${E.replace(/</,"").replace(/>/,"")}}`:E[0]===":"&&(E=`\${${E.replace(/:/,"")}}`),E)).join("/"),B=`"${v}"`;f.variables.length>0&&(B=`(${f.variables.map(b=>`${b}:string`).join(",")})=> \`${v}\``),B=kt(B);let a=o[p],z="",x;if(a!=null&&a.parameters&&((a==null?void 0:a.parameters).forEach((b,O)=>{(b.$ref||b.in==="query"&&b.name)&&(z+=i$1?`${_(r,b.$ref?b:b.schema,b.name||"",b.required)}`:`${j$1(r,b.$ref?b:b.schema,b.name||"",b.required)}`);}),z)){z=i$1?z:`{
46
+ ${z}}`;let O=`${f.name}Query`;if((bn=(In=e==null?void 0:e.types)==null?void 0:In.name)!=null&&bn.useOperationId&&(a!=null&&a.operationId)&&(O=`${a.operationId}Query`),O=g(`${S}${O}`),(En=(xn=e==null?void 0:e.types)==null?void 0:xn.name)!=null&&En.format){let H=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"query",method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},O);H&&(O=`${S}${H}`);}x=O;let M=i$1?`${ne(O,z)}
47
+ `:`export type ${O} = ${z};
48
+ `;e!=null&&e.folderSplit?A[g$1].types+=M:fe+=M;}if(((An=e==null?void 0:e.validations)==null?void 0:An.disable)!==true&&((On=(wn=e==null?void 0:e.validations)==null?void 0:wn.generate)==null?void 0:On.query)!==false&&(a!=null&&a.parameters)){let E=((Tn=e.validations)==null?void 0:Tn.library)||"zod",O=a.parameters.filter(M=>!M.$ref&&M.in==="query"&&M.name);if(O.length>0){let M=((Pn=e==null?void 0:e.validations)==null?void 0:Pn.name)||((Sn=e==null?void 0:e.types)==null?void 0:Sn.name),H=typeof(M==null?void 0:M.prefix)=="string"?M.prefix:"I",X=typeof((qn=(vn=e==null?void 0:e.validations)==null?void 0:vn.name)==null?void 0:qn.suffix)=="string"?e.validations.name.suffix:"Schema",ee=`${f.name}Query`;if(M!=null&&M.useOperationId&&(a!=null&&a.operationId)&&(ee=`${a.operationId}Query`),ee=g(`${H}${ee}${X}`),(jn=(Rn=e==null?void 0:e.validations)==null?void 0:Rn.name)!=null&&jn.format){let Y=e.validations.name.format({code:"",type:"query",method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},ee);Y&&(ee=`${H}${Y}${X}`);}else if((Nn=(kn=e==null?void 0:e.types)==null?void 0:kn.name)!=null&&Nn.format){let Y=e.types.name.format("endpoint",{code:"",type:"query",method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},ee);Y&&(ee=`${H}${Y}${X}`);}let D=O.map(Y=>{let qe=Y!=null&&Y.schema?me(Y.schema,E):E==="joi"?"Joi.string()":E==="yup"?"yup.string()":"z.string()",Ft=Y.required?"":".optional()";return ` ${Y.name}: ${qe}${Ft}`}).join(`,
49
+ `),V=`export const ${ee} = ${E==="joi"?"Joi.object":E==="yup"?"yup.object":"z.object"}({
50
+ ${D}
51
+ });
52
+
53
+ `;e!=null&&e.folderSplit||A[g$1]||(A[g$1]={endpoints:"",types:"",validation:""}),A[g$1].validation+=V;}}let T=a==null?void 0:a.requestBody,P="",N;if(T&&(P=sn(T),P)){let E=`${f.name}DTO`;if((Ln=(Un=e==null?void 0:e.types)==null?void 0:Un.name)!=null&&Ln.useOperationId&&(a!=null&&a.operationId)&&(E=`${a.operationId}DTO`),E=g(`${S}${E}`),(Mn=(Fn=e==null?void 0:e.types)==null?void 0:Fn.name)!=null&&Mn.format){let O=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"dto",method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},E);O&&(E=`${S}${O}`);}N=E;let b=i$1?`${ne(E,P,{inheritSingleTypeExpression:true})}
54
+ `:`export type ${E} = ${P};
55
+ `;e!=null&&e.folderSplit?A[g$1].types+=b:fe+=b;}if(((Qn=e==null?void 0:e.validations)==null?void 0:Qn.disable)!==true&&((Bn=(Gn=e==null?void 0:e.validations)==null?void 0:Gn.generate)==null?void 0:Bn.dto)!==false&&T){let E=((zn=e.validations)==null?void 0:zn.library)||"zod";if(T.content){let b=Object.keys(T.content);if(b[0]&&T.content[b[0]].schema){let O=((Dn=e==null?void 0:e.validations)==null?void 0:Dn.name)||((Jn=e==null?void 0:e.types)==null?void 0:Jn.name),M=typeof(O==null?void 0:O.prefix)=="string"?O.prefix:"I",H=typeof((Wn=(_n=e==null?void 0:e.validations)==null?void 0:_n.name)==null?void 0:Wn.suffix)=="string"?e.validations.name.suffix:"Schema",X=`${f.name}DTO`;if(O!=null&&O.useOperationId&&(a!=null&&a.operationId)&&(X=`${a.operationId}DTO`),X=g(`${M}${X}${H}`),(Hn=(Kn=e==null?void 0:e.validations)==null?void 0:Kn.name)!=null&&Hn.format){let se=e.validations.name.format({code:"",type:"dto",method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},X);se&&(X=`${M}${se}${H}`);}else if((Yn=(Vn=e==null?void 0:e.types)==null?void 0:Vn.name)!=null&&Yn.format){let se=e.types.name.format("endpoint",{code:"",type:"dto",method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},X);se&&(X=`${M}${se}${H}`);}let ee=me(T.content[b[0]].schema,E),D=`export const ${X} = ${ee};
56
+
57
+ `;e!=null&&e.folderSplit||A[g$1]||(A[g$1]={endpoints:"",types:"",validation:""}),A[g$1].validation+=D;}}}let k={},K="",Ae="";if(a!=null&&a.responses){let E=a==null?void 0:a.responses;Object.keys(E).forEach(O=>{var M,H,X,ee;if(K=sn(E[O]),k[O]=K,K){let D=`${f.name}${O}Response`;if((H=(M=e==null?void 0:e.types)==null?void 0:M.name)!=null&&H.useOperationId&&(a!=null&&a.operationId)&&(D=`${a.operationId}${O}Response`),D=g(`${S}${D}`),(ee=(X=e==null?void 0:e.types)==null?void 0:X.name)!=null&&ee.format){let Y=e==null?void 0:e.types.name.format("endpoint",{code:O,type:"response",method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},D);Y&&(D=`${S}${Y}`);}let se=i$1?`${ne(D,K,{inheritSingleTypeExpression:true})}
58
+ `:`export type ${D} = ${K};
59
+ `;e!=null&&e.folderSplit?A[g$1].types+=se:fe+=se,k[O]=D;let V=parseInt(O);V>=200&&V<300&&(Ae=D);}});}let Ie=E=>!E||!E.length?"":E.map(b=>Object.entries(b).map(([M,H])=>{let X=M,ee="";return Array.isArray(H)&&H.length&&(ee=`
60
+ - Scopes: [\`${H.join("`, `")}\`]`,X=`**${X}**`),`
61
+ - ${X}${ee}`}).join("")).join(`
62
+ `),ye=a!=null&&a.security?Ie(a.security):"",ge="";if(!((Xn=(Zn=e==null?void 0:e.endpoints)==null?void 0:Zn.doc)!=null&&Xn.disable)){let E="";if((nt=(et=e==null?void 0:e.endpoints)==null?void 0:et.doc)!=null&&nt.showCurl||i$1){let b={},O="",M="";(tt=a.requestBody)!=null&&tt.content&&Object.keys(a.requestBody.content).forEach(se=>{let V=a.requestBody.content[se].schema;if(V){Array.isArray(b["Content-type"])?b["Content-type"].push(se):b["Content-type"]=[se];let Y=ae(r,V);Y&&(O=Y);}}),a!=null&&a.security&&a.security.forEach(D=>{Object.keys(D).forEach(se=>{var Y,qe;let V=(qe=(Y=r.components)==null?void 0:Y.securitySchemes)==null?void 0:qe[se];V&&(V.type==="mutualTLS"?M+=`
63
+ --cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:V.type==="apiKey"?b[(V==null?void 0:V.name)||"X-API-KEY"]="{API_KEY_VALUE}":b.Authorization=`${(V==null?void 0:V.scheme)==="basic"?"Basic":"Bearer"} {${(V==null?void 0:V.scheme)==="basic"?"VALUE":"TOKEN"}}`);});});let H={};Object.keys(b).forEach(D=>{Array.isArray(b[D])?H[D]=b[D].join("; "):H[D]=b[D];});let ee=`${CurlGenerator({url:R+t,method:p.toUpperCase(),headers:H,body:O})||`curl ${R+t} -X ${p.toUpperCase()}`}${M}`;E=i$1?`
64
+ \`\`\`bash
65
+ ${ee}
66
+ \`\`\``:`
67
+ \`\`\`bash
68
+ ${ee}
69
+ \`\`\``;}if(i$1){let b=[];a!=null&&a.description&&b.push(`* ${a.description}`),b.push(`* **Method**: ${p.toUpperCase()}`),b.push(`* **Summary**: ${(a==null?void 0:a.summary)||""}`),b.push(`* **Tags**: [${((rt=a==null?void 0:a.tags)==null?void 0:rt.join(", "))||""}]`),b.push(`* **OperationId**: ${(a==null?void 0:a.operationId)||""}`),z&&(b.push("* **Query**:"),b.push("```python"),z.split(`
70
+ `).filter(O=>O.trim().length>0).forEach(O=>b.push(O)),b.push("```")),P&&(b.push("* **DTO**:"),b.push("```python"),P.split(`
71
+ `).filter(O=>O.trim().length>0).forEach(O=>b.push(O)),b.push("```")),K&&(b.push("* **Response**:"),b.push("```python"),Object.entries(k).forEach(([O,M])=>{b.push(`${O}: ${String(M).replace(/\n/g," ")}`);}),b.push("```")),ye&&(b.push("* **Security**:"),ye.split(`
72
+ `).filter(O=>O.trim().length>0).forEach(O=>b.push(O.replace(/\*\*/g,"")))),ge=`"""
73
+ ${b.join(`
74
+ `)}${E}
75
+ """
76
+ `;}else ge=`/**${a!=null&&a.description?`
77
+ * ${a==null?void 0:a.description} `:""}
78
+ * **Method**: \`${p.toUpperCase()}\`
79
+ * **Summary**: ${(a==null?void 0:a.summary)||""}
80
+ * **Tags**: [${((st=a==null?void 0:a.tags)==null?void 0:st.join(", "))||""}]
81
+ * **OperationId**: ${(a==null?void 0:a.operationId)||""} ${z?`
82
+ * **Query**: ${j(z)} `:""}${P?`
83
+ * **DTO**: ${j(P)} `:""}${K?`
84
+ * **Response**: ${Object.entries(k).map(([b,O])=>`
85
+ - **${b}**: ${j(O,2)} `).join("")}`:""}${ye?`
86
+ * **Security**: ${ye}
87
+ `:""}${E}
88
+ */
89
+ `;}let he=(at=(ot=e==null?void 0:e.endpoints)==null?void 0:ot.name)!=null&&at.useOperationId&&((it=a==null?void 0:a.operationId)==null?void 0:it.length)>0?a.operationId:`${f.name}`;if((pt=(lt=e==null?void 0:e.endpoints)==null?void 0:lt.name)!=null&&pt.format){let E=e==null?void 0:e.endpoints.name.format({method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},he);E&&(he=E);}let Be={method:`"${p}"`,operationId:`"${a==null?void 0:a.operationId}"`,url:B,tags:(a==null?void 0:a.tags)||[]},Ut=`Endpoint(
90
+ method="${p}",
91
+ operationId="${(a==null?void 0:a.operationId)||""}",
92
+ url=${B},
93
+ tags=[${((a==null?void 0:a.tags)||[]).map(E=>`"${E}"`).join(", ")}]
94
+ )`,gn=i$1?`${U}${he} = ${Ut}
95
+ ${ge?`${ge}`:""}
96
+
97
+ `:`${ge}export const ${U}${he} = ${((mt=(ut=e==null?void 0:e.endpoints)==null?void 0:ut.value)==null?void 0:mt.type)==="object"?i(Be):B};
98
+ `;e!=null&&e.folderSplit?A[g$1].endpoints+=gn:pe+=gn;let Lt={name:`${U}${he}`,method:p,path:t,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId,tags:u,parameters:(ct=a==null?void 0:a.parameters)==null?void 0:ct.filter(E=>!E.$ref&&E.in&&E.name).map(E=>{var b;return {name:E.name,in:E.in,required:E.required,type:((b=E.schema)==null?void 0:b.type)||"string"}}),requestBody:T?{type:P,required:T.required}:void 0,responses:k?Object.entries(k).reduce((E,[b,O])=>(E[b]={type:O},E),{}):void 0,queryType:x,dtoType:N,responseType:Ae||void 0};ve.push(Lt);});}),e!=null&&e.folderSplit){let t=`from dataclasses import dataclass
99
+ from typing import List
100
+
101
+ @dataclass
102
+ class Endpoint:
103
+ method: str
104
+ operationId: str
105
+ url: str
106
+ tags: List[str]
107
+
108
+
109
+
110
+ `;for(let[o,I]of Object.entries(A))if(I.endpoints||I.types){let $=Z.join(C,o);if(I.endpoints){let p=Z.join(Ce,$,`endpoints.${y}`);yield ue.promises.mkdir(Z.dirname(p),{recursive:true}),yield xe(p,i$1?`${t}${I.endpoints}`:I.endpoints,e);}if(I.types){let p=Z.join(Ce,$,`types.${y}`);yield ue.promises.mkdir(Z.dirname(p),{recursive:true});let f=Object.values(le).length>0?i$1?`from __future__ import annotations
111
+ from dataclasses import dataclass
112
+ from . import shared as Shared
113
+ ${Q(I.types)}
114
+ ${I.types}`:`import * as Shared from "../shared";
115
+
116
+ ${I.types}`:I.types;yield xe(p,f,e);}if(((cn=e==null?void 0:e.validations)==null?void 0:cn.disable)!==true&&I.validation&&!i$1){let p=((dn=e.validations)==null?void 0:dn.library)||"zod",f=p==="joi"?'import Joi from "joi";':p==="yup"?'import * as yup from "yup";':'import { z } from "zod";',u=Z.join(Ce,$,"validations.ts");yield ue.promises.mkdir(Z.dirname(u),{recursive:true}),yield xe(u,`${f}
117
+
118
+ ${I.validation}`,e);}}}if(pe.length>0){let t=`from dataclasses import dataclass
119
+ from typing import List
120
+
121
+ @dataclass
122
+ class Endpoint:
123
+ method: str
124
+ operationId: str
125
+ url: str
126
+ tags: List[str]
127
+
128
+
129
+
130
+ `,o=Z.join(Ce,C,`endpoints.${y}`);yield ue.promises.mkdir(Z.dirname(o),{recursive:true}),yield xe(o,i$1?`${t}${pe}`:pe,e);}if(Object.values(le).length>0){let t=Object.values(le).join(`
131
+ `),o=Z.join(Ce,C,e!=null&&e.folderSplit?"":"types",`shared.${y}`);yield ue.promises.mkdir(Z.dirname(o),{recursive:true}),yield xe(o,(i$1?`from __future__ import annotations
132
+ from dataclasses import dataclass
133
+ ${Q(t)}
134
+ `:"")+t,e);}if(fe.length>0){let t=Z.join(Ce,C,"types",`index.${y}`);yield ue.promises.mkdir(Z.dirname(t),{recursive:true}),yield xe(t,(Object.values(le).length>0?i$1?`from __future__ import annotations
135
+ from dataclasses import dataclass
136
+ from . import shared as Shared
137
+ ${Q(fe)}
138
+ `:`import * as Shared from "./shared";
139
+
140
+ `:"")+fe,e);}if(((fn=e==null?void 0:e.validations)==null?void 0:fn.disable)!==true&&!(e!=null&&e.folderSplit)&&!i$1){let t=((yn=e.validations)==null?void 0:yn.library)||"zod",o=t==="joi"?'import Joi from "joi";':t==="yup"?'import * as yup from "yup";':'import { z } from "zod";',I=Object.values(A).map($=>$.validation).filter($=>$.length>0).join("");if(I){let $=Z.join(Ce,C,"validations.ts");yield ue.promises.mkdir(Z.dirname($),{recursive:true}),yield xe($,`${o}
141
+
142
+ ${I}`,e);}}return It(m,ve),console.info(`\u2705 Successfully synced ${m}`),{success:true}}),Fe=xt;});var At,Ve,Ee,Ye,Ze,Xe,wt=d(()=>{At=(l,c)=>{let m=l;return c.tags&&c.tags.length>0&&(m=m.filter(e=>!e.tags||e.tags.length===0?false:e.tags.some(s=>c.tags.includes(s)))),c.endpoints&&c.endpoints.length>0&&(m=m.filter(e=>c.endpoints.includes(e.name))),m},Ve=(l,c,m=false)=>{var r,C;let e=c.baseURL||"",s=c.auth,n=`// Generated Fetch API Client
143
+ `;n+=`// This file was auto-generated. Add custom code in the marked sections.
144
+
145
+ `,n+=`import type {
146
+ `;let d=new Set;if(l.forEach(i=>{i.queryType&&d.add(i.queryType),i.dtoType&&d.add(i.dtoType),i.responseType&&d.add(i.responseType);}),d.forEach(i=>{n+=` ${i},
147
+ `;}),n+=`} from '../types';
148
+
149
+ `,n+=`import {
150
+ `,l.forEach(i=>{n+=` ${i.name} as ${i.name}_endpoint,
151
+ `;}),n+=`} from '../endpoints';
152
+
153
+ `,n+=`export interface ApiConfig {
154
+ `,n+=` baseURL?: string;
155
+ `,n+=` headers?: Record<string, string>;
156
+ `,s&&(n+=` auth?: {
157
+ `,s.type==="bearer"?n+=` token?: string;
158
+ `:s.type==="basic"?(n+=` username?: string;
159
+ `,n+=` password?: string;
160
+ `):s.type==="apiKey"&&(n+=` apiKey?: string;
161
+ `),n+=` };
162
+ `),n+=`}
163
+
164
+ `,n+=`let globalConfig: ApiConfig = {
165
+ `,n+=` baseURL: "${e}",
166
+ `,n+=`};
167
+
168
+ `,n+=`export const setApiConfig = (config: Partial<ApiConfig>) => {
169
+ `,n+=` globalConfig = { ...globalConfig, ...config };
170
+ `,n+=`};
171
+
172
+ `,(r=c.errorHandling)!=null&&r.generateErrorClasses&&(n+=`export class ApiError extends Error {
173
+ `,n+=` constructor(
174
+ `,n+=` message: string,
175
+ `,n+=` public statusCode: number,
176
+ `,n+=` public response?: any
177
+ `,n+=` ) {
178
+ `,n+=` super(message);
179
+ `,n+=` this.name = 'ApiError';
180
+ `,n+=` }
181
+ `,n+=`}
182
+
183
+ `),n+=`async function fetchAPI<T>(
184
+ `,n+=` url: string,
185
+ `,n+=` options: RequestInit = {}
186
+ `,n+=`): Promise<T> {
187
+ `,n+=` const headers: Record<string, string> = {
188
+ `,n+=` 'Content-Type': 'application/json',
189
+ `,n+=` ...globalConfig.headers,
190
+ `,n+=` ...(options.headers as Record<string, string>),
191
+ `,n+=` };
192
+
193
+ `,s){if(s.type==="bearer")n+=` if (globalConfig.auth?.token) {
194
+ `,n+=" headers['Authorization'] = `Bearer ${globalConfig.auth.token}`;\n",n+=` }
195
+
196
+ `;else if(s.type==="basic")n+=` if (globalConfig.auth?.username && globalConfig.auth?.password) {
197
+ `,n+=" const credentials = btoa(`${globalConfig.auth.username}:${globalConfig.auth.password}`);\n",n+=" headers['Authorization'] = `Basic ${credentials}`;\n",n+=` }
198
+
199
+ `;else if(s.type==="apiKey"){let i=s.name||"X-API-Key";(s.in==="header"||!s.in)&&(n+=` if (globalConfig.auth?.apiKey) {
200
+ `,n+=` headers['${i}'] = globalConfig.auth.apiKey;
201
+ `,n+=` }
202
+
203
+ `);}}return n+=" const response = await fetch(`${globalConfig.baseURL}${url}`, {\n",n+=` ...options,
204
+ `,n+=` headers,
205
+ `,n+=` });
206
+
207
+ `,n+=` if (!response.ok) {
208
+ `,(C=c.errorHandling)!=null&&C.generateErrorClasses?(n+=` const errorData = await response.json().catch(() => ({}));
209
+ `,n+=` throw new ApiError(
210
+ `,n+=` errorData.message || response.statusText,
211
+ `,n+=` response.status,
212
+ `,n+=` errorData
213
+ `,n+=` );
214
+ `):n+=" throw new Error(`HTTP error! status: ${response.status}`);\n",n+=` }
215
+
216
+ `,n+=` return response.json();
217
+ `,n+=`}
218
+
219
+ `,l.forEach(i=>{var _,q;let y=i.name,A=((_=i.parameters)==null?void 0:_.filter(w=>w.in==="path"))||[],F=((q=i.parameters)==null?void 0:q.filter(w=>w.in==="query"))||[],R=A.length>0,S=F.length>0,U=!!i.requestBody,G=i.responseType||"any";if(n+=`/**
220
+ `,i.summary&&(n+=` * ${i.summary}
221
+ `),n+=` * @method ${i.method.toUpperCase()}
222
+ `,n+=` * @path ${i.path}
223
+ `,i.tags&&i.tags.length>0&&(n+=` * @tags ${i.tags.join(", ")}
224
+ `),n+=` */
225
+ `,n+=`export async function ${y}(`,(R||S||U)&&(n+=`params: {
226
+ `,R&&(n+=` url: {
227
+ `,A.forEach(w=>{let Q={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[w.type||"string"]||"any",W=w.required?"":"?";n+=` ${w.name}${W}: ${Q};
228
+ `;}),n+=` };
229
+ `),S&&(n+=` query: ${i.queryType||"Record<string, any>"};
230
+ `),U&&(n+=` data: ${i.dtoType||"any"};
231
+ `),n+=`}
232
+ `),n+=`): Promise<${G}> {
233
+ `,R||S||U){let w=[];R&&w.push("url"),S&&w.push("query"),U&&w.push("data"),n+=` const { ${w.join(", ")} } = params;
234
+ `;}let j;if(R){let w=A.map(ne=>`url.${ne.name}`).join(", ");j=`${i.name}_endpoint(${w})`;}else j=`${i.name}_endpoint`;S?(n+=` const queryParams = new URLSearchParams();
235
+ `,F.forEach(w=>{w.required?n+=` queryParams.append('${w.name}', String(query.${w.name}));
236
+ `:(n+=` if (query.${w.name} !== undefined) {
237
+ `,n+=` queryParams.append('${w.name}', String(query.${w.name}));
238
+ `,n+=` }
239
+ `);}),n+=` const _url = \`\${${j}}?\${queryParams.toString()}\`;
240
+ `):n+=` const _url = ${j};
241
+ `,n+=` return fetchAPI<${G}>(_url, {
242
+ `,n+=` method: '${i.method.toUpperCase()}',
243
+ `,U&&(n+=` body: JSON.stringify(data),
244
+ `),n+=` });
245
+ `,n+=`}
246
+
247
+ `;}),m&&(n+=`// Export all functions as a default object
248
+ `,n+=`const apiClient = {
249
+ `,n+=` setApiConfig,
250
+ `,l.forEach(i=>{n+=` ${i.name},
251
+ `;}),n+=`};
252
+
253
+ `,n+=`export default apiClient;
254
+ `),n},Ee=(l,c,m=false)=>{var r,C;let e=c.baseURL||"";c.auth;let n=`// Generated Axios API Client
255
+ `;n+=`// This file was auto-generated. Add custom code in the marked sections.
256
+
257
+ `,n+=`import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
258
+
259
+ `,n+=`import type {
260
+ `;let d=new Set;return l.forEach(i=>{i.queryType&&d.add(i.queryType),i.dtoType&&d.add(i.dtoType),i.responseType&&d.add(i.responseType);}),d.forEach(i=>{n+=` ${i},
261
+ `;}),n+=`} from '../types';
262
+
263
+ `,n+=`import {
264
+ `,l.forEach(i=>{n+=` ${i.name},
265
+ `;}),n+=`} from '../endpoints';
266
+
267
+ `,n+=`export interface ApiConfig {
268
+ `,n+=` baseURL?: string;
269
+ `,n+=` headers?: Record<string, string>;
270
+ `,n+=` timeout?: number;
271
+ `,n+=`}
272
+
273
+ `,(r=c.errorHandling)!=null&&r.generateErrorClasses&&(n+=`export class ApiError extends Error {
274
+ `,n+=` constructor(
275
+ `,n+=` message: string,
276
+ `,n+=` public statusCode: number,
277
+ `,n+=` public response?: any
278
+ `,n+=` ) {
279
+ `,n+=` super(message);
280
+ `,n+=` this.name = 'ApiError';
281
+ `,n+=` }
282
+ `,n+=`}
283
+
284
+ `),n+=`class ApiClient {
285
+ `,n+=` private client: AxiosInstance;
286
+
287
+ `,n+=` constructor(config: ApiConfig = {}) {
288
+ `,n+=` this.client = axios.create({
289
+ `,n+=` baseURL: config.baseURL || "${e}",
290
+ `,n+=` timeout: config.timeout || 30000,
291
+ `,n+=` headers: {
292
+ `,n+=` 'Content-Type': 'application/json',
293
+ `,n+=` ...config.headers,
294
+ `,n+=` },
295
+ `,n+=` });
296
+
297
+ `,n+=` // Response interceptor for error handling
298
+ `,n+=` this.client.interceptors.response.use(
299
+ `,n+=` (response) => response,
300
+ `,n+=` (error) => {
301
+ `,(C=c.errorHandling)!=null&&C.generateErrorClasses?(n+=` const message = error.response?.data?.message || error.message;
302
+ `,n+=` const statusCode = error.response?.status || 500;
303
+ `,n+=` throw new ApiError(message, statusCode, error.response?.data);
304
+ `):n+=` return Promise.reject(error);
305
+ `,n+=` }
306
+ `,n+=` );
307
+ `,n+=` }
308
+
309
+ `,n+=` updateConfig(config: Partial<ApiConfig>) {
310
+ `,n+=` Object.assign(this.client.defaults, config);
311
+ `,n+=` }
312
+
313
+ `,l.forEach(i=>{var j,_;let y=i.name,A=((j=i.parameters)==null?void 0:j.filter(q=>q.in==="path"))||[],F=((_=i.parameters)==null?void 0:_.filter(q=>q.in==="query"))||[],R=A.length>0,S=F.length>0,U=!!i.requestBody,G=i.responseType||"any";if(n+=` /**
314
+ `,i.summary&&(n+=` * ${i.summary}
315
+ `),n+=` * @method ${i.method.toUpperCase()}
316
+ `,n+=` * @path ${i.path}
317
+ `,i.tags&&i.tags.length>0&&(n+=` * @tags ${i.tags.join(", ")}
318
+ `),n+=` */
319
+ `,n+=` async ${y}(`,(R||S||U)&&(n+=`params: {
320
+ `,R&&(n+=` url: {
321
+ `,A.forEach(q=>{let ne={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[q.type||"string"]||"any",Q=q.required?"":"?";n+=` ${q.name}${Q}: ${ne};
322
+ `;}),n+=` };
323
+ `),S&&(n+=` query: ${i.queryType||"Record<string, any>"};
324
+ `),U&&(n+=` data: ${i.dtoType||"any"};
325
+ `),n+=" }"),n+=`): Promise<${G}> {
326
+ `,R||S||U){let q=[];R&&q.push("url"),S&&q.push("query"),U&&q.push("data"),n+=` const { ${q.join(", ")} } = params;
327
+ `;}if(R){let q=A.map(w=>`url.${w.name}`).join(", ");n+=` const _url = ${i.name}(${q});
328
+ `;}else n+=` const _url = ${i.name};
329
+ `;n+=` const config: AxiosRequestConfig = {};
330
+ `,S&&(n+=` config.params = { ...query };
331
+ `),n+=` const response = await this.client.${i.method.toLowerCase()}<${G}>(
332
+ `,n+=` _url,
333
+ `,U?n+=` data,
334
+ config
335
+ `:n+=` config
336
+ `,n+=` );
337
+ `,n+=` return response.data;
338
+ `,n+=` }
339
+
340
+ `;}),n+=`}
341
+
342
+ `,m?n+=`export default ApiClient;
343
+ `:(n+=`export const apiClient = new ApiClient();
344
+ `,n+=`export default apiClient;
345
+ `),n},Ye=(l,c)=>{var C,i;let m=((C=c.reactQuery)==null?void 0:C.version)||5,e=((i=c.reactQuery)==null?void 0:i.mutations)!==false,s=!!(c.reactQuery&&c.reactQuery.infiniteQueries&&!c.reactQuery.infiniteQueries.disable),n=`// Generated React Query Hooks
346
+ `;n+=`// This file was auto-generated. Add custom code in the marked sections.
347
+
348
+ `;let d=e&&l.some(y=>["POST","PUT","PATCH","DELETE"].includes(y.method.toUpperCase()));if(m===5){let y=d?`import { useQuery, useMutation, UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
349
+ `:`import { useQuery, UseQueryOptions } from '@tanstack/react-query';
350
+ `;s&&(y=y.replace("@tanstack/react-query';\\n",`@tanstack/react-query';
351
+ import { useInfiniteQuery, UseInfiniteQueryOptions } from '@tanstack/react-query';
352
+ `)),n+=y;}else {let y=d?`import { useQuery, useMutation, UseQueryOptions, UseMutationOptions } from 'react-query';
353
+ `:`import { useQuery, UseQueryOptions } from 'react-query';
354
+ `;s&&(y=y.replace("react-query';\\n",`react-query';
355
+ import { useInfiniteQuery, UseInfiniteQueryOptions } from 'react-query';
356
+ `)),n+=y;}n+=`
357
+ `,n+=`import apiClient from './client';
358
+ `,n+=`import type {
359
+ `;let r=new Set;return l.forEach(y=>{y.queryType&&r.add(y.queryType),y.dtoType&&r.add(y.dtoType),y.responseType&&r.add(y.responseType);}),r.forEach(y=>{n+=` ${y},
360
+ `;}),n+=`} from '../types';
361
+
362
+ `,l.forEach(y=>{var w,ne;let A=y.method.toUpperCase(),F=A==="GET",R=["POST","PUT","PATCH","DELETE"].includes(A),S=((w=y.parameters)==null?void 0:w.filter(Q=>Q.in==="path"))||[],U=((ne=y.parameters)==null?void 0:ne.filter(Q=>Q.in==="query"))||[],G=S.length>0,j=U.length>0,_=!!y.requestBody,q=y.responseType||"any";if(F){let Q=U.map(ie=>ie.name.toLowerCase()),de=(Q.includes("page")||Q.includes("cursor")||Q.includes("cursorid")||Q.includes("after")||Q.includes("before"))&&s,ae=`use${y.name.charAt(0).toUpperCase()+y.name.slice(1)}`;if(n+=`/**
363
+ `,y.summary&&(n+=` * ${y.summary}
364
+ `),n+=` * @method ${A}
365
+ `,n+=` * @path ${y.path}
366
+ `,y.tags&&y.tags.length>0&&(n+=` * @tags ${y.tags.join(", ")}
367
+ `),n+=` */
368
+ `,G||j?(n+=`export function ${ae}(
369
+ `,n+=` params: {
370
+ `,G&&(n+=` url: {
371
+ `,S.forEach(ie=>{let fe={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[ie.type||"string"]||"any",le=ie.required?"":"?";n+=` ${ie.name}${le}: ${fe};
372
+ `;}),n+=` };
373
+ `),j&&(n+=` query: ${y.queryType||"Record<string, any>"};
374
+ `),n+=` },
375
+ `,n+=` options?: Omit<UseQueryOptions<${q}>, 'queryKey' | 'queryFn'>
376
+ `,n+=`) {
377
+ `,n+=` return useQuery({
378
+ `,n+=` queryKey: ['${y.name}', params],
379
+ `,n+=` queryFn: () => apiClient.${y.name}(params),
380
+ `,n+=` ...options,
381
+ `,n+=` });
382
+ `,n+=`}
383
+
384
+ `):(n+=`export function ${ae}(
385
+ `,n+=` options?: Omit<UseQueryOptions<${q}>, 'queryKey' | 'queryFn'>
386
+ `,n+=`) {
387
+ `,n+=` return useQuery({
388
+ `,n+=` queryKey: ['${y.name}'],
389
+ `,n+=` queryFn: () => apiClient.${y.name}(),
390
+ `,n+=` ...options,
391
+ `,n+=` });
392
+ `,n+=`}
393
+
394
+ `),de){let ie=`${ae}Infinite`;G||j?(n+=`export function ${ie}(
395
+ `,n+=` params: {
396
+ `,G&&(n+=` url: {
397
+ `,S.forEach(pe=>{let le={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[pe.type||"string"]||"any",ve=pe.required?"":"?";n+=` ${pe.name}${ve}: ${le};
398
+ `;}),n+=` };
399
+ `),j&&(n+=` query: ${y.queryType||"Record<string, any>"};
400
+ `),n+=` },
401
+ `,n+=` options?: Omit<UseInfiniteQueryOptions<${q}, Error, ${q}>, 'queryKey' | 'queryFn'>
402
+ `,n+=`) {
403
+ `,n+=` return useInfiniteQuery({
404
+ `,n+=` queryKey: ['${y.name}', params],
405
+ `,n+=` queryFn: ({ pageParam = 1 }) => apiClient.${y.name}({ ...params, query: { ...(params.query || {}), page: pageParam } }),
406
+ `,n+=` getNextPageParam: (lastPage) => lastPage?.nextPage ?? lastPage?.nextCursor ?? null,
407
+ `,n+=` ...options,
408
+ `,n+=` });
409
+ `,n+=`}
410
+
411
+ `):(n+=`export function ${ie}(
412
+ `,n+=` options?: Omit<UseInfiniteQueryOptions<${q}, Error, ${q}>, 'queryKey' | 'queryFn'>
413
+ `,n+=`) {
414
+ `,n+=` return useInfiniteQuery({
415
+ `,n+=` queryKey: ['${y.name}'],
416
+ `,n+=` queryFn: ({ pageParam = 1 }) => apiClient.${y.name}({ query: { page: pageParam } }),
417
+ `,n+=` getNextPageParam: (lastPage) => lastPage?.nextPage ?? lastPage?.nextCursor ?? null,
418
+ `,n+=` ...options,
419
+ `,n+=` });
420
+ `,n+=`}
421
+
422
+ `);}}else if(R&&e){let Q=`use${y.name.charAt(0).toUpperCase()+y.name.slice(1)}`;n+=`/**
423
+ `,y.summary&&(n+=` * ${y.summary}
424
+ `),n+=` * @method ${A}
425
+ `,n+=` * @path ${y.path}
426
+ `,y.tags&&y.tags.length>0&&(n+=` * @tags ${y.tags.join(", ")}
427
+ `),n+=` */
428
+ `;let W="void";(G||j||_)&&(W=`{
429
+ `,G&&(W+=` url: {
430
+ `,S.forEach(de=>{let ie={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[de.type||"string"]||"any",pe=de.required?"":"?";W+=` ${de.name}${pe}: ${ie};
431
+ `;}),W+=` };
432
+ `),j&&(W+=` query: ${y.queryType||"Record<string, any>"};
433
+ `),_&&(W+=` data: ${y.dtoType||"any"};
434
+ `),W+=" }"),n+=`export function ${Q}(
435
+ `,n+=` options?: Omit<UseMutationOptions<${q}, Error, ${W}>, 'mutationFn'>
436
+ `,n+=`) {
437
+ `,n+=` return useMutation({
438
+ `,n+=" mutationFn: (",W!=="void"&&(n+=`variables: ${W}`),n+=`) => {
439
+ `,n+=` return apiClient.${y.name}(${W!=="void"?"variables":""});
440
+ `,n+=` },
441
+ `,n+=` ...options,
442
+ `,n+=` });
443
+ `,n+=`}
444
+
445
+ `;}}),n},Ze=(l,c)=>{var d;let m=((d=c.swr)==null?void 0:d.mutations)!==false,e=`// Generated SWR Hooks
446
+ `;e+=`// This file was auto-generated. Add custom code in the marked sections.
447
+
448
+ `,e+=`/**
449
+ `,e+=` * SWR Hooks - Complete Usage Guide
450
+ `,e+=` *
451
+ `,e+=` * This file contains type-safe SWR hooks generated from your OpenAPI specification.
452
+ `,e+=` *
453
+ `,e+=` * ## Quick Start
454
+ `,e+=` *
455
+ `,e+=` * 1. Configure SWR globally:
456
+ `,e+=` *
457
+ `,e+=" * ```typescript\n",e+=` * // app/providers.tsx
458
+ `,e+=` * import { SWRConfig } from 'swr';
459
+ `,e+=` *
460
+ `,e+=` * export function Providers({ children }) {
461
+ `,e+=` * return (
462
+ `,e+=` * <SWRConfig value={{
463
+ `,e+=` * revalidateOnFocus: false,
464
+ `,e+=` * shouldRetryOnError: true,
465
+ `,e+=` * errorRetryCount: 3,
466
+ `,e+=` * }}>
467
+ `,e+=` * {children}
468
+ `,e+=` * </SWRConfig>
469
+ `,e+=` * );
470
+ `,e+=` * }
471
+ `,e+=" * ```\n",e+=` *
472
+ `,e+=` * 2. Use the hooks in your components:
473
+ `,e+=` *
474
+ `,e+=` * ### Reading Data (GET)
475
+ `,e+=` *
476
+ `,e+=" * ```typescript\n",e+=` * import { useGetItems } from './hooks';
477
+ `,e+=` *
478
+ `,e+=` * function ItemList() {
479
+ `,e+=` * const { data, error, isLoading, mutate } = useGetItems();
480
+ `,e+=` *
481
+ `,e+=` * if (isLoading) return <div>Loading...</div>;
482
+ `,e+=` * if (error) return <div>Error: {error.message}</div>;
483
+ `,e+=` *
484
+ `,e+=` * return (
485
+ `,e+=` * <div>
486
+ `,e+=` * {data?.map(item => <div key={item.id}>{item.name}</div>)}
487
+ `,e+=` * <button onClick={() => mutate()}>Refresh</button>
488
+ `,e+=` * </div>
489
+ `,e+=` * );
490
+ `,e+=` * }
491
+ `,e+=" * ```\n",e+=` *
492
+ `,e+=` * ### With Path Parameters
493
+ `,e+=` *
494
+ `,e+=" * ```typescript\n",e+=` * function ItemDetail({ id }: { id: string }) {
495
+ `,e+=` * const { data } = useGetItemById({ url: { id } });
496
+ `,e+=` * return <div>{data?.name}</div>;
497
+ `,e+=` * }
498
+ `,e+=" * ```\n",e+=` *
499
+ `,e+=` * ### Creating Data (POST)
500
+ `,e+=` *
501
+ `,e+=" * ```typescript\n",e+=` * import { useCreateItem, useGetItems } from './hooks';
502
+ `,e+=` *
503
+ `,e+=` * function CreateItem() {
504
+ `,e+=` * const { trigger, isMutating, error } = useCreateItem();
505
+ `,e+=` * const { mutate: revalidateList } = useGetItems();
506
+ `,e+=` *
507
+ `,e+=` * const handleSubmit = async (name: string) => {
508
+ `,e+=` * try {
509
+ `,e+=` * const result = await trigger({
510
+ `,e+=` * arg: { data: { name } }
511
+ `,e+=` * });
512
+ `,e+=` * await revalidateList(); // Refresh the list
513
+ `,e+=` * alert('Created!');
514
+ `,e+=` * } catch (err) {
515
+ `,e+=` * console.error('Failed:', err);
516
+ `,e+=` * }
517
+ `,e+=` * };
518
+ `,e+=` *
519
+ `,e+=` * return (
520
+ `,e+=` * <button onClick={() => handleSubmit('New Item')} disabled={isMutating}>
521
+ `,e+=` * {isMutating ? 'Creating...' : 'Create'}
522
+ `,e+=` * </button>
523
+ `,e+=` * );
524
+ `,e+=` * }
525
+ `,e+=" * ```\n",e+=` *
526
+ `,e+=` * ### Updating Data (PUT/PATCH)
527
+ `,e+=` *
528
+ `,e+=" * ```typescript\n",e+=` * function UpdateItem({ id }: { id: string }) {
529
+ `,e+=` * const { data, mutate: revalidate } = useGetItemById({ url: { id } });
530
+ `,e+=` * const { trigger } = useUpdateItem();
531
+ `,e+=` *
532
+ `,e+=` * const handleUpdate = async (newName: string) => {
533
+ `,e+=` * await trigger({
534
+ `,e+=` * arg: {
535
+ `,e+=` * url: { id },
536
+ `,e+=` * data: { name: newName }
537
+ `,e+=` * }
538
+ `,e+=` * });
539
+ `,e+=` * await revalidate(); // Refresh the detail view
540
+ `,e+=` * };
541
+ `,e+=` *
542
+ `,e+=` * return <button onClick={() => handleUpdate('Updated')}>Update</button>;
543
+ `,e+=` * }
544
+ `,e+=" * ```\n",e+=` *
545
+ `,e+=` * ### Deleting Data (DELETE)
546
+ `,e+=` *
547
+ `,e+=" * ```typescript\n",e+=` * function DeleteItem({ id }: { id: string }) {
548
+ `,e+=` * const { trigger, isMutating } = useDeleteItem();
549
+ `,e+=` * const { mutate: revalidateList } = useGetItems();
550
+ `,e+=` *
551
+ `,e+=` * const handleDelete = async () => {
552
+ `,e+=` * if (confirm('Delete?')) {
553
+ `,e+=` * await trigger({ arg: { url: { id } } });
554
+ `,e+=` * await revalidateList();
555
+ `,e+=` * }
556
+ `,e+=` * };
557
+ `,e+=` *
558
+ `,e+=` * return (
559
+ `,e+=` * <button onClick={handleDelete} disabled={isMutating}>
560
+ `,e+=` * {isMutating ? 'Deleting...' : 'Delete'}
561
+ `,e+=` * </button>
562
+ `,e+=` * );
563
+ `,e+=` * }
564
+ `,e+=" * ```\n",e+=` *
565
+ `,e+=` * ## Advanced Patterns
566
+ `,e+=` *
567
+ `,e+=` * ### Optimistic Updates
568
+ `,e+=` *
569
+ `,e+=" * ```typescript\n",e+=` * function OptimisticUpdate({ id }: { id: string }) {
570
+ `,e+=` * const { data, mutate: revalidate } = useGetItemById({ url: { id } });
571
+ `,e+=` * const { trigger } = useUpdateItem();
572
+ `,e+=` *
573
+ `,e+=` * const handleUpdate = async (newName: string) => {
574
+ `,e+=` * // Update UI immediately
575
+ `,e+=` * revalidate({ ...data!, name: newName }, false);
576
+ `,e+=` *
577
+ `,e+=` * try {
578
+ `,e+=` * await trigger({ arg: { url: { id }, data: { name: newName } } });
579
+ `,e+=` * await revalidate(); // Sync with server
580
+ `,e+=` * } catch (err) {
581
+ `,e+=` * await revalidate(); // Rollback on error
582
+ `,e+=` * }
583
+ `,e+=` * };
584
+ `,e+=` *
585
+ `,e+=` * return <button onClick={() => handleUpdate('New')}>Update</button>;
586
+ `,e+=` * }
587
+ `,e+=" * ```\n",e+=` *
588
+ `,e+=` * ### Conditional Fetching
589
+ `,e+=` *
590
+ `,e+=" * ```typescript\n",e+=` * function ConditionalFetch({ id, enabled }: { id: string; enabled: boolean }) {
591
+ `,e+=` * // Only fetch when enabled is true
592
+ `,e+=` * const { data } = useGetItemById(enabled ? { url: { id } } : null);
593
+ `,e+=` * return <div>{data?.name || 'Not loaded'}</div>;
594
+ `,e+=` * }
595
+ `,e+=" * ```\n",e+=` *
596
+ `,e+=` * ### Pagination
597
+ `,e+=` *
598
+ `,e+=" * ```typescript\n",e+=` * function PaginatedList() {
599
+ `,e+=` * const [page, setPage] = useState(1);
600
+ `,e+=` * const { data, isLoading } = useGetItems({ query: { page, limit: 10 } });
601
+ `,e+=` *
602
+ `,e+=` * return (
603
+ `,e+=` * <div>
604
+ `,e+=` * {data?.items.map(item => <div key={item.id}>{item.name}</div>)}
605
+ `,e+=` * <button onClick={() => setPage(p => p - 1)} disabled={page === 1}>
606
+ `,e+=` * Previous
607
+ `,e+=` * </button>
608
+ `,e+=` * <button onClick={() => setPage(p => p + 1)}>Next</button>
609
+ `,e+=` * </div>
610
+ `,e+=` * );
611
+ `,e+=` * }
612
+ `,e+=" * ```\n",e+=` *
613
+ `,e+=` * ### Custom Configuration
614
+ `,e+=` *
615
+ `,e+=" * ```typescript\n",e+=` * function CustomConfig({ id }: { id: string }) {
616
+ `,e+=` * const { data } = useGetItemById(
617
+ `,e+=` * { url: { id } },
618
+ `,e+=` * {
619
+ `,e+=` * refreshInterval: 5000, // Refresh every 5s
620
+ `,e+=` * revalidateOnFocus: true, // Refresh on window focus
621
+ `,e+=` * dedupingInterval: 2000, // Dedupe within 2s
622
+ `,e+=` * onError: (err) => console.error(err),
623
+ `,e+=` * onSuccess: (data) => console.log('Loaded:', data),
624
+ `,e+=` * }
625
+ `,e+=` * );
626
+ `,e+=` * return <div>{data?.name}</div>;
627
+ `,e+=` * }
628
+ `,e+=" * ```\n",e+=` *
629
+ `,e+=` * ## Hook Return Values
630
+ `,e+=` *
631
+ `,e+=` * ### Query Hooks (GET)
632
+ `,e+=" * - `data`: The response data (undefined while loading)\n",e+=" * - `error`: Error object if request failed\n",e+=" * - `isLoading`: True during initial load\n",e+=" * - `isValidating`: True during revalidation\n",e+=" * - `mutate()`: Manually trigger revalidation\n",e+=` *
633
+ `,e+=` * ### Mutation Hooks (POST/PUT/DELETE)
634
+ `,e+=" * - `trigger()`: Execute the mutation\n",e+=" * - `data`: The response data from the mutation\n",e+=" * - `error`: Error object if mutation failed\n",e+=" * - `isMutating`: True while mutation is in progress\n",e+=" * - `reset()`: Reset the mutation state\n",e+=` *
635
+ `,e+=` * @see https://swr.vercel.app/docs/getting-started
636
+ `,e+=` * @see https://swr.vercel.app/docs/mutation
637
+ `,e+=` */
638
+
639
+ `,e+=`import useSWR, { SWRConfiguration } from 'swr';
640
+ `,m&&l.some(r=>["POST","PUT","PATCH","DELETE"].includes(r.method.toUpperCase()))&&(e+=`import useSWRMutation, { SWRMutationConfiguration } from 'swr/mutation';
641
+ `),e+=`
642
+ `,e+=`import apiClient from './client';
643
+ `,e+=`import type {
644
+ `;let n=new Set;return l.forEach(r=>{r.queryType&&n.add(r.queryType),r.dtoType&&n.add(r.dtoType),r.responseType&&n.add(r.responseType);}),n.forEach(r=>{e+=` ${r},
645
+ `;}),e+=`} from '../types';
646
+
647
+ `,l.forEach(r=>{var j,_;let C=r.method.toUpperCase(),i=C==="GET",y=["POST","PUT","PATCH","DELETE"].includes(C),A=((j=r.parameters)==null?void 0:j.filter(q=>q.in==="path"))||[],F=((_=r.parameters)==null?void 0:_.filter(q=>q.in==="query"))||[],R=A.length>0,S=F.length>0,U=!!r.requestBody,G=r.responseType||"any";if(i){let q=`use${r.name.charAt(0).toUpperCase()+r.name.slice(1)}`;e+=`/**
648
+ `,r.summary&&(e+=` * ${r.summary}
649
+ `),e+=` * @method ${C}
650
+ `,e+=` * @path ${r.path}
651
+ `,r.tags&&r.tags.length>0&&(e+=` * @tags ${r.tags.join(", ")}
652
+ `),e+=` */
653
+ `,R||S?(e+=`export function ${q}(
654
+ `,e+=` params: {
655
+ `,R&&(e+=` url: {
656
+ `,A.forEach(w=>{let Q={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[w.type||"string"]||"any",W=w.required?"":"?";e+=` ${w.name}${W}: ${Q};
657
+ `;}),e+=` };
658
+ `),S&&(e+=` query: ${r.queryType||"Record<string, any>"};
659
+ `),e+=` },
660
+ `,e+=` config?: SWRConfiguration<${G}>
661
+ `,e+=`) {
662
+ `,e+=` return useSWR(
663
+ `,e+=` ['${r.name}', params],
664
+ `,e+=` () => apiClient.${r.name}(params),
665
+ `,e+=` config
666
+ `,e+=` );
667
+ `):(e+=`export function ${q}(
668
+ `,e+=` config?: SWRConfiguration<${G}>
669
+ `,e+=`) {
670
+ `,e+=` return useSWR(
671
+ `,e+=` '${r.name}',
672
+ `,e+=` () => apiClient.${r.name}(),
673
+ `,e+=` config
674
+ `,e+=` );
675
+ `),e+=`}
676
+
677
+ `;}else if(y&&m){let q=`use${r.name.charAt(0).toUpperCase()+r.name.slice(1)}`;e+=`/**
678
+ `,r.summary&&(e+=` * ${r.summary}
679
+ `),e+=` * @method ${C}
680
+ `,e+=` * @path ${r.path}
681
+ `,r.tags&&r.tags.length>0&&(e+=` * @tags ${r.tags.join(", ")}
682
+ `),e+=` */
683
+ `;let w="void",ne="void";(R||S||U)&&(w=`{
684
+ `,R&&(w+=` url: {
685
+ `,A.forEach(Q=>{let de={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[Q.type||"string"]||"any",ae=Q.required?"":"?";w+=` ${Q.name}${ae}: ${de};
686
+ `;}),w+=` };
687
+ `),S&&(w+=` query: ${r.queryType||"Record<string, any>"};
688
+ `),U&&(w+=` data: ${r.dtoType||"any"};
689
+ `),w+=" }",ne=`{ arg: ${w} }`),e+=`export function ${q}(
690
+ `,e+=` config?: SWRMutationConfiguration<${G}, Error, string, ${w}>
691
+ `,e+=`) {
692
+ `,e+=` return useSWRMutation(
693
+ `,e+=` '${r.name}',
694
+ `,e+=" async (_, ",w!=="void"&&(e+=`{ arg }: ${ne}`),e+=`) => {
695
+ `,e+=` return apiClient.${r.name}(${w!=="void"?"arg":""});
696
+ `,e+=` },
697
+ `,e+=` config
698
+ `,e+=` );
699
+ `,e+=`}
700
+
701
+ `;}}),e},Xe=(l,c)=>{var d;let m=((d=c.rtkQuery)==null?void 0:d.apiName)||"api",e=c.baseURL||"",s=`// Generated RTK Query API Slice
702
+ `;s+=`// This file was auto-generated. Add custom code in the marked sections.
703
+
704
+ `,s+=`import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
705
+
706
+ `,s+=`import type {
707
+ `;let n=new Set;return l.forEach(r=>{r.queryType&&n.add(r.queryType),r.dtoType&&n.add(r.dtoType),r.responseType&&n.add(r.responseType);}),n.forEach(r=>{s+=` ${r},
708
+ `;}),s+=`} from '../types';
709
+
710
+ `,s+=`import {
711
+ `,l.forEach(r=>{s+=` ${r.name},
712
+ `;}),s+=`} from '../endpoints';
713
+
714
+ `,s+=`const ${m}Api = createApi({
715
+ `,s+=` reducerPath: '${m}Api',
716
+ `,s+=` baseQuery: fetchBaseQuery({
717
+ `,s+=` baseUrl: '${e}',
718
+ `,c.auth&&(s+=` prepareHeaders: (headers, { getState }) => {
719
+ `,s+=` // Get token from your auth state
720
+ `,s+=` // const token = (getState() as RootState).auth.token;
721
+ `,s+=` // if (token) {
722
+ `,c.auth.type==="bearer"?s+=" // headers.set('Authorization', `Bearer ${token}`);\n":c.auth.type==="apiKey"&&c.auth.in==="header"&&(s+=` // headers.set('${c.auth.name||"X-API-Key"}', token);
723
+ `),s+=` // }
724
+ `,s+=` return headers;
725
+ `,s+=` },
726
+ `),s+=` }),
727
+ `,s+=` tagTypes: [${[...new Set(l.flatMap(r=>r.tags||[]))].map(r=>`'${r}'`).join(", ")}],
728
+ `,s+=` endpoints: (builder) => ({
729
+ `,l.forEach((r,C)=>{var _,q;let i=r.method.toUpperCase(),y=i==="GET",A=((_=r.parameters)==null?void 0:_.filter(w=>w.in==="path"))||[],F=((q=r.parameters)==null?void 0:q.filter(w=>w.in==="query"))||[],R=A.length>0,S=F.length>0,U=!!r.requestBody,G=r.responseType||"any";s+=` ${r.name}: builder.${y?"query":"mutation"}<
730
+ `,s+=` ${G},
731
+ `;let j="void";if((R||S||U)&&(j=`{
732
+ `,R&&(j+=` url: {
733
+ `,A.forEach(w=>{let Q={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[w.type||"string"]||"any",W=w.required?"":"?";j+=` ${w.name}${W}: ${Q};
734
+ `;}),j+=` };
735
+ `),S&&(j+=` query: ${r.queryType||"Record<string, any>"};
736
+ `),U&&(j+=` data: ${r.dtoType||"any"};
737
+ `),j+=" }"),s+=` ${j}
738
+ `,s+=` >({
739
+ `,s+=" query: (",j!=="void"&&(s+="arg"),s+=`) => {
740
+ `,R){let w=A.map(ne=>`arg.url.${ne.name}`).join(", ");s+=` const url = ${r.name}(${w});
741
+ `;}else s+=` const url = ${r.name};
742
+ `;s+=` return {
743
+ `,s+=` url,
744
+ `,s+=` method: '${i}',
745
+ `,S&&(s+=` params: arg.query,
746
+ `),U&&(s+=` body: arg.data,
747
+ `),s+=` };
748
+ `,s+=` },
749
+ `,r.tags&&r.tags.length>0&&(y?s+=` providesTags: ['${r.tags[0]}'],
750
+ `:s+=` invalidatesTags: ['${r.tags[0]}'],
751
+ `),s+=` })${C<l.length-1?",":""}
752
+ `;}),s+=` }),
753
+ `,s+=`});
754
+
755
+ `,s+=`export default ${m}Api;
756
+
757
+ `,s};});var Wt,Ot,re,Kt,Ht,Tt=d(()=>{wt();o();Wt=(l,c)=>{var m,e;if((m=c==null?void 0:c.folderSplit)!=null&&m.customFolder){let s=c.folderSplit.customFolder({method:l.method,path:l.path,tags:l.tags,operationId:l.operationId,summary:l.summary});if(s)return s}return (e=c==null?void 0:c.folderSplit)!=null&&e.byTags&&l.tags&&l.tags.length>0?l.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},Ot=(l,c,m,e,s)=>f(null,null,function*(){let n=At(l,m);if(n.length===0)return;let d=m.type||"fetch";m.outputDir||Z.join(s,e,"client");let C=!!(c!=null&&c.folderSplit&&(c.folderSplit.byTags||c.folderSplit.customFolder));if(`${d}${n.length}`,C){let y={};n.forEach(R=>{let S=Wt(R,c);y[S]||(y[S]=[]),y[S].push(R);});let A=Object.keys(y);for(let[R,S]of Object.entries(y)){let U=Z.join(s,e,R);yield ue.promises.mkdir(U,{recursive:true}),`${d}${R}${S.length}`,yield Kt(S,c,m,U,d,R,true);}let F=Z.join(s,e);yield Ht(F,A,d,c);return}let i=Z.join(s,e);switch(yield ue.promises.mkdir(i,{recursive:true}),d){case "fetch":let y=Ve(n,m);y=y.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield re(Z.join(i,"clients.ts"),y,c);break;case "axios":let A=Ee(n,m,false);A=A.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield re(Z.join(i,"clients.ts"),A,c);break;case "react-query":let F=Ee(n,m,false);F=F.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield re(Z.join(i,"clients.ts"),F,c);let R=Ye(n,m);R=R.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';").replace("import apiClient from './client';","import apiClient from './clients';"),yield re(Z.join(i,"hooks.ts"),R,c);break;case "swr":let S=Ee(n,m,false);S=S.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield re(Z.join(i,"clients.ts"),S,c);let U=Ze(n,m);U=U.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';").replace("import apiClient from './client';","import apiClient from './clients';"),yield re(Z.join(i,"hooks.ts"),U,c);break;case "rtk-query":let G=Xe(n,m);G=G.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield re(Z.join(i,"api.ts"),G,c);break;default:throw new Error(`Unknown client type: ${d}`)}}),re=(l,c,m)=>f(null,null,function*(){var d,r,C,i;if(!(((d=m==null?void 0:m.customCode)==null?void 0:d.enabled)!==false)){yield ue.promises.writeFile(l,c);return}let s=null;try{s=yield ue.promises.readFile(l,"utf-8");}catch(y){}let n$1=n(c,s,{position:((r=m==null?void 0:m.customCode)==null?void 0:r.position)||"bottom",markerText:(C=m==null?void 0:m.customCode)==null?void 0:C.markerText,includeInstructions:(i=m==null?void 0:m.customCode)==null?void 0:i.includeInstructions});yield ue.promises.writeFile(l,n$1);}),Kt=(l,c,m,e,s,n,d=false)=>f(null,null,function*(){let r="",C="",i=d?"./types":"../types",y=d?"./endpoints":"../endpoints";switch(s){case "fetch":r=Ve(l,m,d),r=r.replace("} from '../types';",`} from '${i}';`).replace("} from '../endpoints';",`} from '${y}';`),yield re(Z.join(e,"client.ts"),r,c);break;case "axios":r=Ee(l,m,d),r=r.replace("} from '../types';",`} from '${i}';`).replace("} from '../endpoints';",`} from '${y}';`),yield re(Z.join(e,"client.ts"),r,c);break;case "react-query":if(r=Ee(l,m,d),r=r.replace("} from '../types';",`} from '${i}';`).replace("} from '../endpoints';",`} from '${y}';`),yield re(Z.join(e,"client.ts"),r,c),C=Ye(l,m),C=C.replace("} from '../types';",`} from '${i}';`).replace("} from '../endpoints';",`} from '${y}';`),d){let F=n.replace(/-/g,"_");C=C.replace("import apiClient from './client';",`import { ${F}Client as apiClient } from '../clients';`);}yield re(Z.join(e,"hooks.ts"),C,c);break;case "swr":if(r=Ee(l,m,d),r=r.replace("} from '../types';",`} from '${i}';`).replace("} from '../endpoints';",`} from '${y}';`),yield re(Z.join(e,"client.ts"),r,c),C=Ze(l,m),C=C.replace("} from '../types';",`} from '${i}';`).replace("} from '../endpoints';",`} from '${y}';`),d){let F=n.replace(/-/g,"_");C=C.replace("import apiClient from './client';",`import { ${F}Client as apiClient } from '../clients';`);}yield re(Z.join(e,"hooks.ts"),C,c);break;case "rtk-query":let A=d?b(a({},m),{rtkQuery:b(a({},m.rtkQuery),{apiName:n.replace(/-/g,"_")})}):m;C=Xe(l,A),C=C.replace("} from '../types';",`} from '${i}';`).replace("} from '../endpoints';",`} from '${y}';`),yield re(Z.join(e,"api.ts"),C,c);break;default:throw new Error(`Unknown client type: ${s}`)}}),Ht=(l,c,m,e)=>f(null,null,function*(){var n;if(m==="rtk-query"){let d=`// Generated RTK Query APIs
758
+ `;d+=`// This file was auto-generated.
759
+ `,d+=`// Aggregates all API slices for easy Redux store setup
760
+
761
+ `,c.forEach(r=>{let C=r.replace(/-/g,"_");d+=`import ${C}Api from './${r}/api';
762
+ `;}),d+=`
763
+ // Export all API slices
764
+ `,c.forEach(r=>{let C=r.replace(/-/g,"_");d+=`export { default as ${C}Api } from './${r}/api';
765
+ `;}),d+=`
766
+ /**
767
+ `,d+=` * Configure Redux store with all API slices
768
+ `,d+=` *
769
+ `,d+=` * @example
770
+ `,d+=` * import { configureStore } from '@reduxjs/toolkit';
771
+ `,d+=` * import { setupApiStore } from './apis';
772
+ `,d+=` *
773
+ `,d+=` * export const store = configureStore({
774
+ `,d+=` * reducer: setupApiStore.reducer,
775
+ `,d+=` * middleware: (getDefaultMiddleware) =>
776
+ `,d+=` * getDefaultMiddleware().concat(setupApiStore.middleware),
777
+ `,d+=` * });
778
+ `,d+=` */
779
+ `,d+=`export const setupApiStore = {
780
+ `,d+=` reducer: {
781
+ `,c.forEach(r=>{let C=r.replace(/-/g,"_");d+=` [${C}Api.reducerPath]: ${C}Api.reducer,
782
+ `;}),d+=` },
783
+ `,d+=` middleware: [
784
+ `,c.forEach(r=>{let C=r.replace(/-/g,"_");d+=` ${C}Api.middleware,
785
+ `;}),d+=` ],
786
+ `,d+=`};
787
+ `,yield re(Z.join(l,"apis.ts"),d,e);return}let s=`// Generated API Clients
788
+ `;if(s+=`// This file was auto-generated.
789
+ `,s+=`// Centralized client instances and configuration
790
+
791
+ `,m==="fetch"?c.forEach(d=>{let r=d.replace(/-/g,"_");s+=`export { default as ${r}Client } from './${d}/client';
792
+ `;}):(c.forEach(d=>{let r=d.replace(/-/g,"_"),C=`${r.charAt(0).toUpperCase()+r.slice(1)}ApiClient`;s+=`import ${C} from './${d}/client';
793
+ `;}),s+=`
794
+ // Create client instances
795
+ `,c.forEach(d=>{let r=d.replace(/-/g,"_"),C=`${r.charAt(0).toUpperCase()+r.slice(1)}ApiClient`;s+=`export const ${r}Client = new ${C}();
796
+ `;})),m==="fetch"&&(s+=`
797
+ // Import clients for aggregation
798
+ `,c.forEach(d=>{let r=d.replace(/-/g,"_");s+=`import ${r}_client from './${d}/client';
799
+ `;})),s+=`
800
+ // Aggregate all client instances
801
+ `,s+=`export const clients = {
802
+ `,c.forEach(d=>{let r=d.replace(/-/g,"_");m==="fetch"?s+=` ${r}: ${r}_client,
803
+ `:s+=` ${r}: ${r}Client,
804
+ `;}),s+=`};
805
+
806
+ `,m==="axios"?(s+=`
807
+ /**
808
+ `,s+=` * Configure all API clients at once
809
+ `,s+=` * @param config - Configuration to apply to all clients
810
+ `,s+=` */
811
+ `,s+=`export const configureAllClients = (config: {
812
+ `,s+=` baseURL?: string;
813
+ `,s+=` headers?: Record<string, string>;
814
+ `,s+=` timeout?: number;
815
+ `,s+=`}) => {
816
+ `,c.forEach(d=>{let r=d.replace(/-/g,"_");s+=` ${r}Client.updateConfig(config);
817
+ `;}),s+=`};
818
+
819
+ `):m==="fetch"&&(s+=`
820
+ /**
821
+ `,s+=` * Configure all API clients at once
822
+ `,s+=` * @param config - Configuration to apply to all clients
823
+ `,s+=` */
824
+ `,s+=`export const configureAllClients = (config: {
825
+ `,s+=` baseURL?: string;
826
+ `,s+=` headers?: Record<string, string>;
827
+ `,s+=` auth?: { token?: string };
828
+ `,s+=`}) => {
829
+ `,c.forEach(d=>{let r=d.replace(/-/g,"_");s+=` ${r}_client.setApiConfig(config);
830
+ `;}),s+=`};
831
+
832
+ `),s+=`// Example usage:
833
+ `,s+=`// import { configureAllClients, clients } from './clients';
834
+ `,s+=`//
835
+ `,s+=`// // Configure all clients at once
836
+ `,s+=`// configureAllClients({
837
+ `,s+=`// baseURL: 'https://api.example.com',
838
+ `,s+=`// timeout: 10000,
839
+ `,s+=`// });
840
+ `,s+=`//
841
+ `,s+=`// // Use specific client
842
+ `,s+=`// const data = await clients.${(n=c[0])==null?void 0:n.replace(/-/g,"_")}.someMethod(...);
843
+ `,yield re(Z.join(l,"clients.ts"),s,e),m==="react-query"||m==="swr"){let d=`// Generated Hooks Aggregator
844
+ `;d+=`// This file was auto-generated.
845
+ `,d+=`// Aggregates all folder-split hooks
846
+
847
+ `,c.forEach(r=>{d+=`export * from './${r}/hooks';
848
+ `;}),d+=`
849
+ // Example usage:
850
+ `,d+=`// import { useGetSomething } from './hooks';
851
+ `,yield re(Z.join(l,"hooks.ts"),d,e);}});});var ce,Pe,Me,Pt,St,vt,qt,Rt,Se,en=d(()=>{ce=class extends Error{toJSON(){return {code:this.code,message:this.message}}},Pe=class extends ce{constructor(m){super(`No openapi-sync config file found. Searched: ${m.join(", ")}. Run \`npx openapi-sync init --no-interactive\` to create one.`);this.code="CONFIG_NOT_FOUND";this.name="ConfigNotFoundError";}toJSON(){return b(a({},super.toJSON()),{searchedPaths:this.message})}},Me=class extends ce{constructor(m,e){let s=e instanceof Error?e.message:String(e);super(`Failed to parse config file "${m}": ${s}`);this.code="CONFIG_PARSE_FAILED";this.name="ConfigParseError",this.configPath=m;}toJSON(){return b(a({},super.toJSON()),{configPath:this.configPath})}},Pt=class extends ce{constructor(m,e){super(`Invalid configuration at "${m}": ${e}`);this.code="CONFIG_INVALID";this.name="ConfigValidationError",this.field=m;}toJSON(){return b(a({},super.toJSON()),{field:this.field})}},St=class extends ce{constructor(m,e,s){let n=e instanceof Error?e.message:String(e);super(`Failed to fetch OpenAPI spec from "${m}": ${n}`+(s?` (HTTP ${s})`:""));this.code="SPEC_FETCH_FAILED";this.name="SpecFetchError",this.url=m,this.statusCode=s;}toJSON(){return a(b(a({},super.toJSON()),{url:this.url}),this.statusCode!==void 0&&{statusCode:this.statusCode})}},vt=class extends ce{constructor(m,e){let s=e instanceof Error?e.message:String(e);super(`Failed to read local OpenAPI spec from "${m}": ${s}`);this.code="SPEC_READ_FAILED";this.name="SpecReadError",this.filePath=m;}toJSON(){return b(a({},super.toJSON()),{filePath:this.filePath})}},qt=class extends ce{constructor(m,e){let s=e instanceof Error?e.message:String(e);super(`Failed to parse OpenAPI spec for API "${m}": ${s}`);this.code="SPEC_PARSE_FAILED";this.name="SpecParseError",this.api=m;}toJSON(){return b(a({},super.toJSON()),{api:this.api})}},Rt=class extends ce{constructor(m,e,s){let n=s instanceof Error?s.message:String(s);super(`Failed to write generated file "${m}" for API "${e}": ${n}`);this.code="GENERATION_FAILED";this.name="GenerationError",this.file=m,this.api=e;}toJSON(){return b(a({},super.toJSON()),{file:this.file,api:this.api})}},Se=class extends ce{constructor(m,e){super(`API "${m}" not found in config. Available APIs: ${e.join(", ")}`);this.code="UNKNOWN_API";this.name="UnknownApiError",this.requestedApi=m,this.availableApis=e;}toJSON(){return b(a({},super.toJSON()),{requestedApi:this.requestedApi,availableApis:this.availableApis})}};});var jt=d(()=>{});var Ge,nn,tn,Ur,Lr,Fr,Mr,Qr,Yt=d(()=>{Et();We();Ke();Tt();en();jt();o();c$1();en();Ge=process.cwd(),nn=()=>{let l=Z.join(Ge,"openapi.sync.js"),c$1=Z.join(Ge,"openapi.sync.ts"),m=Z.join(Ge,"openapi.sync.json"),e=[l,c$1,m];try{c("esbuild-register");}catch(r){throw r}let s,n;for(let r of e)if(ue.existsSync(r)){n=r;try{s=c(r),Object.keys(s).length===1&&s.default&&(s=s.default);}catch(C){throw new Me(r,C)}break}if(!n)throw new Pe(e);typeof s=="function"&&(s=s());let d=s;if(!d)throw new Pe(e);return d},tn=l=>({log:(...c)=>{l||[...c];},info:(...c)=>{l||console.info(...c);},warn:(...c)=>{l||[...c];},error:(...c)=>{l||console.error(...c);}}),Ur=l=>f(null,null,function*(){var s;let c=(s=l==null?void 0:l.silent)!=null?s:false,m=tn(c),e={success:false,apis:[],filesWritten:[],endpointCount:0,warnings:[],errors:[]};try{let n=nn(),d=Object.keys(n.api);e.apis=d;let r=l&&"refetchInterval"in l&&!isNaN(l==null?void 0:l.refetchInterval)?l.refetchInterval:n.refetchInterval;Ne();for(let C=0;C<d.length;C+=1){let i=d[C],y=n.api[i];m.log(`
852
+ \u{1F504} Syncing ${i}...`);try{yield Fe(y,i,n,r);let A=Ue(i);e.endpointCount+=A.length,m.log(`\u2705 ${i}: ${A.length} endpoints`);}catch(A){let F=A instanceof Error?A.message:String(A);e.errors.push(`[${i}] ${F}`),m.error(`\u274C ${i}: ${F}`);}}return e.success=e.errors.length===0,e}catch(n){let d=n instanceof Error?n.message:String(n);return e.errors.push(d),m.error(`\u274C Fatal error: ${d}`),e}}),Lr=l=>f(null,null,function*(){var s;let c=(s=l.silent)!=null?s:false,m=tn(c),e={success:false,apis:[],filesWritten:[],endpointCount:0,warnings:[],errors:[]};try{m.log(`
853
+ \u{1F504} Loading configuration...`);let n=nn(),d=l.apiName?[l.apiName]:Object.keys(n.api);e.apis=d;for(let C of d)if(!n.api[C])throw new Se(C,Object.keys(n.api));m.log("\u{1F504} Syncing OpenAPI specifications..."),Ne();for(let C of d){let i=n.api[C];yield Fe(i,C,n);}let r=(n==null?void 0:n.folder)||"api";for(let C of d){let i=Ue(C);if(i.length===0){let A=`No endpoints found for API: ${C}`;e.warnings.push(A),m.warn(`\u26A0\uFE0F ${A}`);continue}e.endpointCount+=i.length,m.log(`
854
+ \u{1F4CB} Found ${i.length} endpoint(s) for ${C}`);let y=a(a(a(a(b(a({enabled:!0},n.clientGeneration||{}),{type:l.type}),l.outputDir&&{outputDir:l.outputDir}),l.baseURL&&{baseURL:l.baseURL}),l.tags&&{tags:l.tags}),l.endpoints&&{endpoints:l.endpoints});yield Ot(i,n,y,C,Z.join(Ge,r));}return m.log(`
855
+ \u2728 All clients generated successfully!
856
+ `),e.success=e.errors.length===0,e}catch(n){let d=n instanceof Error?n.message:String(n);return e.errors.push(d),m.error(`\u274C Error: ${d}`),e}}),Fr=l=>f(null,null,function*(){let{validateConfig:c}=yield import('./validate-3G3NZCPG.mjs');return c(l)}),Mr=l=>f(null,null,function*(){var e;let c=(e=l==null?void 0:l.silent)!=null?e:false,m=tn(c);try{let s=nn(),n=l!=null&&l.apiName?[l.apiName]:Object.keys(s.api);if(l!=null&&l.apiName&&!s.api[l.apiName])throw new Se(l.apiName,Object.keys(s.api));Ne();for(let r of n){let C=s.api[r];m.log(`\u{1F50D} Fetching spec for ${r}...`),yield Fe(C,r,s);}let d={};for(let r of n){let C=Ue(r);l!=null&&l.tags&&l.tags.length>0&&(C=C.filter(i=>{var y;return (y=i.tags)==null?void 0:y.some(A=>l.tags.includes(A))})),d[r]=C.map(i=>({name:i.name,method:i.method.toUpperCase(),path:i.path,operationId:i.operationId,tags:i.tags,summary:i.summary})),m.log(`\u2705 ${r}: ${d[r].length} endpoint(s)`);}return d}catch(s){let n=s instanceof Error?s.message:String(s);throw m.error(`\u274C Error: ${n}`),s}}),Qr=()=>f(null,null,function*(){let{interactiveInit:l}=yield import('./interactive-init-XBZJKJCH.mjs');yield l();});});export{ce as a,Pe as b,Me as c,Pt as d,St as e,vt as f,qt as g,Rt as h,Se as i,Ur as j,Lr as k,Fr as l,Mr as m,Qr as n,Yt as o};