openapi-sync 5.0.1 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/index.js +494 -494
- package/dist/index.mjs +256 -256
- package/package.json +1 -1
- /package/dist/{interactive-init-B7AFNUFL.mjs → interactive-init-APL2JSEW.mjs} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import {c,d,a,b}from'./chunk-PUWCZVB7.mjs';import
|
|
2
|
-
`+" ".repeat(
|
|
3
|
-
`).filter(r=>r.trim()!=="").join(`
|
|
4
|
-
${" ".repeat(i)}`);s<e.length-1&&(n+=", ");}return n+=`
|
|
5
|
-
${" ".repeat(i-1)}}`,n},ve=(u,i=1)=>`
|
|
6
|
-
\`\`\`typescript
|
|
7
|
-
${" ".repeat(i)} ${u.split(`
|
|
1
|
+
import {c,d,a,b}from'./chunk-PUWCZVB7.mjs';import ie from'fs';import J from'path';import*as Te from'js-yaml';import yn from'lodash.isequal';import Ge from'lodash.get';import gn from'axios';import hn from'axios-retry';import $n from'@apidevtools/swagger-parser';import {CurlGenerator}from'curl-generator';var wn=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Wt=/[A-Za-z0-9_$]/;var Kt=l=>["object"].includes(typeof l)&&!(l instanceof Blob),cn=l=>{try{return Te.load(l),!0}catch(o){let p=o;if(p instanceof Te.YAMLException)return false;throw p}},_t=l=>{if(cn(l)){let o=Te.load(l),p=JSON.stringify(o,null,2);return JSON.parse(p)}},ue=l=>l.substring(0,1).toUpperCase()+l.substring(1),Vt=(l,o)=>{let p=l.split("/"),e=`${ue(o)}`,s=[];return p.forEach(t=>{if(t[0]==="{"&&t[t.length-1]==="}"){let n=t.replace(/{/,"").replace(/}/,"");s.push(n),t=`$${n}`;}else if(t[0]==="<"&&t[t.length-1]===">"){let n=t.replace(/</,"").replace(/>/,"");s.push(n),t=`$${n}`;}else if(t[0]===":"){let n=t.replace(/:/,"");s.push(n),t=`$${n}`;}let i="";t.split("").forEach(n=>{let g=n;Wt.test(n)||(g="/"),i+=g;}),i.split("/").forEach(n=>{e+=ue(n);});}),{name:e,variables:s,pathParts:p}},Ee=(l,o=1)=>{let p="{",e=Object.keys(l);for(let s=0;s<e.length;s++){let t=e[s],i=l[t];if(p+=`
|
|
2
|
+
`+" ".repeat(o)+t+": ",Array.isArray(i)){p+="[";for(let n=0;n<i.length;n++){let g=i[n];typeof g=="object"&&g!==null?p+=Ee(g,o+1):p+=typeof g=="string"?`"${g}"`:g,n<i.length-1&&(p+=", ");}p+="]";}else typeof i=="object"&&i!==null?p+=""+Ee(i,o+1):p+=i.split(`
|
|
8
3
|
`).filter(n=>n.trim()!=="").join(`
|
|
9
|
-
${"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
${" ".repeat(o)}`);s<e.length-1&&(p+=", ");}return p+=`
|
|
5
|
+
${" ".repeat(o-1)}}`,p},ve=(l,o=1)=>`
|
|
6
|
+
\`\`\`typescript
|
|
7
|
+
${" ".repeat(o)} ${l.split(`
|
|
8
|
+
`).filter(p=>p.trim()!=="").join(`
|
|
9
|
+
${" ".repeat(o)} `)}
|
|
10
|
+
\`\`\``;function vn(l,o){return o.split(".").reduce((e,s)=>e&&e[s]!==void 0?e[s]:void 0,l)}var dn=(l,o="CUSTOM CODE")=>{let p=`// \u{1F512} ${o} START`,e=`// \u{1F512} ${o} END`,s={beforeGenerated:"",afterGenerated:""},t=0,i=[];for(;t<l.length;){let n=l.indexOf(p,t);if(n===-1)break;let g=l.indexOf(e,n);if(g===-1)break;let m=g+e.length,f=l.substring(m,m+100),j=f.match(/^\s*\n\s*(\/\/ =+)/);if(j){let k=f.indexOf(`
|
|
11
|
+
`,j.index+1);k!==-1?m+=k+1:m+=j[0].length;}let O=n,w=l.substring(Math.max(0,n-200),n).lastIndexOf("// ==========");w!==-1&&(O=Math.max(0,n-200)+w);let A=l.substring(O,m);i.push({start:O,end:m,content:A}),t=m;}return i.length>0&&(l.substring(0,i[0].start).split(`
|
|
12
|
+
`).filter(m=>{let f=m.trim();return f.length>0&&!f.startsWith("//")}).join("").length===0?(s.beforeGenerated=i[0].content,i.length>1&&(s.afterGenerated=i[1].content)):(s.afterGenerated=i[0].content,i.length>1&&!s.beforeGenerated&&(s.beforeGenerated=i[1].content))),s},Ht=(l,o="CUSTOM CODE",p=true)=>{let e=p?`// ${l==="top"?"Add your custom code below this line":"Add your custom code above this line"}
|
|
13
13
|
// This section will be preserved during regeneration
|
|
14
14
|
`:"";return `// ${"=".repeat(60)}
|
|
15
|
-
// \u{1F512} ${
|
|
15
|
+
// \u{1F512} ${o} START
|
|
16
16
|
${e}// ${"=".repeat(60)}
|
|
17
17
|
|
|
18
|
-
// \u{1F512} ${
|
|
19
|
-
// ${"=".repeat(60)}`},qe=(
|
|
20
|
-
`)};var
|
|
18
|
+
// \u{1F512} ${o} END
|
|
19
|
+
// ${"=".repeat(60)}`},qe=(l,o,p={})=>{let{position:e="bottom",markerText:s="CUSTOM CODE",includeInstructions:t=true}=p,i={beforeGenerated:"",afterGenerated:""};o&&(i=dn(o,s)),!i.beforeGenerated&&!i.afterGenerated&&((e==="top"||e==="both")&&(i.beforeGenerated=Ht("top",s,t)),(e==="bottom"||e==="both")&&(i.afterGenerated=Ht("bottom",s,t)));let n=[];return i.beforeGenerated&&(n.push(i.beforeGenerated),n.push("")),n.push(l),i.afterGenerated&&(n.push(""),n.push(i.afterGenerated)),n.join(`
|
|
20
|
+
`)};var Oe=J.join(__dirname,"../","../db.json");ie.existsSync(Oe)||ie.writeFileSync(Oe,"{}");var Ue={};try{Ue=c(Oe);}catch(l){Ue={};}var we=Ue||{},Yt=l=>{ie.writeFileSync(Oe,JSON.stringify(l));},Zt=(l,o)=>{we[l]=o,Yt(we);},Xt=l=>we[l],Me=()=>{we={},Yt(we);};var en={},tn=(l,o)=>{en[l]=o;},nn=l=>en[l]||[];var ce=process.cwd(),Ne={},rn=gn.create({timeout:6e4});hn(rn,{retries:20,retryCondition:l=>l.code==="ECONNABORTED"||l.message.includes("Network Error"),retryDelay:l=>l*1e3});var ge=(l,o,p)=>d(null,null,function*(){var i,n,g,m;if(!(((i=p==null?void 0:p.customCode)==null?void 0:i.enabled)!==false)){yield ie.promises.writeFile(l,o);return}let s=null;try{s=yield ie.promises.readFile(l,"utf-8");}catch(f){}let t=qe(o,s,{position:((n=p==null?void 0:p.customCode)==null?void 0:n.position)||"bottom",markerText:(g=p==null?void 0:p.customCode)==null?void 0:g.markerText,includeInstructions:(m=p==null?void 0:p.customCode)==null?void 0:m.includeInstructions});yield ie.promises.writeFile(l,t);}),sn=(l,o,p,e)=>d(null,null,function*(){let s=yield bn(l,o,p,e);return e&&!isNaN(e)&&e>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(Ne[o]&&clearTimeout(Ne[o]),Ne[o]=setTimeout(()=>{console.info(`\u{1F504} Auto syncing ${o}`),sn(l,o,p,e);},e))),s}),bn=(...l)=>d(null,null,function*(){var le,be,$e,Pe,De,Je,We,He,Ke,_e;let[o,p,e]=l,s=r=>r.startsWith("http://")||r.startsWith("https://"),t;try{if(s(o))t=(yield rn.get(o)).data;else {let r=J.isAbsolute(o)?o:J.join(ce,o);`${r}`,t=yield ie.promises.readFile(r,"utf-8");}}catch(r){console.error(`Failed to load OpenAPI spec for ${p}:`,r);return}if(!t)return;let i=Kt(t)?t:_t(t),n;try{n=yield $n.parse(i);}catch(r){let u=r instanceof Error?r.message:String(r);throw new Error(`Failed to parse OpenAPI spec for ${p}: ${u}`)}let g=J.join((e==null?void 0:e.folder)||"",p),m={},f=r=>{var u,E;if((u=e==null?void 0:e.folderSplit)!=null&&u.customFolder){let $=e.folderSplit.customFolder(r);if($)return $}return (E=e==null?void 0:e.folderSplit)!=null&&E.byTags&&r.tags&&r.tags.length>0?r.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},j=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((be=(le=n==null?void 0:n.servers)==null?void 0:le[(e==null?void 0:e.server)||0])==null?void 0:be.url)||"",O=typeof((Pe=($e=e==null?void 0:e.types)==null?void 0:$e.name)==null?void 0:Pe.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",q=typeof((Je=(De=e==null?void 0:e.endpoints)==null?void 0:De.name)==null?void 0:Je.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",w=(r,u)=>{var $,d;let E=ue(r);if((d=($=e==null?void 0:e.types)==null?void 0:$.name)!=null&&d.format){let y=e==null?void 0:e.types.name.format("shared",{name:r},E);if(y)return `${O}${y}`}return `${O}${E}`},A=(r,u,E,$,d,y=0)=>{let c="",C="",h="";if(u)if(u.$ref)if(u.$ref[0]==="#"){let v=(u.$ref||"").split("/");v.shift();v[0]==="definitions";[...v].pop();let D=Ge(r,v,null);if(D){D!=null&&D.name&&(c=D.name),C=v[v.length-1];let re=w(C);re.includes(".")&&(re=re.split(".").map((de,fe)=>fe===0?de:`["${de}"]`).join("")),h+=`${d!=null&&d.noSharedImport?"":"Shared."}${re}`;}}else h+="";else if(u.anyOf)h+=`(${u.anyOf.map(v=>A(r,v,"",$,b(a({},d),{useComponentName:false}))).filter(v=>!!v).join("|")})`;else if(u.oneOf)h+=`(${u.oneOf.map(v=>A(r,v,"",$,b(a({},d),{useComponentName:false}))).filter(v=>!!v).join("|")})`;else if(u.allOf)h+=`(${u.allOf.map(v=>A(r,v,"",$,b(a({},d),{useComponentName:false}))).filter(v=>!!v).join("&")})`;else if(u.items)h+=`${A(r,u.items,"",false,b(a({},d),{useComponentName:false}))}[]`;else if(u.properties){let v=Object.keys(u.properties),N=u.required||[],F="";v.forEach(z=>{var re,Ce,de,fe,Ie,ye;let D="";!((Ce=(re=e==null?void 0:e.types)==null?void 0:re.doc)!=null&&Ce.disable)&&((fe=(de=u.properties)==null?void 0:de[z])!=null&&fe.description)&&(D=" * "+((Ie=u.properties)==null?void 0:Ie[z].description.split(`
|
|
21
21
|
`).filter(Re=>Re.trim()!=="").join(`
|
|
22
|
-
*${" ".repeat(1)}`))),
|
|
23
|
-
${
|
|
22
|
+
*${" ".repeat(1)}`))),F+=(D?`/**
|
|
23
|
+
${D}
|
|
24
24
|
*/
|
|
25
|
-
`:"")+`${
|
|
26
|
-
${" ".repeat(
|
|
27
|
-
`:""}`:""},
|
|
28
|
-
`);C.length>0?
|
|
25
|
+
`:"")+`${A(r,(ye=u.properties)==null?void 0:ye[z],z,N.includes(z),d,y+1)}`;}),F.length>0?h+=`{
|
|
26
|
+
${" ".repeat(y)}${F}${" ".repeat(y)}}`:h+="{[k: string]: any}";}else if(u.enum&&u.enum.length>0){let v=u.enum.includes(null),N=u.enum.filter(z=>z!==null).map(z=>JSON.stringify(z)).filter(z=>z!==void 0),F=N.length>1||N.length>0&&v;F&&(h+="("),N.forEach((z,D)=>{h+=`${D===0?"":"|"}${z}`;}),v&&(h+=`${N.length>0?"|":""}null`),F&&(h+=")");}else if(u.type){let v=N=>{let F="";if(typeof N=="string")["string","integer","number","array","boolean","null"].includes(N)?["integer","number"].includes(N)?F+="number":N==="array"?F+="any[]":F+=N:N==="object"&&(u.additionalProperties?F+=`{[k: string]: ${A(r,u.additionalProperties,"",true,b(a({},d),{useComponentName:false}))||"any"}}`:F+="{[k: string]: any}");else if(Array.isArray(N)){let z=N.map(D=>v(D));z.filter(D=>D!==""),z.length>1&&(F+="("+z.join("|")+")");}else F+="any";return F};h=v(u.type);}else h+="any";else h="string";let P=c||E;d!=null&&d.useComponentName&&!P&&(P=C);let W=P?` "${P}"${$?"":"?"}: `:"",a$1=(u==null?void 0:u.enum)&&u.enum.includes(null),Z=u!=null&&u.nullable&&!a$1?" | null":"";return h.length>0?`${W}${h}${Z}${P?`;
|
|
27
|
+
`:""}`:""},k=(r,u)=>{let d="";if(u)if(u.$ref)if(u.$ref[0]==="#"){let y=(u.$ref||"").split("/");y.shift();let C=Ge(r,y,null);C&&(C!=null&&C.name&&(C.name),y[y.length-1],d+=k(r,C));}else d+="";else if(u.anyOf)d+=k(r,u.anyOf[0]);else if(u.oneOf)d+=k(r,u.oneOf[0]);else if(u.allOf)d+=`{${u.allOf.map(y=>`...(${k(r,y)})`).join(",")}}`;else if(u.items)d+=`[${k(r,u.items)}]`;else if(u.properties){let C=Object.keys(u.properties).map(h=>{var P;return ` "${h}": ${k(r,(P=u.properties)==null?void 0:P[h])}`}).join(`,
|
|
28
|
+
`);C.length>0?d+=`{
|
|
29
29
|
${C}
|
|
30
|
-
}`:
|
|
31
|
-
`).filter(
|
|
32
|
-
*${" ".repeat(1)}`)),
|
|
33
|
-
${$}
|
|
34
|
-
*/
|
|
35
|
-
`:"")+"export type "+d+" = "+(typeof C=="string"?C:Ee(C))+`;
|
|
36
|
-
`;});}});let _=a=>{let p="";if(a.content){let w=Object.keys(a.content);w[0]&&a.content[w[0]].schema&&(p+=`${x(o,a.content[w[0]].schema,"")}`);}return p},O=(a,p,w=0)=>{if(!a)return p==="joi"?"Joi.any()":p==="yup"?"yup.mixed()":"z.any()";if(a.$ref){if(a.$ref[0]==="#"){let g=a.$ref.split("/");g.shift();let c=g.join("."),h=Ge(o,c);if(h)return O(h,p,w)}return p==="joi"?"Joi.any()":p==="yup"?"yup.mixed()":"z.any()"}if(a.anyOf||a.oneOf){let g=a.anyOf||a.oneOf;if(g.every(h=>h.enum!==void 0&&Array.isArray(h.enum))){let h=[],d=false;if(g.forEach(C=>{C.enum&&C.enum.forEach($=>{$===null?d=true:h.includes($)||h.push($);});}),h.length>0){let C=h.map($=>JSON.stringify($)).join(", ");if(p==="zod"){let $=`z.enum([${C}])`;return d&&($+=".nullable()"),$}else if(p==="yup"){let $=`yup.mixed().oneOf([${C}])`;return d&&($+=".nullable()"),$}else return d?`Joi.valid(${C}, null)`:`Joi.valid(${C})`}else if(d)return p==="zod"?"z.null()":p==="yup"?"yup.mixed().nullable()":"Joi.valid(null)"}return p==="zod"?`z.union([${g.map(C=>O(C,p,w+1)).join(", ")}])`:p==="yup"?`yup.mixed().oneOf([${g.map(C=>O(C,p,w+1)).join(", ")}])`:`Joi.alternatives().try(${g.map(d=>O(d,p,w+1)).join(", ")})`}if(a.allOf)if(p==="zod"){let g=a.allOf.map(h=>O(h,p,w+1)),c=g[0];for(let h=1;h<g.length;h++)c=`${c}.merge(${g[h]})`;return c}else return O(a.allOf[0],p,w+1);if(a.items){let g=O(a.items,p,w+1);if(p==="zod"){let c=`z.array(${g})`;return a.minItems!==void 0&&(c+=`.min(${a.minItems})`),a.maxItems!==void 0&&(c+=`.max(${a.maxItems})`),c}else if(p==="yup"){let c=`yup.array().of(${g})`;return a.minItems!==void 0&&(c+=`.min(${a.minItems})`),a.maxItems!==void 0&&(c+=`.max(${a.maxItems})`),c}else {let c=`Joi.array().items(${g})`;return a.minItems!==void 0&&(c+=`.min(${a.minItems})`),a.maxItems!==void 0&&(c+=`.max(${a.maxItems})`),c}}if(a.properties){let g=a.required||[],c=" ".repeat(w+1),h=Object.entries(a.properties).map(([d,C])=>{let $=g.includes(d),P=O(C,p,w+1);return $||(P+=".optional()"),`${c}${d}: ${P}`}).join(`,
|
|
37
|
-
`);return p==="zod"?`z.object({
|
|
38
|
-
${h}
|
|
39
|
-
${" ".repeat(w)}})`:p==="yup"?`yup.object({
|
|
30
|
+
}`:d+="{}";}else if(u.enum&&u.enum.length>0)u.enum.length>1&&(d+=u.enum[0]);else if(u.type)if(u.example)d+=JSON.stringify(u.example);else {let y=c=>{let C="";if(typeof c=="string")["string","integer","number","array","boolean","null"].includes(c)?["integer","number"].includes(c)?C+="123":c==="array"?C+="[]":c==="boolean"?C+="true":c==="null"?C+="null":C+=`"${c}"`:c==="object"&&(C+="{}");else if(Array.isArray(c)){let h=c.map(P=>y(P));h.filter(P=>P!==""),h.length>1&&(C+=h.join("|"));}else C+="any";return C};d=y(u.type);}else d+="any";else d="string";return d},S=Xt(p);if(yn(S,n))return;Zt(p,n);let H="",T="",b$1={},Y=[],G=(r,u)=>{let E={},$={};Object.keys(r).forEach(y=>{var h;let c=(h=r[y])!=null&&h.schema?r[y].schema:r[y],C=`${A(n,c,"",true,{noSharedImport:true,useComponentName:false})}`;if(C){let P=y.split("."),W=E,a=$;for(let Z=0;Z<P.length;Z++){let v=P[Z];Z<P.length-1?(v in W||(W[v]={},a[v]={}),W=W[v],a=a[v]):(W[v]=C,a[v]=c);}}}),Object.keys(E).forEach(y=>{var P,W,a,Z;let c=w(y),C=E[y],h="";!((W=(P=e==null?void 0:e.types)==null?void 0:P.doc)!=null&&W.disable)&&y in r&&((a=r[y])!=null&&a.description)&&(h=" * "+r[y].description.split(`
|
|
31
|
+
`).filter(v=>v.trim()!=="").join(`
|
|
32
|
+
*${" ".repeat(1)}`)),b$1[y]=((Z=b$1[y])!=null?Z:"")+(h?`/**
|
|
40
33
|
${h}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
*/
|
|
35
|
+
`:"")+"export type "+c+" = "+(typeof C=="string"?C:Ee(C))+`;
|
|
36
|
+
`;});};n.definitions&&G(n.definitions),n.components&&Object.keys(n.components).forEach(r=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(r)){let u=n.components[r];G(u);}});let Q=r=>{let u="";if(r.content){let E=Object.keys(r.content);E[0]&&r.content[E[0]].schema&&(u+=`${A(n,r.content[E[0]].schema,"")}`);}return u},K=(r,u,E=0)=>{if(!r)return u==="joi"?"Joi.any()":u==="yup"?"yup.mixed()":"z.any()";if(r.$ref){if(r.$ref[0]==="#"){let $=r.$ref.split("/");$.shift();let d=$.join("."),y=Ge(n,d);if(y)return K(y,u,E)}return u==="joi"?"Joi.any()":u==="yup"?"yup.mixed()":"z.any()"}if(r.anyOf||r.oneOf){let $=r.anyOf||r.oneOf;if($.every(y=>y.enum!==void 0&&Array.isArray(y.enum))){let y=[],c=false;if($.forEach(C=>{C.enum&&C.enum.forEach(h=>{h===null?c=true:y.includes(h)||y.push(h);});}),y.length>0){let C=y.map(h=>JSON.stringify(h)).join(", ");if(u==="zod"){let h=`z.enum([${C}])`;return c&&(h+=".nullable()"),h}else if(u==="yup"){let h=`yup.mixed().oneOf([${C}])`;return c&&(h+=".nullable()"),h}else return c?`Joi.valid(${C}, null)`:`Joi.valid(${C})`}else if(c)return u==="zod"?"z.null()":u==="yup"?"yup.mixed().nullable()":"Joi.valid(null)"}return u==="zod"?`z.union([${$.map(C=>K(C,u,E+1)).join(", ")}])`:u==="yup"?`yup.mixed().oneOf([${$.map(C=>K(C,u,E+1)).join(", ")}])`:`Joi.alternatives().try(${$.map(c=>K(c,u,E+1)).join(", ")})`}if(r.allOf)if(u==="zod"){let $=r.allOf.map(y=>K(y,u,E+1)),d=$[0];for(let y=1;y<$.length;y++)d=`${d}.merge(${$[y]})`;return d}else return K(r.allOf[0],u,E+1);if(r.items){let $=K(r.items,u,E+1);if(u==="zod"){let d=`z.array(${$})`;return r.minItems!==void 0&&(d+=`.min(${r.minItems})`),r.maxItems!==void 0&&(d+=`.max(${r.maxItems})`),d}else if(u==="yup"){let d=`yup.array().of(${$})`;return r.minItems!==void 0&&(d+=`.min(${r.minItems})`),r.maxItems!==void 0&&(d+=`.max(${r.maxItems})`),d}else {let d=`Joi.array().items(${$})`;return r.minItems!==void 0&&(d+=`.min(${r.minItems})`),r.maxItems!==void 0&&(d+=`.max(${r.maxItems})`),d}}if(r.properties){let $=r.required||[],d=" ".repeat(E+1),y=Object.entries(r.properties).map(([c,C])=>{let h=$.includes(c),P=K(C,u,E+1);return h||(P+=".optional()"),`${d}${c}: ${P}`}).join(`,
|
|
37
|
+
`);return u==="zod"?`z.object({
|
|
38
|
+
${y}
|
|
39
|
+
${" ".repeat(E)}})`:u==="yup"?`yup.object({
|
|
40
|
+
${y}
|
|
41
|
+
${" ".repeat(E)}})`:`Joi.object({
|
|
42
|
+
${y}
|
|
43
|
+
${" ".repeat(E)}})`}if(r.enum&&r.enum.length>0){let $=[],d=false;r.enum.forEach(c=>{c===null?d=true:$.includes(c)||$.push(c);});let y=$.map(c=>JSON.stringify(c)).join(", ");if(u==="zod"){let c=`z.enum([${y}])`;return d&&(c+=".nullable()"),c}else if(u==="yup"){let c=`yup.mixed().oneOf([${y}])`;return d&&(c+=".nullable()"),c}else {let c=`Joi.valid(${y})`;return d&&(c+=".allow(null)"),c}}if(r.type){let d=(y=>{switch(y){case "string":if(u==="zod"){let c="z.string()";return r.format==="email"?c+=".email()":r.format==="uuid"?c+=".uuid()":r.format==="url"||r.format==="uri"?c+=".url()":r.format==="date-time"?c+=".datetime()":r.format==="date"&&(c+=".date()"),r.minLength&&(c+=`.min(${r.minLength})`),r.maxLength&&(c+=`.max(${r.maxLength})`),r.pattern&&(c+=`.regex(/${r.pattern}/)`),c}else if(u==="yup"){let c="yup.string()";return r.format==="email"?c+=".email()":(r.format==="url"||r.format==="uri")&&(c+=".url()"),r.minLength&&(c+=`.min(${r.minLength})`),r.maxLength&&(c+=`.max(${r.maxLength})`),r.pattern&&(c+=`.matches(/${r.pattern}/)`),c}else {let c="Joi.string()";return r.format==="email"?c+=".email()":r.format==="url"||r.format==="uri"?c+=".uri()":r.format==="uuid"?c+=".guid({ version: 'uuidv4' })":r.format==="date-time"&&(c+=".isoDate()"),r.minLength&&(c+=`.min(${r.minLength})`),r.maxLength&&(c+=`.max(${r.maxLength})`),r.pattern&&(c+=`.pattern(/${r.pattern}/)`),c}case "integer":case "number":if(u==="zod"){let c="z.number()";return y==="integer"&&(c+=".int()"),r.minimum!==void 0&&(r.exclusiveMinimum?c+=`.gt(${r.minimum})`:c+=`.min(${r.minimum})`),r.maximum!==void 0&&(r.exclusiveMaximum?c+=`.lt(${r.maximum})`:c+=`.max(${r.maximum})`),c}else if(u==="yup"){let c="yup.number()";return y==="integer"&&(c+=".integer()"),r.minimum!==void 0&&(c+=`.min(${r.minimum})`),r.maximum!==void 0&&(c+=`.max(${r.maximum})`),c}else {let c="Joi.number()";return y==="integer"&&(c+=".integer()"),r.minimum!==void 0&&(r.exclusiveMinimum?c+=`.greater(${r.minimum})`:c+=`.min(${r.minimum})`),r.maximum!==void 0&&(r.exclusiveMaximum?c+=`.less(${r.maximum})`:c+=`.max(${r.maximum})`),c}case "boolean":return u==="joi"?"Joi.boolean()":u==="yup"?"yup.boolean()":"z.boolean()";case "null":return u==="joi"?"Joi.any().allow(null)":u==="yup"?"yup.mixed().nullable()":"z.null()";default:return u==="joi"?"Joi.any()":u==="yup"?"yup.mixed()":"z.any()"}})(typeof r.type=="string"?r.type:r.type[0]);return r.nullable&&u!=="joi"?d+=".nullable()":r.nullable&&u==="joi"&&(d+=".allow(null)"),d}return u==="joi"?"Joi.any()":u==="yup"?"yup.mixed()":"z.any()"},pe=r=>{var u,E,$,d,y;if((E=(u=e==null?void 0:e.endpoints)==null?void 0:u.value)!=null&&E.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let c=r;return (y=(d=($=e==null?void 0:e.endpoints)==null?void 0:$.value)==null?void 0:d.replaceWords)==null||y.forEach((C,h)=>{let P=new RegExp(C.replace,"g");c=c.replace(P,C.with||"");}),c}else return r},oe=(r,u,E=[])=>{var y,c;let $=(y=e==null?void 0:e.endpoints)==null?void 0:y.exclude,d=(c=e==null?void 0:e.endpoints)==null?void 0:c.include;if(d){let C=d.tags&&d.tags.length>0?E.some(P=>d.tags.includes(P)):true,h=d.endpoints&&d.endpoints.length>0?d.endpoints.some(P=>{let W=!P.method||P.method.toLowerCase()===u.toLowerCase();return P.path?r===P.path&&W:P.regex?new RegExp(P.regex).test(r)&&W:false}):true;if(!C||!h)return true}return !!($&&($.tags&&$.tags.length>0&&E.some(h=>$.tags.includes(h))||$.endpoints&&$.endpoints.length>0&&$.endpoints.some(h=>{let P=!h.method||h.method.toLowerCase()===u.toLowerCase();return h.path?r===h.path&&P:h.regex?new RegExp(h.regex).test(r)&&P:false})))};if(Object.keys(n.paths||{}).forEach(r=>{let u=n.paths[r];Object.keys(u).forEach($=>{var Ye,Ze,Xe,et,tt,nt,rt,st,ot,at,it,lt,ut,pt,mt,ct,dt,ft,yt,gt,ht,$t,Ct,bt,It,xt,Et,Tt,wt,At,Pt,vt,qt,Ot,jt,kt,Rt,St,Ut,Mt,Gt,Nt,Lt,Ft,Qt,Bt,zt,Dt,Jt;let d=$,y=Vt(r,d),c=((Ye=u[d])==null?void 0:Ye.tags)||[];if(oe(r,d,c))return;let C=u[d],h=f({method:d,path:r,summary:C==null?void 0:C.summary,operationId:C==null?void 0:C.operationId,tags:c,parameters:C==null?void 0:C.parameters,requestBody:C==null?void 0:C.requestBody,responses:C==null?void 0:C.responses});m[h]||(m[h]={endpoints:"",types:"",validation:""});let P=((Xe=(Ze=e==null?void 0:e.endpoints)==null?void 0:Ze.value)!=null&&Xe.includeServer?j:"")+y.pathParts.map(I=>(I[0]==="{"&&I[I.length-1]==="}"?I=`\${${I.replace(/{/,"").replace(/}/,"")}}`:I[0]==="<"&&I[I.length-1]===">"?I=`\${${I.replace(/</,"").replace(/>/,"")}}`:I[0]===":"&&(I=`\${${I.replace(/:/,"")}}`),I)).join("/"),W=`"${P}"`;y.variables.length>0&&(W=`(${y.variables.map(x=>`${x}:string`).join(",")})=> \`${P}\``),W=pe(W);let a=u[d],Z="",v;if(a!=null&&a.parameters&&((a==null?void 0:a.parameters).forEach((x,R)=>{(x.$ref||x.in==="query"&&x.name)&&(Z+=`${A(n,x.$ref?x:x.schema,x.name||"",x.required)}`);}),Z)){Z=`{
|
|
44
|
+
${Z}}`;let x=`${y.name}Query`;if((tt=(et=e==null?void 0:e.types)==null?void 0:et.name)!=null&&tt.useOperationId&&(a!=null&&a.operationId)&&(x=`${a.operationId}Query`),x=ue(`${O}${x}`),(rt=(nt=e==null?void 0:e.types)==null?void 0:nt.name)!=null&&rt.format){let L=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"query",method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},x);L&&(x=`${O}${L}`);}v=x;let R=`export type ${x} = ${Z};
|
|
45
|
+
`;e!=null&&e.folderSplit?m[h].types+=R:T+=R;}if(((st=e==null?void 0:e.validations)==null?void 0:st.disable)!==true&&((at=(ot=e==null?void 0:e.validations)==null?void 0:ot.generate)==null?void 0:at.query)!==false&&(a!=null&&a.parameters)){let I=((it=e.validations)==null?void 0:it.library)||"zod",R=a.parameters.filter(L=>!L.$ref&&L.in==="query"&&L.name);if(R.length>0){let L=((lt=e==null?void 0:e.validations)==null?void 0:lt.name)||((ut=e==null?void 0:e.types)==null?void 0:ut.name),_=typeof(L==null?void 0:L.prefix)=="string"?L.prefix:"I",M=typeof((mt=(pt=e==null?void 0:e.validations)==null?void 0:pt.name)==null?void 0:mt.suffix)=="string"?e.validations.name.suffix:"Schema",B=`${y.name}Query`;if(L!=null&&L.useOperationId&&(a!=null&&a.operationId)&&(B=`${a.operationId}Query`),B=ue(`${_}${B}${M}`),(dt=(ct=e==null?void 0:e.validations)==null?void 0:ct.name)!=null&&dt.format){let ne=e.validations.name.format({code:"",type:"query",method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},B);ne&&(B=`${_}${ne}${M}`);}else if((yt=(ft=e==null?void 0:e.types)==null?void 0:ft.name)!=null&&yt.format){let ne=e.types.name.format("endpoint",{code:"",type:"query",method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},B);ne&&(B=`${_}${ne}${M}`);}let U=R.map(ne=>{let pn=ne!=null&&ne.schema?K(ne.schema,I):I==="joi"?"Joi.string()":I==="yup"?"yup.string()":"z.string()",mn=ne.required?"":".optional()";return ` ${ne.name}: ${pn}${mn}`}).join(`,
|
|
46
|
+
`),me=`export const ${B} = ${I==="joi"?"Joi.object":I==="yup"?"yup.object":"z.object"}({
|
|
47
47
|
${U}
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
`;
|
|
51
|
-
`;
|
|
50
|
+
`;e!=null&&e.folderSplit||m[h]||(m[h]={endpoints:"",types:"",validation:""}),m[h].validation+=me;}}let N=a==null?void 0:a.requestBody,F="",z;if(N&&(F=Q(N),F)){let I=`${y.name}DTO`;if((ht=(gt=e==null?void 0:e.types)==null?void 0:gt.name)!=null&&ht.useOperationId&&(a!=null&&a.operationId)&&(I=`${a.operationId}DTO`),I=ue(`${O}${I}`),(Ct=($t=e==null?void 0:e.types)==null?void 0:$t.name)!=null&&Ct.format){let R=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"dto",method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},I);R&&(I=`${O}${R}`);}z=I;let x=`export type ${I} = ${F};
|
|
51
|
+
`;e!=null&&e.folderSplit?m[h].types+=x:T+=x;}if(((bt=e==null?void 0:e.validations)==null?void 0:bt.disable)!==true&&((xt=(It=e==null?void 0:e.validations)==null?void 0:It.generate)==null?void 0:xt.dto)!==false&&N){let I=((Et=e.validations)==null?void 0:Et.library)||"zod";if(N.content){let x=Object.keys(N.content);if(x[0]&&N.content[x[0]].schema){let R=((Tt=e==null?void 0:e.validations)==null?void 0:Tt.name)||((wt=e==null?void 0:e.types)==null?void 0:wt.name),L=typeof(R==null?void 0:R.prefix)=="string"?R.prefix:"I",_=typeof((Pt=(At=e==null?void 0:e.validations)==null?void 0:At.name)==null?void 0:Pt.suffix)=="string"?e.validations.name.suffix:"Schema",M=`${y.name}DTO`;if(R!=null&&R.useOperationId&&(a!=null&&a.operationId)&&(M=`${a.operationId}DTO`),M=ue(`${L}${M}${_}`),(qt=(vt=e==null?void 0:e.validations)==null?void 0:vt.name)!=null&&qt.format){let te=e.validations.name.format({code:"",type:"dto",method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},M);te&&(M=`${L}${te}${_}`);}else if((jt=(Ot=e==null?void 0:e.types)==null?void 0:Ot.name)!=null&&jt.format){let te=e.types.name.format("endpoint",{code:"",type:"dto",method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},M);te&&(M=`${L}${te}${_}`);}let B=K(N.content[x[0]].schema,I),U=`export const ${M} = ${B};
|
|
52
52
|
|
|
53
|
-
`;
|
|
54
|
-
`;
|
|
55
|
-
- Scopes: [\`${
|
|
53
|
+
`;e!=null&&e.folderSplit||m[h]||(m[h]={endpoints:"",types:"",validation:""}),m[h].validation+=U;}}}let D={},re="",Ce="";if(a!=null&&a.responses){let I=a==null?void 0:a.responses;Object.keys(I).forEach(R=>{var L,_,M,B;if(re=Q(I[R]),D[R]=re,re){let U=`${y.name}${R}Response`;if((_=(L=e==null?void 0:e.types)==null?void 0:L.name)!=null&&_.useOperationId&&(a!=null&&a.operationId)&&(U=`${a.operationId}${R}Response`),U=ue(`${O}${U}`),(B=(M=e==null?void 0:e.types)==null?void 0:M.name)!=null&&B.format){let ne=e==null?void 0:e.types.name.format("endpoint",{code:R,type:"response",method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},U);ne&&(U=`${O}${ne}`);}let te=`export type ${U} = ${re};
|
|
54
|
+
`;e!=null&&e.folderSplit?m[h].types+=te:T+=te,D[R]=U;let me=parseInt(R);me>=200&&me<300&&(Ce=U);}});}let de=I=>!I||!I.length?"":I.map(x=>Object.entries(x).map(([L,_])=>{let M=L,B="";return Array.isArray(_)&&_.length&&(B=`
|
|
55
|
+
- Scopes: [\`${_.join("`, `")}\`]`,M=`**${M}**`),`
|
|
56
56
|
- ${M}${B}`}).join("")).join(`
|
|
57
|
-
`),
|
|
58
|
-
--cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:U.type==="apiKey"?
|
|
57
|
+
`),fe=a!=null&&a.security?de(a.security):"",Ie="";if(!((Rt=(kt=e==null?void 0:e.endpoints)==null?void 0:kt.doc)!=null&&Rt.disable)){let I="";if((Ut=(St=e==null?void 0:e.endpoints)==null?void 0:St.doc)!=null&&Ut.showCurl){let x={},R="",L="";(Mt=a.requestBody)!=null&&Mt.content&&Object.keys(a.requestBody.content).forEach(B=>{let U=a.requestBody.content[B].schema;if(U){Array.isArray(x["Content-type"])?x["Content-type"].push(B):x["Content-type"]=[B];let te=k(n,U);te&&(R=te);}}),a!=null&&a.security&&a.security.forEach(M=>{Object.keys(M).forEach(B=>{var te,me;let U=(me=(te=n.components)==null?void 0:te.securitySchemes)==null?void 0:me[B];U&&(U.type==="mutualTLS"?L+=`
|
|
58
|
+
--cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:U.type==="apiKey"?x[(U==null?void 0:U.name)||"X-API-KEY"]="{API_KEY_VALUE}":x.Authorization=`${(U==null?void 0:U.scheme)==="basic"?"Basic":"Bearer"} {${(U==null?void 0:U.scheme)==="basic"?"VALUE":"TOKEN"}}`);});});let _={};Object.keys(x).forEach(M=>{Array.isArray(x[M])?_[M]=x[M].join("; "):_[M]=x[M];}),I=`
|
|
59
59
|
\`\`\`bash
|
|
60
|
-
${CurlGenerator({url:
|
|
61
|
-
\`\`\``;}
|
|
62
|
-
* ${
|
|
63
|
-
* **Method**: \`${
|
|
64
|
-
* **Summary**: ${(
|
|
65
|
-
* **Tags**: [${((
|
|
66
|
-
* **OperationId**: ${(
|
|
67
|
-
* **Query**: ${ve(
|
|
68
|
-
* **DTO**: ${ve(
|
|
69
|
-
* **Response**: ${Object.entries(
|
|
70
|
-
- **${
|
|
71
|
-
* **Security**: ${
|
|
72
|
-
`:""}${
|
|
60
|
+
${CurlGenerator({url:j+r,method:d.toUpperCase(),headers:_,body:R})}${L}
|
|
61
|
+
\`\`\``;}Ie=`/**${a!=null&&a.description?`
|
|
62
|
+
* ${a==null?void 0:a.description} `:""}
|
|
63
|
+
* **Method**: \`${d.toUpperCase()}\`
|
|
64
|
+
* **Summary**: ${(a==null?void 0:a.summary)||""}
|
|
65
|
+
* **Tags**: [${((Gt=a==null?void 0:a.tags)==null?void 0:Gt.join(", "))||""}]
|
|
66
|
+
* **OperationId**: ${(a==null?void 0:a.operationId)||""} ${Z?`
|
|
67
|
+
* **Query**: ${ve(Z)} `:""}${F?`
|
|
68
|
+
* **DTO**: ${ve(F)} `:""}${re?`
|
|
69
|
+
* **Response**: ${Object.entries(D).map(([x,R])=>`
|
|
70
|
+
- **${x}**: ${ve(R,2)} `).join("")}`:""}${fe?`
|
|
71
|
+
* **Security**: ${fe}
|
|
72
|
+
`:""}${I}
|
|
73
73
|
*/
|
|
74
|
-
`;}let
|
|
75
|
-
`;
|
|
74
|
+
`;}let ye=(Lt=(Nt=e==null?void 0:e.endpoints)==null?void 0:Nt.name)!=null&&Lt.useOperationId&&((Ft=a==null?void 0:a.operationId)==null?void 0:Ft.length)>0?a.operationId:`${y.name}`;if((Bt=(Qt=e==null?void 0:e.endpoints)==null?void 0:Qt.name)!=null&&Bt.format){let I=e==null?void 0:e.endpoints.name.format({method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId},ye);I&&(ye=I);}let Re={method:`"${d}"`,operationId:`"${a==null?void 0:a.operationId}"`,url:W,tags:(a==null?void 0:a.tags)||[]},Ve=`${Ie}export const ${q}${ye} = ${((Dt=(zt=e==null?void 0:e.endpoints)==null?void 0:zt.value)==null?void 0:Dt.type)==="object"?Ee(Re):W};
|
|
75
|
+
`;e!=null&&e.folderSplit?m[h].endpoints+=Ve:H+=Ve;let un={name:`${q}${ye}`,method:d,path:r,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId,tags:c,parameters:(Jt=a==null?void 0:a.parameters)==null?void 0:Jt.filter(I=>!I.$ref&&I.in&&I.name).map(I=>{var x;return {name:I.name,in:I.in,required:I.required,type:((x=I.schema)==null?void 0:x.type)||"string"}}),requestBody:N?{type:F,required:N.required}:void 0,responses:D?Object.entries(D).reduce((I,[x,R])=>(I[x]={type:R},I),{}):void 0,queryType:v,dtoType:z,responseType:Ce||void 0};Y.push(un);});}),e!=null&&e.folderSplit){for(let[r,u]of Object.entries(m))if(u.endpoints||u.types){let E=J.join(g,r);if(u.endpoints){let $=J.join(ce,E,"endpoints.ts");yield ie.promises.mkdir(J.dirname($),{recursive:true}),yield ge($,u.endpoints,e);}if(u.types){let $=J.join(ce,E,"types.ts");yield ie.promises.mkdir(J.dirname($),{recursive:true});let d=Object.values(b$1).length>0?`import * as Shared from "../shared";
|
|
76
76
|
|
|
77
|
-
${
|
|
77
|
+
${u.types}`:u.types;yield ge($,d,e);}if(((We=e==null?void 0:e.validations)==null?void 0:We.disable)!==true&&u.validation){let $=((He=e.validations)==null?void 0:He.library)||"zod",d=$==="joi"?'import Joi from "joi";':$==="yup"?'import * as yup from "yup";':'import { z } from "zod";',y=J.join(ce,E,"validations.ts");yield ie.promises.mkdir(J.dirname(y),{recursive:true}),yield ge(y,`${d}
|
|
78
78
|
|
|
79
|
-
${
|
|
80
|
-
`),
|
|
79
|
+
${u.validation}`,e);}}}if(H.length>0){let r=J.join(ce,g,"endpoints.ts");yield ie.promises.mkdir(J.dirname(r),{recursive:true}),yield ge(r,H,e);}if(Object.values(b$1).length>0){let r=J.join(ce,g,e!=null&&e.folderSplit?"":"types","shared.ts");yield ie.promises.mkdir(J.dirname(r),{recursive:true}),yield ge(r,Object.values(b$1).join(`
|
|
80
|
+
`),e);}if(T.length>0){let r=J.join(ce,g,"types","index.ts");yield ie.promises.mkdir(J.dirname(r),{recursive:true}),yield ge(r,`${Object.values(b$1).length>0?`import * as Shared from "./shared";
|
|
81
81
|
|
|
82
|
-
`:""}${
|
|
82
|
+
`:""}${T}`,e);}if(((Ke=e==null?void 0:e.validations)==null?void 0:Ke.disable)!==true&&!(e!=null&&e.folderSplit)){let r=((_e=e.validations)==null?void 0:_e.library)||"zod",u=r==="joi"?'import Joi from "joi";':r==="yup"?'import * as yup from "yup";':'import { z } from "zod";',E=Object.values(m).map($=>$.validation).filter($=>$.length>0).join("");if(E){let $=J.join(ce,g,"validations.ts");yield ie.promises.mkdir(J.dirname($),{recursive:true}),yield ge($,`${u}
|
|
83
83
|
|
|
84
|
-
${
|
|
84
|
+
${E}`,e);}}return tn(p,Y),console.info(`\u2705 Successfully synced ${p}`),{success:true}}),Le=sn;var on=(l,o)=>{let p=l;return o.tags&&o.tags.length>0&&(p=p.filter(e=>!e.tags||e.tags.length===0?false:e.tags.some(s=>o.tags.includes(s)))),o.endpoints&&o.endpoints.length>0&&(p=p.filter(e=>o.endpoints.includes(e.name))),p};var Fe=(l,o,p=false)=>{var n,g;let e=o.baseURL||"";o.auth;let t=`// Generated Fetch API Client
|
|
85
85
|
`;t+=`// This file was auto-generated. Add custom code in the marked sections.
|
|
86
86
|
|
|
87
87
|
`,t+=`import type {
|
|
88
|
-
`;let
|
|
88
|
+
`;let i=new Set;return l.forEach(m=>{m.queryType&&i.add(m.queryType),m.dtoType&&i.add(m.dtoType),m.responseType&&i.add(m.responseType);}),i.forEach(m=>{t+=` ${m},
|
|
89
89
|
`;}),t+=`} from '../types';
|
|
90
90
|
|
|
91
91
|
`,t+=`import {
|
|
92
|
-
`,
|
|
92
|
+
`,l.forEach(m=>{t+=` ${m.name} as ${m.name}_endpoint,
|
|
93
93
|
`;}),t+=`} from '../endpoints';
|
|
94
94
|
|
|
95
95
|
`,t+=`export interface ApiConfig {
|
|
@@ -105,7 +105,7 @@ ${w}`,n);}}Xt(i,I);}),Le=nn;var rn=(u,i)=>{let n=u;return i.tags&&i.tags.length>
|
|
|
105
105
|
`,t+=` globalConfig = { ...globalConfig, ...config };
|
|
106
106
|
`,t+=`};
|
|
107
107
|
|
|
108
|
-
`,(
|
|
108
|
+
`,(n=o.errorHandling)!=null&&n.generateErrorClasses&&(t+=`export class ApiError extends Error {
|
|
109
109
|
`,t+=` constructor(
|
|
110
110
|
`,t+=` message: string,
|
|
111
111
|
`,t+=` public statusCode: number,
|
|
@@ -131,7 +131,7 @@ ${w}`,n);}}Xt(i,I);}),Le=nn;var rn=(u,i)=>{let n=u;return i.tags&&i.tags.length>
|
|
|
131
131
|
`,t+=` });
|
|
132
132
|
|
|
133
133
|
`,t+=` if (!response.ok) {
|
|
134
|
-
`,(
|
|
134
|
+
`,(g=o.errorHandling)!=null&&g.generateErrorClasses?(t+=` const errorData = await response.json().catch(() => ({}));
|
|
135
135
|
`,t+=` throw new ApiError(
|
|
136
136
|
`,t+=` errorData.message || response.statusText,
|
|
137
137
|
`,t+=` response.status,
|
|
@@ -142,52 +142,52 @@ ${w}`,n);}}Xt(i,I);}),Le=nn;var rn=(u,i)=>{let n=u;return i.tags&&i.tags.length>
|
|
|
142
142
|
`,t+=` return response.json();
|
|
143
143
|
`,t+=`}
|
|
144
144
|
|
|
145
|
-
`,
|
|
145
|
+
`,l.forEach(m=>{var H,T;let f=m.name,j=((H=m.parameters)==null?void 0:H.filter(b=>b.in==="path"))||[],O=((T=m.parameters)==null?void 0:T.filter(b=>b.in==="query"))||[],q=j.length>0,w=O.length>0,A=!!m.requestBody,k=m.responseType||"any";if(t+=`/**
|
|
146
146
|
`,m.summary&&(t+=` * ${m.summary}
|
|
147
147
|
`),t+=` * @method ${m.method.toUpperCase()}
|
|
148
148
|
`,t+=` * @path ${m.path}
|
|
149
149
|
`,m.tags&&m.tags.length>0&&(t+=` * @tags ${m.tags.join(", ")}
|
|
150
150
|
`),t+=` */
|
|
151
|
-
`,t+=`export async function ${
|
|
152
|
-
`,
|
|
153
|
-
`,
|
|
151
|
+
`,t+=`export async function ${f}(`,(q||w||A)&&(t+=`params: {
|
|
152
|
+
`,q&&(t+=` url: {
|
|
153
|
+
`,j.forEach(b=>{let G={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[b.type||"string"]||"any",Q=b.required?"":"?";t+=` ${b.name}${Q}: ${G};
|
|
154
154
|
`;}),t+=` };
|
|
155
|
-
`),
|
|
156
|
-
`),
|
|
155
|
+
`),w&&(t+=` query: ${m.queryType||"Record<string, any>"};
|
|
156
|
+
`),A&&(t+=` data: ${m.dtoType||"any"};
|
|
157
157
|
`),t+=`}
|
|
158
|
-
`),t+=`): Promise<${
|
|
159
|
-
`,
|
|
160
|
-
`;}let
|
|
161
|
-
`,
|
|
162
|
-
`:(t+=` if (query.${
|
|
163
|
-
`,t+=` queryParams.append('${
|
|
158
|
+
`),t+=`): Promise<${k}> {
|
|
159
|
+
`,q||w||A){let b=[];q&&b.push("url"),w&&b.push("query"),A&&b.push("data"),t+=` const { ${b.join(", ")} } = params;
|
|
160
|
+
`;}let S;if(q){let b=j.map(Y=>`url.${Y.name}`).join(", ");S=`${m.name}_endpoint(${b})`;}else S=`${m.name}_endpoint`;w?(t+=` const queryParams = new URLSearchParams();
|
|
161
|
+
`,O.forEach(b=>{b.required?t+=` queryParams.append('${b.name}', String(query.${b.name}));
|
|
162
|
+
`:(t+=` if (query.${b.name} !== undefined) {
|
|
163
|
+
`,t+=` queryParams.append('${b.name}', String(query.${b.name}));
|
|
164
164
|
`,t+=` }
|
|
165
|
-
`);}),t+=` const _url = \`\${${
|
|
166
|
-
`):t+=` const _url = ${
|
|
167
|
-
`,t+=` return fetchAPI<${
|
|
165
|
+
`);}),t+=` const _url = \`\${${S}}?\${queryParams.toString()}\`;
|
|
166
|
+
`):t+=` const _url = ${S};
|
|
167
|
+
`,t+=` return fetchAPI<${k}>(_url, {
|
|
168
168
|
`,t+=` method: '${m.method.toUpperCase()}',
|
|
169
|
-
`,
|
|
169
|
+
`,A&&(t+=` body: JSON.stringify(data),
|
|
170
170
|
`),t+=` });
|
|
171
171
|
`,t+=`}
|
|
172
172
|
|
|
173
|
-
`;}),
|
|
173
|
+
`;}),p&&(t+=`// Export all functions as a default object
|
|
174
174
|
`,t+=`const apiClient = {
|
|
175
175
|
`,t+=` setApiConfig,
|
|
176
|
-
`,
|
|
176
|
+
`,l.forEach(m=>{t+=` ${m.name},
|
|
177
177
|
`;}),t+=`};
|
|
178
178
|
|
|
179
179
|
`,t+=`export default apiClient;
|
|
180
|
-
`),t},
|
|
180
|
+
`),t},he=(l,o,p=false)=>{var n,g;let e=o.baseURL||"";o.auth;let t=`// Generated Axios API Client
|
|
181
181
|
`;t+=`// This file was auto-generated. Add custom code in the marked sections.
|
|
182
182
|
|
|
183
183
|
`,t+=`import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
184
184
|
|
|
185
185
|
`,t+=`import type {
|
|
186
|
-
`;let
|
|
186
|
+
`;let i=new Set;return l.forEach(m=>{m.queryType&&i.add(m.queryType),m.dtoType&&i.add(m.dtoType),m.responseType&&i.add(m.responseType);}),i.forEach(m=>{t+=` ${m},
|
|
187
187
|
`;}),t+=`} from '../types';
|
|
188
188
|
|
|
189
189
|
`,t+=`import {
|
|
190
|
-
`,
|
|
190
|
+
`,l.forEach(m=>{t+=` ${m.name},
|
|
191
191
|
`;}),t+=`} from '../endpoints';
|
|
192
192
|
|
|
193
193
|
`,t+=`export interface ApiConfig {
|
|
@@ -196,7 +196,7 @@ ${w}`,n);}}Xt(i,I);}),Le=nn;var rn=(u,i)=>{let n=u;return i.tags&&i.tags.length>
|
|
|
196
196
|
`,t+=` timeout?: number;
|
|
197
197
|
`,t+=`}
|
|
198
198
|
|
|
199
|
-
`,(
|
|
199
|
+
`,(n=o.errorHandling)!=null&&n.generateErrorClasses&&(t+=`export class ApiError extends Error {
|
|
200
200
|
`,t+=` constructor(
|
|
201
201
|
`,t+=` message: string,
|
|
202
202
|
`,t+=` public statusCode: number,
|
|
@@ -224,7 +224,7 @@ ${w}`,n);}}Xt(i,I);}),Le=nn;var rn=(u,i)=>{let n=u;return i.tags&&i.tags.length>
|
|
|
224
224
|
`,t+=` this.client.interceptors.response.use(
|
|
225
225
|
`,t+=` (response) => response,
|
|
226
226
|
`,t+=` (error) => {
|
|
227
|
-
`,(
|
|
227
|
+
`,(g=o.errorHandling)!=null&&g.generateErrorClasses?(t+=` const message = error.response?.data?.message || error.message;
|
|
228
228
|
`,t+=` const statusCode = error.response?.status || 500;
|
|
229
229
|
`,t+=` throw new ApiError(message, statusCode, error.response?.data);
|
|
230
230
|
`):t+=` return Promise.reject(error);
|
|
@@ -236,27 +236,27 @@ ${w}`,n);}}Xt(i,I);}),Le=nn;var rn=(u,i)=>{let n=u;return i.tags&&i.tags.length>
|
|
|
236
236
|
`,t+=` Object.assign(this.client.defaults, config);
|
|
237
237
|
`,t+=` }
|
|
238
238
|
|
|
239
|
-
`,
|
|
239
|
+
`,l.forEach(m=>{var S,H;let f=m.name,j=((S=m.parameters)==null?void 0:S.filter(T=>T.in==="path"))||[],O=((H=m.parameters)==null?void 0:H.filter(T=>T.in==="query"))||[],q=j.length>0,w=O.length>0,A=!!m.requestBody,k=m.responseType||"any";if(t+=` /**
|
|
240
240
|
`,m.summary&&(t+=` * ${m.summary}
|
|
241
241
|
`),t+=` * @method ${m.method.toUpperCase()}
|
|
242
242
|
`,t+=` * @path ${m.path}
|
|
243
243
|
`,m.tags&&m.tags.length>0&&(t+=` * @tags ${m.tags.join(", ")}
|
|
244
244
|
`),t+=` */
|
|
245
|
-
`,t+=` async ${
|
|
246
|
-
`,
|
|
247
|
-
`,
|
|
245
|
+
`,t+=` async ${f}(`,(q||w||A)&&(t+=`params: {
|
|
246
|
+
`,q&&(t+=` url: {
|
|
247
|
+
`,j.forEach(T=>{let Y={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[T.type||"string"]||"any",G=T.required?"":"?";t+=` ${T.name}${G}: ${Y};
|
|
248
248
|
`;}),t+=` };
|
|
249
|
-
`),
|
|
250
|
-
`),
|
|
251
|
-
`),t+=" }"),t+=`): Promise<${
|
|
252
|
-
`,
|
|
253
|
-
`;}if(
|
|
249
|
+
`),w&&(t+=` query: ${m.queryType||"Record<string, any>"};
|
|
250
|
+
`),A&&(t+=` data: ${m.dtoType||"any"};
|
|
251
|
+
`),t+=" }"),t+=`): Promise<${k}> {
|
|
252
|
+
`,q||w||A){let T=[];q&&T.push("url"),w&&T.push("query"),A&&T.push("data"),t+=` const { ${T.join(", ")} } = params;
|
|
253
|
+
`;}if(q){let T=j.map(b=>`url.${b.name}`).join(", ");t+=` const _url = ${m.name}(${T});
|
|
254
254
|
`;}else t+=` const _url = ${m.name};
|
|
255
255
|
`;t+=` const config: AxiosRequestConfig = {};
|
|
256
|
-
`,
|
|
257
|
-
`),t+=` const response = await this.client.${m.method.toLowerCase()}<${
|
|
256
|
+
`,w&&(t+=` config.params = { ...query };
|
|
257
|
+
`),t+=` const response = await this.client.${m.method.toLowerCase()}<${k}>(
|
|
258
258
|
`,t+=` _url,
|
|
259
|
-
`,
|
|
259
|
+
`,A?t+=` data,
|
|
260
260
|
config
|
|
261
261
|
`:t+=` config
|
|
262
262
|
`,t+=` );
|
|
@@ -265,110 +265,110 @@ ${w}`,n);}}Xt(i,I);}),Le=nn;var rn=(u,i)=>{let n=u;return i.tags&&i.tags.length>
|
|
|
265
265
|
|
|
266
266
|
`;}),t+=`}
|
|
267
267
|
|
|
268
|
-
`,
|
|
268
|
+
`,p?t+=`export default ApiClient;
|
|
269
269
|
`:(t+=`export const apiClient = new ApiClient();
|
|
270
270
|
`,t+=`export default apiClient;
|
|
271
|
-
`),t},Qe=(
|
|
271
|
+
`),t},Qe=(l,o)=>{var g,m;let p=((g=o.reactQuery)==null?void 0:g.version)||5,e=((m=o.reactQuery)==null?void 0:m.mutations)!==false,s=!!(o.reactQuery&&o.reactQuery.infiniteQueries&&!o.reactQuery.infiniteQueries.disable),t=`// Generated React Query Hooks
|
|
272
272
|
`;t+=`// This file was auto-generated. Add custom code in the marked sections.
|
|
273
273
|
|
|
274
|
-
`;let
|
|
274
|
+
`;let i=e&&l.some(f=>["POST","PUT","PATCH","DELETE"].includes(f.method.toUpperCase()));if(p===5){let f=i?`import { useQuery, useMutation, UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
275
275
|
`:`import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
276
|
-
`;s&&(
|
|
276
|
+
`;s&&(f=f.replace("@tanstack/react-query';\\n",`@tanstack/react-query';
|
|
277
277
|
import { useInfiniteQuery, UseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
278
|
-
`)),t+=
|
|
278
|
+
`)),t+=f;}else {let f=i?`import { useQuery, useMutation, UseQueryOptions, UseMutationOptions } from 'react-query';
|
|
279
279
|
`:`import { useQuery, UseQueryOptions } from 'react-query';
|
|
280
|
-
`;s&&(
|
|
280
|
+
`;s&&(f=f.replace("react-query';\\n",`react-query';
|
|
281
281
|
import { useInfiniteQuery, UseInfiniteQueryOptions } from 'react-query';
|
|
282
|
-
`)),t+=
|
|
282
|
+
`)),t+=f;}t+=`
|
|
283
283
|
`,t+=`import apiClient from './client';
|
|
284
284
|
`,t+=`import type {
|
|
285
|
-
`;let
|
|
285
|
+
`;let n=new Set;return l.forEach(f=>{f.queryType&&n.add(f.queryType),f.dtoType&&n.add(f.dtoType),f.responseType&&n.add(f.responseType);}),n.forEach(f=>{t+=` ${f},
|
|
286
286
|
`;}),t+=`} from '../types';
|
|
287
287
|
|
|
288
|
-
`,
|
|
289
|
-
`,
|
|
290
|
-
`),t+=` * @method ${
|
|
291
|
-
`,t+=` * @path ${
|
|
292
|
-
`,
|
|
288
|
+
`,l.forEach(f=>{var b,Y;let j=f.method.toUpperCase(),O=j==="GET",q=["POST","PUT","PATCH","DELETE"].includes(j),w=((b=f.parameters)==null?void 0:b.filter(G=>G.in==="path"))||[],A=((Y=f.parameters)==null?void 0:Y.filter(G=>G.in==="query"))||[],k=w.length>0,S=A.length>0,H=!!f.requestBody,T=f.responseType||"any";if(O){let G=A.map(oe=>oe.name.toLowerCase()),K=(G.includes("page")||G.includes("cursor")||G.includes("cursorid")||G.includes("after")||G.includes("before"))&&s,pe=`use${f.name.charAt(0).toUpperCase()+f.name.slice(1)}`;if(t+=`/**
|
|
289
|
+
`,f.summary&&(t+=` * ${f.summary}
|
|
290
|
+
`),t+=` * @method ${j}
|
|
291
|
+
`,t+=` * @path ${f.path}
|
|
292
|
+
`,f.tags&&f.tags.length>0&&(t+=` * @tags ${f.tags.join(", ")}
|
|
293
293
|
`),t+=` */
|
|
294
|
-
`,
|
|
294
|
+
`,k||S?(t+=`export function ${pe}(
|
|
295
295
|
`,t+=` params: {
|
|
296
|
-
`,
|
|
297
|
-
`,
|
|
296
|
+
`,k&&(t+=` url: {
|
|
297
|
+
`,w.forEach(oe=>{let be={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[oe.type||"string"]||"any",$e=oe.required?"":"?";t+=` ${oe.name}${$e}: ${be};
|
|
298
298
|
`;}),t+=` };
|
|
299
|
-
`),
|
|
299
|
+
`),S&&(t+=` query: ${f.queryType||"Record<string, any>"};
|
|
300
300
|
`),t+=` },
|
|
301
301
|
`,t+=` options?: Omit<UseQueryOptions<${T}>, 'queryKey' | 'queryFn'>
|
|
302
302
|
`,t+=`) {
|
|
303
303
|
`,t+=` return useQuery({
|
|
304
|
-
`,t+=` queryKey: ['${
|
|
305
|
-
`,t+=` queryFn: () => apiClient.${
|
|
304
|
+
`,t+=` queryKey: ['${f.name}', params],
|
|
305
|
+
`,t+=` queryFn: () => apiClient.${f.name}(params),
|
|
306
306
|
`,t+=` ...options,
|
|
307
307
|
`,t+=` });
|
|
308
308
|
`,t+=`}
|
|
309
309
|
|
|
310
|
-
`):(t+=`export function ${
|
|
310
|
+
`):(t+=`export function ${pe}(
|
|
311
311
|
`,t+=` options?: Omit<UseQueryOptions<${T}>, 'queryKey' | 'queryFn'>
|
|
312
312
|
`,t+=`) {
|
|
313
313
|
`,t+=` return useQuery({
|
|
314
|
-
`,t+=` queryKey: ['${
|
|
315
|
-
`,t+=` queryFn: () => apiClient.${
|
|
314
|
+
`,t+=` queryKey: ['${f.name}'],
|
|
315
|
+
`,t+=` queryFn: () => apiClient.${f.name}(),
|
|
316
316
|
`,t+=` ...options,
|
|
317
317
|
`,t+=` });
|
|
318
318
|
`,t+=`}
|
|
319
319
|
|
|
320
|
-
`),
|
|
320
|
+
`),K){let oe=`${pe}Infinite`;k||S?(t+=`export function ${oe}(
|
|
321
321
|
`,t+=` params: {
|
|
322
|
-
`,
|
|
323
|
-
`,
|
|
322
|
+
`,k&&(t+=` url: {
|
|
323
|
+
`,w.forEach(le=>{let $e={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[le.type||"string"]||"any",Pe=le.required?"":"?";t+=` ${le.name}${Pe}: ${$e};
|
|
324
324
|
`;}),t+=` };
|
|
325
|
-
`),
|
|
325
|
+
`),S&&(t+=` query: ${f.queryType||"Record<string, any>"};
|
|
326
326
|
`),t+=` },
|
|
327
327
|
`,t+=` options?: Omit<UseInfiniteQueryOptions<${T}, Error, ${T}>, 'queryKey' | 'queryFn'>
|
|
328
328
|
`,t+=`) {
|
|
329
329
|
`,t+=` return useInfiniteQuery({
|
|
330
|
-
`,t+=` queryKey: ['${
|
|
331
|
-
`,t+=` queryFn: ({ pageParam = 1 }) => apiClient.${
|
|
330
|
+
`,t+=` queryKey: ['${f.name}', params],
|
|
331
|
+
`,t+=` queryFn: ({ pageParam = 1 }) => apiClient.${f.name}({ ...params, query: { ...(params.query || {}), page: pageParam } }),
|
|
332
332
|
`,t+=` getNextPageParam: (lastPage) => lastPage?.nextPage ?? lastPage?.nextCursor ?? null,
|
|
333
333
|
`,t+=` ...options,
|
|
334
334
|
`,t+=` });
|
|
335
335
|
`,t+=`}
|
|
336
336
|
|
|
337
|
-
`):(t+=`export function ${
|
|
337
|
+
`):(t+=`export function ${oe}(
|
|
338
338
|
`,t+=` options?: Omit<UseInfiniteQueryOptions<${T}, Error, ${T}>, 'queryKey' | 'queryFn'>
|
|
339
339
|
`,t+=`) {
|
|
340
340
|
`,t+=` return useInfiniteQuery({
|
|
341
|
-
`,t+=` queryKey: ['${
|
|
342
|
-
`,t+=` queryFn: ({ pageParam = 1 }) => apiClient.${
|
|
341
|
+
`,t+=` queryKey: ['${f.name}'],
|
|
342
|
+
`,t+=` queryFn: ({ pageParam = 1 }) => apiClient.${f.name}({ query: { page: pageParam } }),
|
|
343
343
|
`,t+=` getNextPageParam: (lastPage) => lastPage?.nextPage ?? lastPage?.nextCursor ?? null,
|
|
344
344
|
`,t+=` ...options,
|
|
345
345
|
`,t+=` });
|
|
346
346
|
`,t+=`}
|
|
347
347
|
|
|
348
|
-
`);}}else if(
|
|
349
|
-
`,
|
|
350
|
-
`),t+=` * @method ${
|
|
351
|
-
`,t+=` * @path ${
|
|
352
|
-
`,
|
|
348
|
+
`);}}else if(q&&e){let G=`use${f.name.charAt(0).toUpperCase()+f.name.slice(1)}`;t+=`/**
|
|
349
|
+
`,f.summary&&(t+=` * ${f.summary}
|
|
350
|
+
`),t+=` * @method ${j}
|
|
351
|
+
`,t+=` * @path ${f.path}
|
|
352
|
+
`,f.tags&&f.tags.length>0&&(t+=` * @tags ${f.tags.join(", ")}
|
|
353
353
|
`),t+=` */
|
|
354
|
-
`;let
|
|
355
|
-
`,
|
|
356
|
-
`,
|
|
357
|
-
`;}),
|
|
358
|
-
`),
|
|
359
|
-
`),
|
|
360
|
-
`),
|
|
361
|
-
`,t+=` options?: Omit<UseMutationOptions<${T}, Error, ${
|
|
354
|
+
`;let Q="void";(k||S||H)&&(Q=`{
|
|
355
|
+
`,k&&(Q+=` url: {
|
|
356
|
+
`,w.forEach(K=>{let oe={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[K.type||"string"]||"any",le=K.required?"":"?";Q+=` ${K.name}${le}: ${oe};
|
|
357
|
+
`;}),Q+=` };
|
|
358
|
+
`),S&&(Q+=` query: ${f.queryType||"Record<string, any>"};
|
|
359
|
+
`),H&&(Q+=` data: ${f.dtoType||"any"};
|
|
360
|
+
`),Q+=" }"),t+=`export function ${G}(
|
|
361
|
+
`,t+=` options?: Omit<UseMutationOptions<${T}, Error, ${Q}>, 'mutationFn'>
|
|
362
362
|
`,t+=`) {
|
|
363
363
|
`,t+=` return useMutation({
|
|
364
|
-
`,t+=" mutationFn: (",
|
|
365
|
-
`,t+=` return apiClient.${
|
|
364
|
+
`,t+=" mutationFn: (",Q!=="void"&&(t+=`variables: ${Q}`),t+=`) => {
|
|
365
|
+
`,t+=` return apiClient.${f.name}(${Q!=="void"?"variables":""});
|
|
366
366
|
`,t+=` },
|
|
367
367
|
`,t+=` ...options,
|
|
368
368
|
`,t+=` });
|
|
369
369
|
`,t+=`}
|
|
370
370
|
|
|
371
|
-
`;}}),t},Be=(
|
|
371
|
+
`;}}),t},Be=(l,o)=>{var i;let p=((i=o.swr)==null?void 0:i.mutations)!==false,e=`// Generated SWR Hooks
|
|
372
372
|
`;e+=`// This file was auto-generated. Add custom code in the marked sections.
|
|
373
373
|
|
|
374
374
|
`,e+=`/**
|
|
@@ -563,173 +563,173 @@ import { useInfiniteQuery, UseInfiniteQueryOptions } from 'react-query';
|
|
|
563
563
|
`,e+=` */
|
|
564
564
|
|
|
565
565
|
`,e+=`import useSWR, { SWRConfiguration } from 'swr';
|
|
566
|
-
`,
|
|
566
|
+
`,p&&l.some(n=>["POST","PUT","PATCH","DELETE"].includes(n.method.toUpperCase()))&&(e+=`import useSWRMutation, { SWRMutationConfiguration } from 'swr/mutation';
|
|
567
567
|
`),e+=`
|
|
568
568
|
`,e+=`import apiClient from './client';
|
|
569
569
|
`,e+=`import type {
|
|
570
|
-
`;let t=new Set;return
|
|
570
|
+
`;let t=new Set;return l.forEach(n=>{n.queryType&&t.add(n.queryType),n.dtoType&&t.add(n.dtoType),n.responseType&&t.add(n.responseType);}),t.forEach(n=>{e+=` ${n},
|
|
571
571
|
`;}),e+=`} from '../types';
|
|
572
572
|
|
|
573
|
-
`,
|
|
574
|
-
`,
|
|
575
|
-
`),e+=` * @method ${
|
|
576
|
-
`,e+=` * @path ${
|
|
577
|
-
`,
|
|
573
|
+
`,l.forEach(n=>{var S,H;let g=n.method.toUpperCase(),m=g==="GET",f=["POST","PUT","PATCH","DELETE"].includes(g),j=((S=n.parameters)==null?void 0:S.filter(T=>T.in==="path"))||[],O=((H=n.parameters)==null?void 0:H.filter(T=>T.in==="query"))||[],q=j.length>0,w=O.length>0,A=!!n.requestBody,k=n.responseType||"any";if(m){let T=`use${n.name.charAt(0).toUpperCase()+n.name.slice(1)}`;e+=`/**
|
|
574
|
+
`,n.summary&&(e+=` * ${n.summary}
|
|
575
|
+
`),e+=` * @method ${g}
|
|
576
|
+
`,e+=` * @path ${n.path}
|
|
577
|
+
`,n.tags&&n.tags.length>0&&(e+=` * @tags ${n.tags.join(", ")}
|
|
578
578
|
`),e+=` */
|
|
579
|
-
`,
|
|
579
|
+
`,q||w?(e+=`export function ${T}(
|
|
580
580
|
`,e+=` params: {
|
|
581
|
-
`,
|
|
582
|
-
`,
|
|
581
|
+
`,q&&(e+=` url: {
|
|
582
|
+
`,j.forEach(b=>{let G={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[b.type||"string"]||"any",Q=b.required?"":"?";e+=` ${b.name}${Q}: ${G};
|
|
583
583
|
`;}),e+=` };
|
|
584
|
-
`),
|
|
584
|
+
`),w&&(e+=` query: ${n.queryType||"Record<string, any>"};
|
|
585
585
|
`),e+=` },
|
|
586
|
-
`,e+=` config?: SWRConfiguration<${
|
|
586
|
+
`,e+=` config?: SWRConfiguration<${k}>
|
|
587
587
|
`,e+=`) {
|
|
588
588
|
`,e+=` return useSWR(
|
|
589
|
-
`,e+=` ['${
|
|
590
|
-
`,e+=` () => apiClient.${
|
|
589
|
+
`,e+=` ['${n.name}', params],
|
|
590
|
+
`,e+=` () => apiClient.${n.name}(params),
|
|
591
591
|
`,e+=` config
|
|
592
592
|
`,e+=` );
|
|
593
593
|
`):(e+=`export function ${T}(
|
|
594
|
-
`,e+=` config?: SWRConfiguration<${
|
|
594
|
+
`,e+=` config?: SWRConfiguration<${k}>
|
|
595
595
|
`,e+=`) {
|
|
596
596
|
`,e+=` return useSWR(
|
|
597
|
-
`,e+=` '${
|
|
598
|
-
`,e+=` () => apiClient.${
|
|
597
|
+
`,e+=` '${n.name}',
|
|
598
|
+
`,e+=` () => apiClient.${n.name}(),
|
|
599
599
|
`,e+=` config
|
|
600
600
|
`,e+=` );
|
|
601
601
|
`),e+=`}
|
|
602
602
|
|
|
603
|
-
`;}else if(
|
|
604
|
-
`,
|
|
605
|
-
`),e+=` * @method ${
|
|
606
|
-
`,e+=` * @path ${
|
|
607
|
-
`,
|
|
603
|
+
`;}else if(f&&p){let T=`use${n.name.charAt(0).toUpperCase()+n.name.slice(1)}`;e+=`/**
|
|
604
|
+
`,n.summary&&(e+=` * ${n.summary}
|
|
605
|
+
`),e+=` * @method ${g}
|
|
606
|
+
`,e+=` * @path ${n.path}
|
|
607
|
+
`,n.tags&&n.tags.length>0&&(e+=` * @tags ${n.tags.join(", ")}
|
|
608
608
|
`),e+=` */
|
|
609
|
-
`;let
|
|
610
|
-
`,
|
|
611
|
-
`,
|
|
612
|
-
`;}),
|
|
613
|
-
`),
|
|
614
|
-
`),
|
|
615
|
-
`),
|
|
616
|
-
`,e+=` config?: SWRMutationConfiguration<${
|
|
609
|
+
`;let b="void",Y="void";(q||w||A)&&(b=`{
|
|
610
|
+
`,q&&(b+=` url: {
|
|
611
|
+
`,j.forEach(G=>{let K={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[G.type||"string"]||"any",pe=G.required?"":"?";b+=` ${G.name}${pe}: ${K};
|
|
612
|
+
`;}),b+=` };
|
|
613
|
+
`),w&&(b+=` query: ${n.queryType||"Record<string, any>"};
|
|
614
|
+
`),A&&(b+=` data: ${n.dtoType||"any"};
|
|
615
|
+
`),b+=" }",Y=`{ arg: ${b} }`),e+=`export function ${T}(
|
|
616
|
+
`,e+=` config?: SWRMutationConfiguration<${k}, Error, string, ${b}>
|
|
617
617
|
`,e+=`) {
|
|
618
618
|
`,e+=` return useSWRMutation(
|
|
619
|
-
`,e+=` '${
|
|
620
|
-
`,e+=" async (_, ",
|
|
621
|
-
`,e+=` return apiClient.${
|
|
619
|
+
`,e+=` '${n.name}',
|
|
620
|
+
`,e+=" async (_, ",b!=="void"&&(e+=`{ arg }: ${Y}`),e+=`) => {
|
|
621
|
+
`,e+=` return apiClient.${n.name}(${b!=="void"?"arg":""});
|
|
622
622
|
`,e+=` },
|
|
623
623
|
`,e+=` config
|
|
624
624
|
`,e+=` );
|
|
625
625
|
`,e+=`}
|
|
626
626
|
|
|
627
|
-
`;}}),e},ze=(
|
|
627
|
+
`;}}),e},ze=(l,o)=>{var i;let p=((i=o.rtkQuery)==null?void 0:i.apiName)||"api",e=o.baseURL||"",s=`// Generated RTK Query API Slice
|
|
628
628
|
`;s+=`// This file was auto-generated. Add custom code in the marked sections.
|
|
629
629
|
|
|
630
630
|
`,s+=`import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
|
631
631
|
|
|
632
632
|
`,s+=`import type {
|
|
633
|
-
`;let t=new Set;return
|
|
633
|
+
`;let t=new Set;return l.forEach(n=>{n.queryType&&t.add(n.queryType),n.dtoType&&t.add(n.dtoType),n.responseType&&t.add(n.responseType);}),t.forEach(n=>{s+=` ${n},
|
|
634
634
|
`;}),s+=`} from '../types';
|
|
635
635
|
|
|
636
636
|
`,s+=`import {
|
|
637
|
-
`,
|
|
637
|
+
`,l.forEach(n=>{s+=` ${n.name},
|
|
638
638
|
`;}),s+=`} from '../endpoints';
|
|
639
639
|
|
|
640
|
-
`,s+=`const ${
|
|
641
|
-
`,s+=` reducerPath: '${
|
|
640
|
+
`,s+=`const ${p}Api = createApi({
|
|
641
|
+
`,s+=` reducerPath: '${p}Api',
|
|
642
642
|
`,s+=` baseQuery: fetchBaseQuery({
|
|
643
643
|
`,s+=` baseUrl: '${e}',
|
|
644
|
-
`,
|
|
644
|
+
`,o.auth&&(s+=` prepareHeaders: (headers, { getState }) => {
|
|
645
645
|
`,s+=` // Get token from your auth state
|
|
646
646
|
`,s+=` // const token = (getState() as RootState).auth.token;
|
|
647
647
|
`,s+=` // if (token) {
|
|
648
|
-
`,
|
|
648
|
+
`,o.auth.type==="bearer"?s+=" // headers.set('Authorization', `Bearer ${token}`);\n":o.auth.type==="apiKey"&&o.auth.in==="header"&&(s+=` // headers.set('${o.auth.name||"X-API-Key"}', token);
|
|
649
649
|
`),s+=` // }
|
|
650
650
|
`,s+=` return headers;
|
|
651
651
|
`,s+=` },
|
|
652
652
|
`),s+=` }),
|
|
653
|
-
`,s+=` tagTypes: [${[...new Set(
|
|
653
|
+
`,s+=` tagTypes: [${[...new Set(l.flatMap(n=>n.tags||[]))].map(n=>`'${n}'`).join(", ")}],
|
|
654
654
|
`,s+=` endpoints: (builder) => ({
|
|
655
|
-
`,
|
|
656
|
-
`,s+=` ${
|
|
657
|
-
`;let
|
|
658
|
-
`,
|
|
659
|
-
`,
|
|
660
|
-
`;}),
|
|
661
|
-
`),
|
|
662
|
-
`),
|
|
663
|
-
`),
|
|
655
|
+
`,l.forEach((n,g)=>{var H,T;let m=n.method.toUpperCase(),f=m==="GET",j=((H=n.parameters)==null?void 0:H.filter(b=>b.in==="path"))||[],O=((T=n.parameters)==null?void 0:T.filter(b=>b.in==="query"))||[],q=j.length>0,w=O.length>0,A=!!n.requestBody,k=n.responseType||"any";s+=` ${n.name}: builder.${f?"query":"mutation"}<
|
|
656
|
+
`,s+=` ${k},
|
|
657
|
+
`;let S="void";if((q||w||A)&&(S=`{
|
|
658
|
+
`,q&&(S+=` url: {
|
|
659
|
+
`,j.forEach(b=>{let G={string:"string",number:"number",integer:"number",boolean:"boolean",array:"any[]",object:"any"}[b.type||"string"]||"any",Q=b.required?"":"?";S+=` ${b.name}${Q}: ${G};
|
|
660
|
+
`;}),S+=` };
|
|
661
|
+
`),w&&(S+=` query: ${n.queryType||"Record<string, any>"};
|
|
662
|
+
`),A&&(S+=` data: ${n.dtoType||"any"};
|
|
663
|
+
`),S+=" }"),s+=` ${S}
|
|
664
664
|
`,s+=` >({
|
|
665
|
-
`,s+=" query: (",
|
|
666
|
-
`,
|
|
667
|
-
`;}else s+=` const url = ${
|
|
665
|
+
`,s+=" query: (",S!=="void"&&(s+="arg"),s+=`) => {
|
|
666
|
+
`,q){let b=j.map(Y=>`arg.url.${Y.name}`).join(", ");s+=` const url = ${n.name}(${b});
|
|
667
|
+
`;}else s+=` const url = ${n.name};
|
|
668
668
|
`;s+=` return {
|
|
669
669
|
`,s+=` url,
|
|
670
670
|
`,s+=` method: '${m}',
|
|
671
|
-
`,
|
|
672
|
-
`),
|
|
671
|
+
`,w&&(s+=` params: arg.query,
|
|
672
|
+
`),A&&(s+=` body: arg.data,
|
|
673
673
|
`),s+=` };
|
|
674
674
|
`,s+=` },
|
|
675
|
-
`,
|
|
676
|
-
`:s+=` invalidatesTags: ['${
|
|
677
|
-
`),s+=` })${
|
|
675
|
+
`,n.tags&&n.tags.length>0&&(f?s+=` providesTags: ['${n.tags[0]}'],
|
|
676
|
+
`:s+=` invalidatesTags: ['${n.tags[0]}'],
|
|
677
|
+
`),s+=` })${g<l.length-1?",":""}
|
|
678
678
|
`;}),s+=` }),
|
|
679
679
|
`,s+=`});
|
|
680
680
|
|
|
681
|
-
`,s+=`export default ${
|
|
681
|
+
`,s+=`export default ${p}Api;
|
|
682
682
|
|
|
683
|
-
`,s};var
|
|
684
|
-
`;
|
|
685
|
-
`,
|
|
683
|
+
`,s};var In=(l,o)=>{var p,e;if((p=o==null?void 0:o.folderSplit)!=null&&p.customFolder){let s=o.folderSplit.customFolder({method:l.method,path:l.path,tags:l.tags,operationId:l.operationId,summary:l.summary});if(s)return s}return (e=o==null?void 0:o.folderSplit)!=null&&e.byTags&&l.tags&&l.tags.length>0?l.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},an=(l,o,p,e,s)=>d(null,null,function*(){let t=on(l,p);if(t.length===0)return;let i=p.type||"fetch";p.outputDir||J.join(s,e,"client");let g=!!(o!=null&&o.folderSplit&&(o.folderSplit.byTags||o.folderSplit.customFolder));if(`${i}${t.length}`,g){let f={};t.forEach(q=>{let w=In(q,o);f[w]||(f[w]=[]),f[w].push(q);});let j=Object.keys(f);for(let[q,w]of Object.entries(f)){let A=J.join(s,e,q);yield ie.promises.mkdir(A,{recursive:true}),`${i}${q}${w.length}`,yield xn(w,o,p,A,i,q,true);}let O=J.join(s,e);yield En(O,j,i,o);return}let m=J.join(s,e);switch(yield ie.promises.mkdir(m,{recursive:true}),i){case "fetch":let f=Fe(t,p);f=f.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield X(J.join(m,"clients.ts"),f,o);break;case "axios":let j=he(t,p,false);j=j.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield X(J.join(m,"clients.ts"),j,o);break;case "react-query":let O=he(t,p,false);O=O.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield X(J.join(m,"clients.ts"),O,o);let q=Qe(t,p);q=q.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';").replace("import apiClient from './client';","import apiClient from './clients';"),yield X(J.join(m,"hooks.ts"),q,o);break;case "swr":let w=he(t,p,false);w=w.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield X(J.join(m,"clients.ts"),w,o);let A=Be(t,p);A=A.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';").replace("import apiClient from './client';","import apiClient from './clients';"),yield X(J.join(m,"hooks.ts"),A,o);break;case "rtk-query":let k=ze(t,p);k=k.replace("} from '../types';","} from './types';").replace("} from '../endpoints';","} from './endpoints';"),yield X(J.join(m,"api.ts"),k,o);break;default:throw new Error(`Unknown client type: ${i}`)}}),X=(l,o,p)=>d(null,null,function*(){var i,n,g,m;if(!(((i=p==null?void 0:p.customCode)==null?void 0:i.enabled)!==false)){yield ie.promises.writeFile(l,o);return}let s=null;try{s=yield ie.promises.readFile(l,"utf-8");}catch(f){}let t=qe(o,s,{position:((n=p==null?void 0:p.customCode)==null?void 0:n.position)||"bottom",markerText:(g=p==null?void 0:p.customCode)==null?void 0:g.markerText,includeInstructions:(m=p==null?void 0:p.customCode)==null?void 0:m.includeInstructions});yield ie.promises.writeFile(l,t);});var xn=(l,o,p,e,s,t,i=false)=>d(null,null,function*(){let n="",g="",m=i?"./types":"../types",f=i?"./endpoints":"../endpoints";switch(s){case "fetch":n=Fe(l,p,i),n=n.replace("} from '../types';",`} from '${m}';`).replace("} from '../endpoints';",`} from '${f}';`),yield X(J.join(e,"client.ts"),n,o);break;case "axios":n=he(l,p,i),n=n.replace("} from '../types';",`} from '${m}';`).replace("} from '../endpoints';",`} from '${f}';`),yield X(J.join(e,"client.ts"),n,o);break;case "react-query":if(n=he(l,p,i),n=n.replace("} from '../types';",`} from '${m}';`).replace("} from '../endpoints';",`} from '${f}';`),yield X(J.join(e,"client.ts"),n,o),g=Qe(l,p),g=g.replace("} from '../types';",`} from '${m}';`).replace("} from '../endpoints';",`} from '${f}';`),i){let O=t.replace(/-/g,"_");g=g.replace("import apiClient from './client';",`import { ${O}Client as apiClient } from '../clients';`);}yield X(J.join(e,"hooks.ts"),g,o);break;case "swr":if(n=he(l,p,i),n=n.replace("} from '../types';",`} from '${m}';`).replace("} from '../endpoints';",`} from '${f}';`),yield X(J.join(e,"client.ts"),n,o),g=Be(l,p),g=g.replace("} from '../types';",`} from '${m}';`).replace("} from '../endpoints';",`} from '${f}';`),i){let O=t.replace(/-/g,"_");g=g.replace("import apiClient from './client';",`import { ${O}Client as apiClient } from '../clients';`);}yield X(J.join(e,"hooks.ts"),g,o);break;case "rtk-query":let j=i?b(a({},p),{rtkQuery:b(a({},p.rtkQuery),{apiName:t.replace(/-/g,"_")})}):p;g=ze(l,j),g=g.replace("} from '../types';",`} from '${m}';`).replace("} from '../endpoints';",`} from '${f}';`),yield X(J.join(e,"api.ts"),g,o);break;default:throw new Error(`Unknown client type: ${s}`)}}),En=(l,o,p,e)=>d(null,null,function*(){var t;if(p==="rtk-query"){let i=`// Generated RTK Query APIs
|
|
684
|
+
`;i+=`// This file was auto-generated.
|
|
685
|
+
`,i+=`// Aggregates all API slices for easy Redux store setup
|
|
686
686
|
|
|
687
|
-
`,
|
|
688
|
-
`;}),
|
|
687
|
+
`,o.forEach(n=>{let g=n.replace(/-/g,"_");i+=`import ${g}Api from './${n}/api';
|
|
688
|
+
`;}),i+=`
|
|
689
689
|
// Export all API slices
|
|
690
|
-
`,
|
|
691
|
-
`;}),
|
|
690
|
+
`,o.forEach(n=>{let g=n.replace(/-/g,"_");i+=`export { default as ${g}Api } from './${n}/api';
|
|
691
|
+
`;}),i+=`
|
|
692
692
|
/**
|
|
693
|
-
`,
|
|
694
|
-
`,
|
|
695
|
-
`,
|
|
696
|
-
`,
|
|
697
|
-
`,
|
|
698
|
-
`,
|
|
699
|
-
`,
|
|
700
|
-
`,
|
|
701
|
-
`,
|
|
702
|
-
`,
|
|
703
|
-
`,
|
|
704
|
-
`,
|
|
705
|
-
`,
|
|
706
|
-
`,
|
|
707
|
-
`,
|
|
708
|
-
`;}),
|
|
709
|
-
`,
|
|
710
|
-
`,
|
|
711
|
-
`;}),
|
|
712
|
-
`,
|
|
713
|
-
`,yield
|
|
693
|
+
`,i+=` * Configure Redux store with all API slices
|
|
694
|
+
`,i+=` *
|
|
695
|
+
`,i+=` * @example
|
|
696
|
+
`,i+=` * import { configureStore } from '@reduxjs/toolkit';
|
|
697
|
+
`,i+=` * import { setupApiStore } from './apis';
|
|
698
|
+
`,i+=` *
|
|
699
|
+
`,i+=` * export const store = configureStore({
|
|
700
|
+
`,i+=` * reducer: setupApiStore.reducer,
|
|
701
|
+
`,i+=` * middleware: (getDefaultMiddleware) =>
|
|
702
|
+
`,i+=` * getDefaultMiddleware().concat(setupApiStore.middleware),
|
|
703
|
+
`,i+=` * });
|
|
704
|
+
`,i+=` */
|
|
705
|
+
`,i+=`export const setupApiStore = {
|
|
706
|
+
`,i+=` reducer: {
|
|
707
|
+
`,o.forEach(n=>{let g=n.replace(/-/g,"_");i+=` [${g}Api.reducerPath]: ${g}Api.reducer,
|
|
708
|
+
`;}),i+=` },
|
|
709
|
+
`,i+=` middleware: [
|
|
710
|
+
`,o.forEach(n=>{let g=n.replace(/-/g,"_");i+=` ${g}Api.middleware,
|
|
711
|
+
`;}),i+=` ],
|
|
712
|
+
`,i+=`};
|
|
713
|
+
`,yield X(J.join(l,"apis.ts"),i,e);return}let s=`// Generated API Clients
|
|
714
714
|
`;if(s+=`// This file was auto-generated.
|
|
715
715
|
`,s+=`// Centralized client instances and configuration
|
|
716
716
|
|
|
717
|
-
`,
|
|
718
|
-
`;}):(
|
|
717
|
+
`,p==="fetch"?o.forEach(i=>{let n=i.replace(/-/g,"_");s+=`export { default as ${n}Client } from './${i}/client';
|
|
718
|
+
`;}):(o.forEach(i=>{let n=i.replace(/-/g,"_"),g=`${n.charAt(0).toUpperCase()+n.slice(1)}ApiClient`;s+=`import ${g} from './${i}/client';
|
|
719
719
|
`;}),s+=`
|
|
720
720
|
// Create client instances
|
|
721
|
-
`,
|
|
722
|
-
`;})),
|
|
721
|
+
`,o.forEach(i=>{let n=i.replace(/-/g,"_"),g=`${n.charAt(0).toUpperCase()+n.slice(1)}ApiClient`;s+=`export const ${n}Client = new ${g}();
|
|
722
|
+
`;})),p==="fetch"&&(s+=`
|
|
723
723
|
// Import clients for aggregation
|
|
724
|
-
`,
|
|
724
|
+
`,o.forEach(i=>{let n=i.replace(/-/g,"_");s+=`import ${n}_client from './${i}/client';
|
|
725
725
|
`;})),s+=`
|
|
726
726
|
// Aggregate all client instances
|
|
727
727
|
`,s+=`export const clients = {
|
|
728
|
-
`,
|
|
729
|
-
`:s+=` ${
|
|
728
|
+
`,o.forEach(i=>{let n=i.replace(/-/g,"_");p==="fetch"?s+=` ${n}: ${n}_client,
|
|
729
|
+
`:s+=` ${n}: ${n}Client,
|
|
730
730
|
`;}),s+=`};
|
|
731
731
|
|
|
732
|
-
`,
|
|
732
|
+
`,p==="axios"?(s+=`
|
|
733
733
|
/**
|
|
734
734
|
`,s+=` * Configure all API clients at once
|
|
735
735
|
`,s+=` * @param config - Configuration to apply to all clients
|
|
@@ -739,10 +739,10 @@ import { useInfiniteQuery, UseInfiniteQueryOptions } from 'react-query';
|
|
|
739
739
|
`,s+=` headers?: Record<string, string>;
|
|
740
740
|
`,s+=` timeout?: number;
|
|
741
741
|
`,s+=`}) => {
|
|
742
|
-
`,
|
|
742
|
+
`,o.forEach(i=>{let n=i.replace(/-/g,"_");s+=` ${n}Client.updateConfig(config);
|
|
743
743
|
`;}),s+=`};
|
|
744
744
|
|
|
745
|
-
`):
|
|
745
|
+
`):p==="fetch"&&(s+=`
|
|
746
746
|
/**
|
|
747
747
|
`,s+=` * Configure all API clients at once
|
|
748
748
|
`,s+=` * @param config - Configuration to apply to all clients
|
|
@@ -752,7 +752,7 @@ import { useInfiniteQuery, UseInfiniteQueryOptions } from 'react-query';
|
|
|
752
752
|
`,s+=` headers?: Record<string, string>;
|
|
753
753
|
`,s+=` auth?: { token?: string };
|
|
754
754
|
`,s+=`}) => {
|
|
755
|
-
`,
|
|
755
|
+
`,o.forEach(i=>{let n=i.replace(/-/g,"_");s+=` ${n}_client.setApiConfig(config);
|
|
756
756
|
`;}),s+=`};
|
|
757
757
|
|
|
758
758
|
`),s+=`// Example usage:
|
|
@@ -765,13 +765,13 @@ import { useInfiniteQuery, UseInfiniteQueryOptions } from 'react-query';
|
|
|
765
765
|
`,s+=`// });
|
|
766
766
|
`,s+=`//
|
|
767
767
|
`,s+=`// // Use specific client
|
|
768
|
-
`,s+=`// const data = await clients.${(t=
|
|
769
|
-
`,yield
|
|
770
|
-
`;
|
|
771
|
-
`,
|
|
768
|
+
`,s+=`// const data = await clients.${(t=o[0])==null?void 0:t.replace(/-/g,"_")}.someMethod(...);
|
|
769
|
+
`,yield X(J.join(l,"clients.ts"),s,e),p==="react-query"||p==="swr"){let i=`// Generated Hooks Aggregator
|
|
770
|
+
`;i+=`// This file was auto-generated.
|
|
771
|
+
`,i+=`// Aggregates all folder-split hooks
|
|
772
772
|
|
|
773
|
-
`,
|
|
774
|
-
`;}),
|
|
773
|
+
`,o.forEach(n=>{i+=`export * from './${n}/hooks';
|
|
774
|
+
`;}),i+=`
|
|
775
775
|
// Example usage:
|
|
776
|
-
`,
|
|
777
|
-
`,yield
|
|
776
|
+
`,i+=`// import { useGetSomething } from './hooks';
|
|
777
|
+
`,yield X(J.join(l,"hooks.ts"),i,e);}});var ke=process.cwd(),ln=()=>{let l;try{c("esbuild-register");}catch(i){throw i}let o=J.join(ke,"openapi.sync.js"),p=J.join(ke,"openapi.sync.ts"),e=J.join(ke,"openapi.sync.json"),s=[o,p,e];try{for(let i of s)ie.existsSync(i)&&(l=c(i),Object.keys(l).length===1&&l.default&&(l=l.default));}catch(i){}typeof l=="function"&&(l=l());let t=l;if(!t)throw new Error("No config found");return t},mr=l=>d(null,null,function*(){let o=ln(),p=Object.keys(o.api),e=l&&"refetchInterval"in l&&!isNaN(l==null?void 0:l.refetchInterval)?l.refetchInterval:o.refetchInterval;Me();for(let s=0;s<p.length;s+=1){let t=p[s],i=o.api[t];yield Le(i,t,o,e);}}),cr=l=>d(null,null,function*(){let o=ln(),p=l.apiName?[l.apiName]:Object.keys(o.api);for(let s of p)if(!o.api[s])throw new Error(`API "${s}" not found in configuration. Available APIs: ${Object.keys(o.api).join(", ")}`);Me();for(let s of p){let t=o.api[s];yield Le(t,s,o);}let e=(o==null?void 0:o.folder)||"api";for(let s of p){let t=nn(s);if(t.length===0){continue}`${t.length}${s}`;let i=a(a(a(a(b(a({enabled:true},o.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 an(t,o,i,s,J.join(ke,e));}}),dr=()=>d(null,null,function*(){let{interactiveInit:l}=yield import('./interactive-init-APL2JSEW.mjs');yield l();});export{cr as GenerateClient,mr as Init,dr as InteractiveInit,Ee as JSONStringify,ue as capitalize,Ht as createCustomCodeMarker,dn as extractCustomCode,Vt as getEndpointDetails,vn as getNestedValue,Kt as isJson,cn as isYamlString,qe as mergeCustomCode,ve as renderTypeRefMD,wn as variableName,Wt as variableNameChar,_t as yamlStringToJson};
|