openapi-sync 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- 'use strict';var L=require('fs'),B=require('path'),ee=require('js-yaml'),ut=require('lodash.isequal'),rt=require('lodash.get'),yt=require('axios'),ct=require('axios-retry'),ht=require('@apidevtools/swagger-parser'),curlGenerator=require('curl-generator');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var L__default=/*#__PURE__*/_interopDefault(L);var B__default=/*#__PURE__*/_interopDefault(B);var ee__namespace=/*#__PURE__*/_interopNamespace(ee);var ut__default=/*#__PURE__*/_interopDefault(ut);var rt__default=/*#__PURE__*/_interopDefault(rt);var yt__default=/*#__PURE__*/_interopDefault(yt);var ct__default=/*#__PURE__*/_interopDefault(ct);var ht__default=/*#__PURE__*/_interopDefault(ht);var X=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(i,e)=>(typeof require!="undefined"?require:i)[e]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var g=(n,i,e)=>new Promise((O,$)=>{var C=f=>{try{p(e.next(f));}catch(E){$(E);}},o=f=>{try{p(e.throw(f));}catch(E){$(E);}},p=f=>f.done?O(f.value):Promise.resolve(f.value).then(C,o);p((e=e.apply(n,i)).next());});var Ot=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Ye=/[A-Za-z0-9_$]/;var Ze=n=>["object"].includes(typeof n)&&!(n instanceof Blob),pt=n=>{try{return ee__namespace.load(n),!0}catch(i){let e=i;if(e instanceof ee__namespace.YAMLException)return false;throw e}},De=n=>{if(pt(n)){let i=ee__namespace.load(n),e=JSON.stringify(i,null,2);return JSON.parse(e)}},W=n=>n.substring(0,1).toUpperCase()+n.substring(1),He=(n,i)=>{let e=n.split("/"),O=`${W(i)}`,$=[];return e.forEach(C=>{if(C[0]==="{"&&C[C.length-1]==="}"){let p=C.replace(/{/,"").replace(/}/,"");$.push(p),C=`$${p}`;}else if(C[0]==="<"&&C[C.length-1]===">"){let p=C.replace(/</,"").replace(/>/,"");$.push(p),C=`$${p}`;}else if(C[0]===":"){let p=C.replace(/:/,"");$.push(p),C=`$${p}`;}let o="";C.split("").forEach(p=>{let f=p;Ye.test(p)||(f="/"),o+=f;}),o.split("/").forEach(p=>{O+=W(p);});}),{name:O,variables:$,pathParts:e}},_=(n,i=1)=>{let e="{",O=Object.keys(n);for(let $=0;$<O.length;$++){let C=O[$],o=n[C];if(e+=`
2
- `+" ".repeat(i)+C+": ",Array.isArray(o)){e+="[";for(let p=0;p<o.length;p++){let f=o[p];typeof f=="object"&&f!==null?e+=_(f,i+1):e+=typeof f=="string"?`"${f}"`:f,p<o.length-1&&(e+=", ");}e+="]";}else typeof o=="object"&&o!==null?e+=""+_(o,i+1):e+=o.split(`
1
+ 'use strict';var z=require('fs'),F=require('path'),te=require('js-yaml'),ut=require('lodash.isequal'),st=require('lodash.get'),yt=require('axios'),ct=require('axios-retry'),ht=require('@apidevtools/swagger-parser'),curlGenerator=require('curl-generator');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var z__default=/*#__PURE__*/_interopDefault(z);var F__default=/*#__PURE__*/_interopDefault(F);var te__namespace=/*#__PURE__*/_interopNamespace(te);var ut__default=/*#__PURE__*/_interopDefault(ut);var st__default=/*#__PURE__*/_interopDefault(st);var yt__default=/*#__PURE__*/_interopDefault(yt);var ct__default=/*#__PURE__*/_interopDefault(ct);var ht__default=/*#__PURE__*/_interopDefault(ht);var X=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(i,e)=>(typeof require!="undefined"?require:i)[e]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var _=(n,i,e)=>new Promise((O,$)=>{var I=f=>{try{p(e.next(f));}catch(x){$(x);}},o=f=>{try{p(e.throw(f));}catch(x){$(x);}},p=f=>f.done?O(f.value):Promise.resolve(f.value).then(I,o);p((e=e.apply(n,i)).next());});var Ot=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Qe=/[A-Za-z0-9_$]/;var ge=n=>["object"].includes(typeof n)&&!(n instanceof Blob),pt=n=>{try{return te__namespace.load(n),!0}catch(i){let e=i;if(e instanceof te__namespace.YAMLException)return false;throw e}},De=n=>{if(pt(n)){let i=te__namespace.load(n),e=JSON.stringify(i,null,2);return JSON.parse(e)}},W=n=>n.substring(0,1).toUpperCase()+n.substring(1),He=(n,i)=>{let e=n.split("/"),O=`${W(i)}`,$=[];return e.forEach(I=>{if(I[0]==="{"&&I[I.length-1]==="}"){let p=I.replace(/{/,"").replace(/}/,"");$.push(p),I=`$${p}`;}else if(I[0]==="<"&&I[I.length-1]===">"){let p=I.replace(/</,"").replace(/>/,"");$.push(p),I=`$${p}`;}else if(I[0]===":"){let p=I.replace(/:/,"");$.push(p),I=`$${p}`;}let o="";I.split("").forEach(p=>{let f=p;Qe.test(p)||(f="/"),o+=f;}),o.split("/").forEach(p=>{O+=W(p);});}),{name:O,variables:$,pathParts:e}},ee=(n,i=1)=>{let e="{",O=Object.keys(n);for(let $=0;$<O.length;$++){let I=O[$],o=n[I];if(e+=`
2
+ `+" ".repeat(i)+I+": ",Array.isArray(o)){e+="[";for(let p=0;p<o.length;p++){let f=o[p];typeof f=="object"&&f!==null?e+=ee(f,i+1):e+=typeof f=="string"?`"${f}"`:f,p<o.length-1&&(e+=", ");}e+="]";}else typeof o=="object"&&o!==null?e+=""+ee(o,i+1):e+=o.split(`
3
3
  `).filter(p=>p.trim()!=="").join(`
4
4
  ${" ".repeat(i)}`);$<O.length-1&&(e+=", ");}return e+=`
5
5
  ${" ".repeat(i-1)}}`,e},le=(n,i=1)=>`
@@ -7,59 +7,60 @@ ${" ".repeat(i-1)}}`,e},le=(n,i=1)=>`
7
7
  ${" ".repeat(i)} ${n.split(`
8
8
  `).filter(e=>e.trim()!=="").join(`
9
9
  ${" ".repeat(i)} `)}
10
- \`\`\``;function xt(n,i){return i.split(".").reduce((O,$)=>O&&O[$]!==void 0?O[$]:void 0,n)}var dt=(n,i="CUSTOM CODE")=>{let e=`// \u{1F512} ${i} START`,O=`// \u{1F512} ${i} END`,$={beforeGenerated:"",afterGenerated:""},C=0,o=[];for(;C<n.length;){let p=n.indexOf(e,C);if(p===-1)break;let f=n.indexOf(O,p);if(f===-1)break;let E=f+O.length,k=p,ne=n.substring(Math.max(0,p-200),p).lastIndexOf("// ==========");ne!==-1&&(k=Math.max(0,p-200)+ne);let oe=n.substring(k,E);o.push({start:k,end:E,content:oe}),C=E;}return o.length>0&&(n.substring(0,o[0].start).split(`
11
- `).filter(E=>{let k=E.trim();return k.length>0&&!k.startsWith("//")}).join("").length===0?($.beforeGenerated=o[0].content,o.length>1&&($.afterGenerated=o[1].content)):($.afterGenerated=o[0].content,o.length>1&&!$.beforeGenerated&&($.beforeGenerated=o[1].content))),$},Qe=(n,i="CUSTOM CODE",e=true)=>{let O=e?`// ${n==="top"?"Add your custom code below this line":"Add your custom code above this line"}
10
+ \`\`\``;function xt(n,i){return i.split(".").reduce((O,$)=>O&&O[$]!==void 0?O[$]:void 0,n)}var dt=(n,i="CUSTOM CODE")=>{let e=`// \u{1F512} ${i} START`,O=`// \u{1F512} ${i} END`,$={beforeGenerated:"",afterGenerated:""},I=0,o=[];for(;I<n.length;){let p=n.indexOf(e,I);if(p===-1)break;let f=n.indexOf(O,p);if(f===-1)break;let x=f+O.length,B=n.substring(x,x+100),R=B.match(/^\s*\n\s*(\/\/ =+)/);if(R){let oe=B.indexOf(`
11
+ `,R.index+1);oe!==-1?x+=oe+1:x+=R[0].length;}let Q=p,M=n.substring(Math.max(0,p-200),p).lastIndexOf("// ==========");M!==-1&&(Q=Math.max(0,p-200)+M);let U=n.substring(Q,x);o.push({start:Q,end:x,content:U}),I=x;}return o.length>0&&(n.substring(0,o[0].start).split(`
12
+ `).filter(x=>{let B=x.trim();return B.length>0&&!B.startsWith("//")}).join("").length===0?($.beforeGenerated=o[0].content,o.length>1&&($.afterGenerated=o[1].content)):($.afterGenerated=o[0].content,o.length>1&&!$.beforeGenerated&&($.beforeGenerated=o[1].content))),$},Ze=(n,i="CUSTOM CODE",e=true)=>{let O=e?`// ${n==="top"?"Add your custom code below this line":"Add your custom code above this line"}
12
13
  // This section will be preserved during regeneration
13
14
  `:"";return `// ${"=".repeat(60)}
14
15
  // \u{1F512} ${i} START
15
16
  ${O}// ${"=".repeat(60)}
16
17
 
17
18
  // \u{1F512} ${i} END
18
- // ${"=".repeat(60)}`},Xe=(n,i,e={})=>{let{position:O="bottom",markerText:$="CUSTOM CODE",includeInstructions:C=true}=e,o={beforeGenerated:"",afterGenerated:""};i&&(o=dt(i,$)),!o.beforeGenerated&&!o.afterGenerated&&((O==="top"||O==="both")&&(o.beforeGenerated=Qe("top",$,C)),(O==="bottom"||O==="both")&&(o.afterGenerated=Qe("bottom",$,C)));let p=[];return o.beforeGenerated&&(p.push(o.beforeGenerated),p.push("")),p.push(n),o.afterGenerated&&(p.push(""),p.push(o.afterGenerated)),p.join(`
19
- `)};var pe=B__default.default.join(__dirname,"../","../db.json");L__default.default.existsSync(pe)||L__default.default.writeFileSync(pe,"{}");var ue={};try{ue=X(pe);}catch(n){ue={};}var te=ue||{},ge=n=>{L__default.default.writeFileSync(pe,JSON.stringify(n));},_e=(n,i)=>{te[n]=i,ge(te);},et=n=>te[n],tt=()=>{te={},ge(te);};var re=process.cwd(),ye={},st=yt__default.default.create({timeout:6e4});ct__default.default(st,{retries:20,retryCondition:n=>n.code==="ECONNABORTED"||n.message.includes("Network Error"),retryDelay:n=>n*1e3});var se=(n,i,e)=>g(null,null,function*(){var o,p,f,E;if(!(((o=e==null?void 0:e.customCode)==null?void 0:o.enabled)!==false)){yield L__default.default.promises.writeFile(n,i);return}let $=null;try{$=yield L__default.default.promises.readFile(n,"utf-8");}catch(k){}let C=Xe(i,$,{position:((p=e==null?void 0:e.customCode)==null?void 0:p.position)||"bottom",markerText:(f=e==null?void 0:e.customCode)==null?void 0:f.markerText,includeInstructions:(E=e==null?void 0:e.customCode)==null?void 0:E.includeInstructions});yield L__default.default.promises.writeFile(n,C);}),nt=(n,i,e,O)=>g(null,null,function*(){var fe,be,Oe,Ce,Ie,xe;let $=yield st.get(n),C=Ze($.data)?$.data:De($.data),o;try{o=yield ht__default.default.parse(C);}catch(s){let r=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse OpenAPI spec for ${i}: ${r}`)}let p=B__default.default.join((e==null?void 0:e.folder)||"",i),f={},E=s=>{var r,x;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let b=e.folderSplit.customFolder(s);if(console.log("customFolder",b),b)return b}return (x=e==null?void 0:e.folderSplit)!=null&&x.byTags&&s.tags&&s.tags.length>0?s.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},k=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((be=(fe=o==null?void 0:o.servers)==null?void 0:fe[(e==null?void 0:e.server)||0])==null?void 0:be.url)||"",M=typeof((Ce=(Oe=e==null?void 0:e.types)==null?void 0:Oe.name)==null?void 0:Ce.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",ne=typeof((xe=(Ie=e==null?void 0:e.endpoints)==null?void 0:Ie.name)==null?void 0:xe.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",oe=(s,r)=>{var b,a;let x=W(s);if((a=(b=e==null?void 0:e.types)==null?void 0:b.name)!=null&&a.format){let m=e==null?void 0:e.types.name.format("shared",{name:s},x);if(m)return `${M}${m}`}return `${M}${x}`},q=(s,r,x,b,a,m=0)=>{let I="",l="",d="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let u=(r.$ref||"").split("/");u.shift(),[...u].pop();let w=rt__default.default(s,u,null);if(w){w!=null&&w.name&&(I=w.name),l=u[u.length-1];let N=oe(l);N.includes(".")&&(N=N.split(".").map((U,K)=>K===0?U:`["${U}"]`).join("")),d+=`${a!=null&&a.noSharedImport?"":"Shared."}${N}`;}}else d+="";else if(r.anyOf)d+=`(${r.anyOf.map(u=>q(s,u,"",b,a)).filter(u=>!!u).join("|")})`;else if(r.oneOf)d+=`(${r.oneOf.map(u=>q(s,u,"",b,a)).filter(u=>!!u).join("|")})`;else if(r.allOf)d+=`(${r.allOf.map(u=>q(s,u,"",b,a)).filter(u=>!!u).join("&")})`;else if(r.items)d+=`${q(s,r.items,"",false,a)}[]`;else if(r.properties){let u=Object.keys(r.properties),j=r.required||[],S="";u.forEach(w=>{var Z,U,K,Y,ae,D;let N="";!((U=(Z=e==null?void 0:e.types)==null?void 0:Z.doc)!=null&&U.disable)&&((Y=(K=r.properties)==null?void 0:K[w])!=null&&Y.description)&&(N=" * "+((ae=r.properties)==null?void 0:ae[w].description.split(`
19
+ // ${"=".repeat(60)}`},Xe=(n,i,e={})=>{let{position:O="bottom",markerText:$="CUSTOM CODE",includeInstructions:I=true}=e,o={beforeGenerated:"",afterGenerated:""};i&&(o=dt(i,$)),!o.beforeGenerated&&!o.afterGenerated&&((O==="top"||O==="both")&&(o.beforeGenerated=Ze("top",$,I)),(O==="bottom"||O==="both")&&(o.afterGenerated=Ze("bottom",$,I)));let p=[];return o.beforeGenerated&&(p.push(o.beforeGenerated),p.push("")),p.push(n),o.afterGenerated&&(p.push(""),p.push(o.afterGenerated)),p.join(`
20
+ `)};var pe=F__default.default.join(__dirname,"../","../db.json");z__default.default.existsSync(pe)||z__default.default.writeFileSync(pe,"{}");var ye={};try{ye=X(pe);}catch(n){ye={};}var re=ye||{},_e=n=>{z__default.default.writeFileSync(pe,JSON.stringify(n));},et=(n,i)=>{re[n]=i,_e(re);},tt=n=>re[n],rt=()=>{re={},_e(re);};var se=process.cwd(),ce={},nt=yt__default.default.create({timeout:6e4});ct__default.default(nt,{retries:20,retryCondition:n=>n.code==="ECONNABORTED"||n.message.includes("Network Error"),retryDelay:n=>n*1e3});var ne=(n,i,e)=>_(null,null,function*(){var o,p,f,x;if(!(((o=e==null?void 0:e.customCode)==null?void 0:o.enabled)!==false)){yield z__default.default.promises.writeFile(n,i);return}let $=null;try{$=yield z__default.default.promises.readFile(n,"utf-8");}catch(B){}let I=Xe(i,$,{position:((p=e==null?void 0:e.customCode)==null?void 0:p.position)||"bottom",markerText:(f=e==null?void 0:e.customCode)==null?void 0:f.markerText,includeInstructions:(x=e==null?void 0:e.customCode)==null?void 0:x.includeInstructions});yield z__default.default.promises.writeFile(n,I);}),ot=(n,i,e,O)=>_(null,null,function*(){var be,Oe,Ie,Ce,xe,je;let $=yield nt.get(n),I=ge($.data)?$.data:De($.data),o;try{o=yield ht__default.default.parse(I);}catch(s){let r=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse OpenAPI spec for ${i}: ${r}`)}let p=F__default.default.join((e==null?void 0:e.folder)||"",i),f={},x=s=>{var r,j;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let b=e.folderSplit.customFolder(s);if(console.log("customFolder",b),b)return b}return (j=e==null?void 0:e.folderSplit)!=null&&j.byTags&&s.tags&&s.tags.length>0?s.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},B=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((Oe=(be=o==null?void 0:o.servers)==null?void 0:be[(e==null?void 0:e.server)||0])==null?void 0:Oe.url)||"",R=typeof((Ce=(Ie=e==null?void 0:e.types)==null?void 0:Ie.name)==null?void 0:Ce.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",Q=typeof((je=(xe=e==null?void 0:e.endpoints)==null?void 0:xe.name)==null?void 0:je.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",de=(s,r)=>{var b,a;let j=W(s);if((a=(b=e==null?void 0:e.types)==null?void 0:b.name)!=null&&a.format){let m=e==null?void 0:e.types.name.format("shared",{name:s},j);if(m)return `${R}${m}`}return `${R}${j}`},M=(s,r,j,b,a,m=0)=>{let C="",l="",d="";if(r)if(r.$ref)if(r.$ref[0]==="#"){let u=(r.$ref||"").split("/");u.shift(),[...u].pop();let w=st__default.default(s,u,null);if(w){w!=null&&w.name&&(C=w.name),l=u[u.length-1];let N=de(l);N.includes(".")&&(N=N.split(".").map((J,K)=>K===0?J:`["${J}"]`).join("")),d+=`${a!=null&&a.noSharedImport?"":"Shared."}${N}`;}}else d+="";else if(r.anyOf)d+=`(${r.anyOf.map(u=>M(s,u,"",b,a)).filter(u=>!!u).join("|")})`;else if(r.oneOf)d+=`(${r.oneOf.map(u=>M(s,u,"",b,a)).filter(u=>!!u).join("|")})`;else if(r.allOf)d+=`(${r.allOf.map(u=>M(s,u,"",b,a)).filter(u=>!!u).join("&")})`;else if(r.items)d+=`${M(s,r.items,"",false,a)}[]`;else if(r.properties){let u=Object.keys(r.properties),E=r.required||[],S="";u.forEach(w=>{var g,J,K,Y,ae,D;let N="";!((J=(g=e==null?void 0:e.types)==null?void 0:g.doc)!=null&&J.disable)&&((Y=(K=r.properties)==null?void 0:K[w])!=null&&Y.description)&&(N=" * "+((ae=r.properties)==null?void 0:ae[w].description.split(`
20
21
  `).filter(ie=>ie.trim()!=="").join(`
21
22
  *${" ".repeat(1)}`))),S+=(N?`/**
22
23
  ${N}
23
24
  */
24
- `:"")+`${q(s,(D=r.properties)==null?void 0:D[w],w,j.includes(w),a,m+1)}`;}),S.length>0?d+=`{
25
- ${" ".repeat(m)}${S}${" ".repeat(m)}}`:d+="{[k: string]: any}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(d+="("),r.enum.map(u=>JSON.stringify(u)).filter(u=>!!u).forEach((u,j)=>{d+=`${j===0?"":"|"}${u}`;}),r.enum.length>1&&(d+=")");else if(r.type){let u=j=>{let S="";if(typeof j=="string")["string","integer","number","array","boolean","null"].includes(j)?["integer","number"].includes(j)?S+="number":j==="array"?S+="any[]":S+=j:j==="object"&&(r.additionalProperties?S+=`{[k: string]: ${q(s,r.additionalProperties,"",true,a)||"any"}}`:S+="{[k: string]: any}");else if(Array.isArray(j)){let w=j.map(N=>u(N));w.filter(N=>N!==""),w.length>1&&(S+="("+w.join("|")+")");}else S+="any";return S};d=u(r.type);}}else d="string";let c=I||x;a!=null&&a.useComponentName&&!c&&(c=l);let T=c?` "${c}"${b?"":"?"}: `:"",t=r!=null&&r.nullable?" | null":"";return d.length>0?`${T}${d}${t}${c?`;
26
- `:""}`:""},z=(s,r)=>{let a="";if(r)if(r.$ref)if(r.$ref[0]==="#"){let m=(r.$ref||"").split("/");m.shift();let l=rt__default.default(s,m,null);l&&(l!=null&&l.name&&(l.name),m[m.length-1],a+=z(s,l));}else a+="";else if(r.anyOf)a+=z(s,r.anyOf[0]);else if(r.oneOf)a+=z(s,r.oneOf[0]);else if(r.allOf)a+=`{${r.allOf.map(m=>`...(${z(s,m)})`).join(",")}}`;else if(r.items)a+=`[${z(s,r.items)}]`;else if(r.properties){let l=Object.keys(r.properties).map(d=>{var c;return ` "${d}": ${z(s,(c=r.properties)==null?void 0:c[d])}`}).join(`,
25
+ `:"")+`${M(s,(D=r.properties)==null?void 0:D[w],w,E.includes(w),a,m+1)}`;}),S.length>0?d+=`{
26
+ ${" ".repeat(m)}${S}${" ".repeat(m)}}`:d+="{[k: string]: any}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(d+="("),r.enum.map(u=>JSON.stringify(u)).filter(u=>!!u).forEach((u,E)=>{d+=`${E===0?"":"|"}${u}`;}),r.enum.length>1&&(d+=")");else if(r.type){let u=E=>{let S="";if(typeof E=="string")["string","integer","number","array","boolean","null"].includes(E)?["integer","number"].includes(E)?S+="number":E==="array"?S+="any[]":S+=E:E==="object"&&(r.additionalProperties?S+=`{[k: string]: ${M(s,r.additionalProperties,"",true,a)||"any"}}`:S+="{[k: string]: any}");else if(Array.isArray(E)){let w=E.map(N=>u(N));w.filter(N=>N!==""),w.length>1&&(S+="("+w.join("|")+")");}else S+="any";return S};d=u(r.type);}else d+="any";else d="string";let c=C||j;a!=null&&a.useComponentName&&!c&&(c=l);let T=c?` "${c}"${b?"":"?"}: `:"",t=r!=null&&r.nullable?" | null":"";return d.length>0?`${T}${d}${t}${c?`;
27
+ `:""}`:""},U=(s,r)=>{let a="";if(r)if(r.$ref)if(r.$ref[0]==="#"){let m=(r.$ref||"").split("/");m.shift();let l=st__default.default(s,m,null);l&&(l!=null&&l.name&&(l.name),m[m.length-1],a+=U(s,l));}else a+="";else if(r.anyOf)a+=U(s,r.anyOf[0]);else if(r.oneOf)a+=U(s,r.oneOf[0]);else if(r.allOf)a+=`{${r.allOf.map(m=>`...(${U(s,m)})`).join(",")}}`;else if(r.items)a+=`[${U(s,r.items)}]`;else if(r.properties){let l=Object.keys(r.properties).map(d=>{var c;return ` "${d}": ${U(s,(c=r.properties)==null?void 0:c[d])}`}).join(`,
27
28
  `);l.length>0?a+=`{
28
29
  ${l}
29
- }`:a+="{}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(a+=r.enum[0]);else if(r.type)if(r.example)a+=JSON.stringify(r.example);else {let m=I=>{let l="";if(typeof I=="string")["string","integer","number","array","boolean","null"].includes(I)?["integer","number"].includes(I)?l+="123":I==="array"?l+="[]":I==="boolean"?l+="true":I==="null"?l+="null":l+=`"${I}"`:I==="object"&&(l+="{}");else if(Array.isArray(I)){let d=I.map(c=>m(c));d.filter(c=>c!==""),d.length>1&&(l+=d.join("|"));}else l+="any";return l};a=m(r.type);}else a+="any";else a="string";return a};O&&!isNaN(O)&&O>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(ye[i]&&clearTimeout(ye[i]),ye[i]=setTimeout(()=>nt(n,i,e,O),O)));let at=et(i);if(ut__default.default(at,o))return;_e(i,o);let de="",Q="",V={};o.components&&Object.keys(o.components).forEach(s=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(s)){let r=o.components[s],x={},b={};Object.keys(r).forEach(m=>{var d;let I=(d=r[m])!=null&&d.schema?r[m].schema:r[m],l=`${q(o,I,"",true,{noSharedImport:true,useComponentName:["parameters"].includes(s)})}`;if(l){let c=m.split("."),T=x,t=b;for(let u=0;u<c.length;u++){let j=c[u];u<c.length-1?(j in T||(T[j]={},t[j]={}),T=T[j],t=t[j]):(T[j]=l,t[j]=I);}}}),Object.keys(x).forEach(m=>{var c,T,t,u;let I=oe(m),l=x[m],d="";!((T=(c=e==null?void 0:e.types)==null?void 0:c.doc)!=null&&T.disable)&&m in r&&((t=r[m])!=null&&t.description)&&(d=" * "+r[m].description.split(`
30
- `).filter(j=>j.trim()!=="").join(`
30
+ }`:a+="{}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(a+=r.enum[0]);else if(r.type)if(r.example)a+=JSON.stringify(r.example);else {let m=C=>{let l="";if(typeof C=="string")["string","integer","number","array","boolean","null"].includes(C)?["integer","number"].includes(C)?l+="123":C==="array"?l+="[]":C==="boolean"?l+="true":C==="null"?l+="null":l+=`"${C}"`:C==="object"&&(l+="{}");else if(Array.isArray(C)){let d=C.map(c=>m(c));d.filter(c=>c!==""),d.length>1&&(l+=d.join("|"));}else l+="any";return l};a=m(r.type);}else a+="any";else a="string";return a};O&&!isNaN(O)&&O>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(ce[i]&&clearTimeout(ce[i]),ce[i]=setTimeout(()=>ot(n,i,e,O),O)));let oe=tt(i);if(ut__default.default(oe,o))return;et(i,o);let me="",Z="",V={};o.components&&Object.keys(o.components).forEach(s=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(s)){let r=o.components[s],j={},b={};Object.keys(r).forEach(m=>{var d;let C=(d=r[m])!=null&&d.schema?r[m].schema:r[m],l=`${M(o,C,"",true,{noSharedImport:true,useComponentName:["parameters"].includes(s)})}`;if(l){let c=m.split("."),T=j,t=b;for(let u=0;u<c.length;u++){let E=c[u];u<c.length-1?(E in T||(T[E]={},t[E]={}),T=T[E],t=t[E]):(T[E]=l,t[E]=C);}}}),Object.keys(j).forEach(m=>{var c,T,t,u;let C=de(m),l=j[m],d="";!((T=(c=e==null?void 0:e.types)==null?void 0:c.doc)!=null&&T.disable)&&m in r&&((t=r[m])!=null&&t.description)&&(d=" * "+r[m].description.split(`
31
+ `).filter(E=>E.trim()!=="").join(`
31
32
  *${" ".repeat(1)}`)),V[m]=((u=V[m])!=null?u:"")+(d?`/**
32
33
  ${d}
33
34
  */
34
- `:"")+"export type "+I+" = "+(typeof l=="string"?l:_(l))+`;
35
- `;});}});let $e=s=>{let r="";if(s.content){let x=Object.keys(s.content);x[0]&&s.content[x[0]].schema&&(r+=`${q(o,s.content[x[0]].schema,"")}`);}return r},it=s=>{var r,x,b,a,m;if((x=(r=e==null?void 0:e.endpoints)==null?void 0:r.value)!=null&&x.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let I=s;return (m=(a=(b=e==null?void 0:e.endpoints)==null?void 0:b.value)==null?void 0:a.replaceWords)==null||m.forEach((l,d)=>{let c=new RegExp(l.replace,"g");I=I.replace(c,l.with||"");}),I}else return s},lt=(s,r,x=[])=>{var m,I;let b=(m=e==null?void 0:e.endpoints)==null?void 0:m.exclude,a=(I=e==null?void 0:e.endpoints)==null?void 0:I.include;if(a){let l=a.tags&&a.tags.length>0?x.some(c=>a.tags.includes(c)):true,d=a.endpoints&&a.endpoints.length>0?a.endpoints.some(c=>{let T=!c.method||c.method.toLowerCase()===r.toLowerCase();return c.path?s===c.path&&T:c.regex?new RegExp(c.regex).test(s)&&T:false}):true;if(!l||!d)return true}return !!(b&&(b.tags&&b.tags.length>0&&x.some(d=>b.tags.includes(d))||b.endpoints&&b.endpoints.length>0&&b.endpoints.some(d=>{let c=!d.method||d.method.toLowerCase()===r.toLowerCase();return d.path?s===d.path&&c:d.regex?new RegExp(d.regex).test(s)&&c:false})))};if(Object.keys(o.paths||{}).forEach(s=>{let r=o.paths[s];Object.keys(r).forEach(b=>{var ie,je,Ee,Ae,Te,Se,we,Ne,ve,Re,ke,Be,Me,Fe,Ge,Pe,qe,Ue,Je,Le,ze,Ke,We,Ve;let a=b,m=He(s,a),I=((ie=r[a])==null?void 0:ie.tags)||[];if(lt(s,a,I))return;let l=r[a],d=E({method:a,path:s,summary:l==null?void 0:l.summary,operationId:l==null?void 0:l.operationId,tags:I,parameters:l==null?void 0:l.parameters,requestBody:l==null?void 0:l.requestBody,responses:l==null?void 0:l.responses});f[d]||(f[d]={endpoints:"",types:""});let c=((Ee=(je=e==null?void 0:e.endpoints)==null?void 0:je.value)!=null&&Ee.includeServer?k:"")+m.pathParts.map(h=>(h[0]==="{"&&h[h.length-1]==="}"?h=`\${${h.replace(/{/,"").replace(/}/,"")}}`:h[0]==="<"&&h[h.length-1]===">"?h=`\${${h.replace(/</,"").replace(/>/,"")}}`:h[0]===":"&&(h=`\${${h.replace(/:/,"")}}`),h)).join("/"),T=`"${c}"`;m.variables.length>0&&(T=`(${m.variables.map(y=>`${y}:string`).join(",")})=> \`${c}\``),T=it(T);let t=r[a],u="";if(t!=null&&t.parameters&&((t==null?void 0:t.parameters).forEach((y,v)=>{(y.$ref||y.in==="query"&&y.name)&&(u+=`${q(o,y.$ref?y:y.schema,y.name||"",y.required)}`);}),u)){u=`{
36
- ${u}}`;let y=`${m.name}Query`;if((Te=(Ae=e==null?void 0:e.types)==null?void 0:Ae.name)!=null&&Te.useOperationId&&(t!=null&&t.operationId)&&(y=`${t.operationId}Query`),y=W(`${M}${y}`),(we=(Se=e==null?void 0:e.types)==null?void 0:Se.name)!=null&&we.format){let G=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"query",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},y);G&&(y=`${M}${G}`);}let v=`export type ${y} = ${u};
37
- `;e!=null&&e.folderSplit?f[d].types+=v:Q+=v;}let j=t==null?void 0:t.requestBody,S="";if(j&&(S=$e(j),S)){let h=`${m.name}DTO`;if((ve=(Ne=e==null?void 0:e.types)==null?void 0:Ne.name)!=null&&ve.useOperationId&&(t!=null&&t.operationId)&&(h=`${t.operationId}DTO`),h=W(`${M}${h}`),(ke=(Re=e==null?void 0:e.types)==null?void 0:Re.name)!=null&&ke.format){let v=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"dto",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},h);v&&(h=`${M}${v}`);}let y=`export type ${h} = ${S};
38
- `;e!=null&&e.folderSplit?f[d].types+=y:Q+=y;}let w={},N="";if(t!=null&&t.responses){let h=t==null?void 0:t.responses;Object.keys(h).forEach(v=>{var G,P,R,F;if(N=$e(h[v]),w[v]=N,N){let A=`${m.name}${v}Response`;if((P=(G=e==null?void 0:e.types)==null?void 0:G.name)!=null&&P.useOperationId&&(t!=null&&t.operationId)&&(A=`${t.operationId}${v}Response`),A=W(`${M}${A}`),(F=(R=e==null?void 0:e.types)==null?void 0:R.name)!=null&&F.format){let H=e==null?void 0:e.types.name.format("endpoint",{code:v,type:"response",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},A);H&&(A=`${M}${H}`);}let J=`export type ${A} = ${N};
39
- `;e!=null&&e.folderSplit?f[d].types+=J:Q+=J;}});}let Z=h=>!h||!h.length?"":h.map(y=>Object.entries(y).map(([G,P])=>{let R=G,F="";return Array.isArray(P)&&P.length&&(F=`
40
- - Scopes: [\`${P.join("`, `")}\`]`,R=`**${R}**`),`
41
- - ${R}${F}`}).join("")).join(`
42
- `),U=t!=null&&t.security?Z(t.security):"",K="";if(!((Me=(Be=e==null?void 0:e.endpoints)==null?void 0:Be.doc)!=null&&Me.disable)){let h="";if((Ge=(Fe=e==null?void 0:e.endpoints)==null?void 0:Fe.doc)!=null&&Ge.showCurl){let y={},v="",G="";(Pe=t.requestBody)!=null&&Pe.content&&Object.keys(t.requestBody.content).forEach(F=>{let A=t.requestBody.content[F].schema;if(A){Array.isArray(y["Content-type"])?y["Content-type"].push(F):y["Content-type"]=[F];let J=z(o,A);J&&(v=J);}}),t!=null&&t.security&&t.security.forEach(R=>{Object.keys(R).forEach(F=>{var J,H;let A=(H=(J=o.components)==null?void 0:J.securitySchemes)==null?void 0:H[F];A&&(A.type==="mutualTLS"?G+=`
43
- --cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:A.type==="apiKey"?y[(A==null?void 0:A.name)||"X-API-KEY"]="{API_KEY_VALUE}":y.Authorization=`${(A==null?void 0:A.scheme)==="basic"?"Basic":"Bearer"} {${(A==null?void 0:A.scheme)==="basic"?"VALUE":"TOKEN"}}`);});});let P={};Object.keys(y).forEach(R=>{Array.isArray(y[R])?P[R]=y[R].join("; "):P[R]=y[R];}),h=`
35
+ `:"")+"export type "+C+" = "+(typeof l=="string"?l:ee(l))+`;
36
+ `;});}});let fe=s=>{let r="";if(s.content){let j=Object.keys(s.content);j[0]&&s.content[j[0]].schema&&(r+=`${M(o,s.content[j[0]].schema,"")}`);}return r},it=s=>{var r,j,b,a,m;if((j=(r=e==null?void 0:e.endpoints)==null?void 0:r.value)!=null&&j.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let C=s;return (m=(a=(b=e==null?void 0:e.endpoints)==null?void 0:b.value)==null?void 0:a.replaceWords)==null||m.forEach((l,d)=>{let c=new RegExp(l.replace,"g");C=C.replace(c,l.with||"");}),C}else return s},lt=(s,r,j=[])=>{var m,C;let b=(m=e==null?void 0:e.endpoints)==null?void 0:m.exclude,a=(C=e==null?void 0:e.endpoints)==null?void 0:C.include;if(a){let l=a.tags&&a.tags.length>0?j.some(c=>a.tags.includes(c)):true,d=a.endpoints&&a.endpoints.length>0?a.endpoints.some(c=>{let T=!c.method||c.method.toLowerCase()===r.toLowerCase();return c.path?s===c.path&&T:c.regex?new RegExp(c.regex).test(s)&&T:false}):true;if(!l||!d)return true}return !!(b&&(b.tags&&b.tags.length>0&&j.some(d=>b.tags.includes(d))||b.endpoints&&b.endpoints.length>0&&b.endpoints.some(d=>{let c=!d.method||d.method.toLowerCase()===r.toLowerCase();return d.path?s===d.path&&c:d.regex?new RegExp(d.regex).test(s)&&c:false})))};if(Object.keys(o.paths||{}).forEach(s=>{let r=o.paths[s];Object.keys(r).forEach(b=>{var ie,Ee,Ae,Te,Se,we,Ne,ke,ve,Re,Be,Me,Fe,Ge,Pe,qe,Ue,Je,Le,ze,Ke,We,Ve,Ye;let a=b,m=He(s,a),C=((ie=r[a])==null?void 0:ie.tags)||[];if(lt(s,a,C))return;let l=r[a],d=x({method:a,path:s,summary:l==null?void 0:l.summary,operationId:l==null?void 0:l.operationId,tags:C,parameters:l==null?void 0:l.parameters,requestBody:l==null?void 0:l.requestBody,responses:l==null?void 0:l.responses});f[d]||(f[d]={endpoints:"",types:""});let c=((Ae=(Ee=e==null?void 0:e.endpoints)==null?void 0:Ee.value)!=null&&Ae.includeServer?B:"")+m.pathParts.map(h=>(h[0]==="{"&&h[h.length-1]==="}"?h=`\${${h.replace(/{/,"").replace(/}/,"")}}`:h[0]==="<"&&h[h.length-1]===">"?h=`\${${h.replace(/</,"").replace(/>/,"")}}`:h[0]===":"&&(h=`\${${h.replace(/:/,"")}}`),h)).join("/"),T=`"${c}"`;m.variables.length>0&&(T=`(${m.variables.map(y=>`${y}:string`).join(",")})=> \`${c}\``),T=it(T);let t=r[a],u="";if(t!=null&&t.parameters&&((t==null?void 0:t.parameters).forEach((y,k)=>{(y.$ref||y.in==="query"&&y.name)&&(u+=`${M(o,y.$ref?y:y.schema,y.name||"",y.required)}`);}),u)){u=`{
37
+ ${u}}`;let y=`${m.name}Query`;if((Se=(Te=e==null?void 0:e.types)==null?void 0:Te.name)!=null&&Se.useOperationId&&(t!=null&&t.operationId)&&(y=`${t.operationId}Query`),y=W(`${R}${y}`),(Ne=(we=e==null?void 0:e.types)==null?void 0:we.name)!=null&&Ne.format){let P=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"query",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},y);P&&(y=`${R}${P}`);}let k=`export type ${y} = ${u};
38
+ `;e!=null&&e.folderSplit?f[d].types+=k:Z+=k;}let E=t==null?void 0:t.requestBody,S="";if(E&&(S=fe(E),S)){let h=`${m.name}DTO`;if((ve=(ke=e==null?void 0:e.types)==null?void 0:ke.name)!=null&&ve.useOperationId&&(t!=null&&t.operationId)&&(h=`${t.operationId}DTO`),h=W(`${R}${h}`),(Be=(Re=e==null?void 0:e.types)==null?void 0:Re.name)!=null&&Be.format){let k=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"dto",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},h);k&&(h=`${R}${k}`);}let y=`export type ${h} = ${S};
39
+ `;e!=null&&e.folderSplit?f[d].types+=y:Z+=y;}let w={},N="";if(t!=null&&t.responses){let h=t==null?void 0:t.responses;Object.keys(h).forEach(k=>{var P,q,v,G;if(N=fe(h[k]),w[k]=N,N){let A=`${m.name}${k}Response`;if((q=(P=e==null?void 0:e.types)==null?void 0:P.name)!=null&&q.useOperationId&&(t!=null&&t.operationId)&&(A=`${t.operationId}${k}Response`),A=W(`${R}${A}`),(G=(v=e==null?void 0:e.types)==null?void 0:v.name)!=null&&G.format){let H=e==null?void 0:e.types.name.format("endpoint",{code:k,type:"response",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},A);H&&(A=`${R}${H}`);}let L=`export type ${A} = ${N};
40
+ `;e!=null&&e.folderSplit?f[d].types+=L:Z+=L;}});}let g=h=>!h||!h.length?"":h.map(y=>Object.entries(y).map(([P,q])=>{let v=P,G="";return Array.isArray(q)&&q.length&&(G=`
41
+ - Scopes: [\`${q.join("`, `")}\`]`,v=`**${v}**`),`
42
+ - ${v}${G}`}).join("")).join(`
43
+ `),J=t!=null&&t.security?g(t.security):"",K="";if(!((Fe=(Me=e==null?void 0:e.endpoints)==null?void 0:Me.doc)!=null&&Fe.disable)){let h="";if((Pe=(Ge=e==null?void 0:e.endpoints)==null?void 0:Ge.doc)!=null&&Pe.showCurl){let y={},k="",P="";(qe=t.requestBody)!=null&&qe.content&&Object.keys(t.requestBody.content).forEach(G=>{let A=t.requestBody.content[G].schema;if(A){Array.isArray(y["Content-type"])?y["Content-type"].push(G):y["Content-type"]=[G];let L=U(o,A);L&&(k=L);}}),t!=null&&t.security&&t.security.forEach(v=>{Object.keys(v).forEach(G=>{var L,H;let A=(H=(L=o.components)==null?void 0:L.securitySchemes)==null?void 0:H[G];A&&(A.type==="mutualTLS"?P+=`
44
+ --cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:A.type==="apiKey"?y[(A==null?void 0:A.name)||"X-API-KEY"]="{API_KEY_VALUE}":y.Authorization=`${(A==null?void 0:A.scheme)==="basic"?"Basic":"Bearer"} {${(A==null?void 0:A.scheme)==="basic"?"VALUE":"TOKEN"}}`);});});let q={};Object.keys(y).forEach(v=>{Array.isArray(y[v])?q[v]=y[v].join("; "):q[v]=y[v];}),h=`
44
45
  \`\`\`bash
45
- ${curlGenerator.CurlGenerator({url:k+s,method:a.toUpperCase(),headers:P,body:v})}${G}
46
+ ${curlGenerator.CurlGenerator({url:B+s,method:a.toUpperCase(),headers:q,body:k})}${P}
46
47
  \`\`\``;}K=`/**${t!=null&&t.description?`
47
48
  * ${t==null?void 0:t.description} `:""}
48
49
  * **Method**: \`${a.toUpperCase()}\`
49
50
  * **Summary**: ${(t==null?void 0:t.summary)||""}
50
- * **Tags**: [${((qe=t==null?void 0:t.tags)==null?void 0:qe.join(", "))||""}]
51
+ * **Tags**: [${((Ue=t==null?void 0:t.tags)==null?void 0:Ue.join(", "))||""}]
51
52
  * **OperationId**: ${(t==null?void 0:t.operationId)||""} ${u?`
52
53
  * **Query**: ${le(u)} `:""}${S?`
53
54
  * **DTO**: ${le(S)} `:""}${N?`
54
- * **Response**: ${Object.entries(w).map(([y,v])=>`
55
- - **${y}**: ${le(v,2)} `).join("")}`:""}${U?`
56
- * **Security**: ${U}
55
+ * **Response**: ${Object.entries(w).map(([y,k])=>`
56
+ - **${y}**: ${le(k,2)} `).join("")}`:""}${J?`
57
+ * **Security**: ${J}
57
58
  `:""}${h}
58
59
  */
59
- `;}let Y=(Je=(Ue=e==null?void 0:e.endpoints)==null?void 0:Ue.name)!=null&&Je.useOperationId&&((Le=t==null?void 0:t.operationId)==null?void 0:Le.length)>0?t.operationId:`${m.name}`;if((Ke=(ze=e==null?void 0:e.endpoints)==null?void 0:ze.name)!=null&&Ke.format){let h=e==null?void 0:e.endpoints.name.format({method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},Y);h&&(Y=h);}let ae={method:`"${a}"`,operationId:`"${t==null?void 0:t.operationId}"`,url:T,tags:(t==null?void 0:t.tags)||[]},D=`${K}export const ${ne}${Y} = ${((Ve=(We=e==null?void 0:e.endpoints)==null?void 0:We.value)==null?void 0:Ve.type)==="object"?_(ae):T};
60
- `;e!=null&&e.folderSplit?f[d].endpoints+=D:de+=D;});}),e!=null&&e.folderSplit){for(let[s,r]of Object.entries(f))if(r.endpoints||r.types){let x=B__default.default.join(p,s);if(r.endpoints){let b=B__default.default.join(re,x,"endpoints.ts");yield L__default.default.promises.mkdir(B__default.default.dirname(b),{recursive:true}),yield se(b,r.endpoints,e);}if(r.types){let b=B__default.default.join(re,x,"types.ts");yield L__default.default.promises.mkdir(B__default.default.dirname(b),{recursive:true});let a=Object.values(V).length>0?`import * as Shared from "../shared";
60
+ `;}let Y=(Le=(Je=e==null?void 0:e.endpoints)==null?void 0:Je.name)!=null&&Le.useOperationId&&((ze=t==null?void 0:t.operationId)==null?void 0:ze.length)>0?t.operationId:`${m.name}`;if((We=(Ke=e==null?void 0:e.endpoints)==null?void 0:Ke.name)!=null&&We.format){let h=e==null?void 0:e.endpoints.name.format({method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},Y);h&&(Y=h);}let ae={method:`"${a}"`,operationId:`"${t==null?void 0:t.operationId}"`,url:T,tags:(t==null?void 0:t.tags)||[]},D=`${K}export const ${Q}${Y} = ${((Ye=(Ve=e==null?void 0:e.endpoints)==null?void 0:Ve.value)==null?void 0:Ye.type)==="object"?ee(ae):T};
61
+ `;e!=null&&e.folderSplit?f[d].endpoints+=D:me+=D;});}),e!=null&&e.folderSplit){for(let[s,r]of Object.entries(f))if(r.endpoints||r.types){let j=F__default.default.join(p,s);if(r.endpoints){let b=F__default.default.join(se,j,"endpoints.ts");yield z__default.default.promises.mkdir(F__default.default.dirname(b),{recursive:true}),yield ne(b,r.endpoints,e);}if(r.types){let b=F__default.default.join(se,j,"types.ts");yield z__default.default.promises.mkdir(F__default.default.dirname(b),{recursive:true});let a=Object.values(V).length>0?`import * as Shared from "../shared";
61
62
 
62
- ${r.types}`:r.types;yield se(b,a,e);}}}if(de.length>0){let s=B__default.default.join(re,p,"endpoints.ts");yield L__default.default.promises.mkdir(B__default.default.dirname(s),{recursive:true}),yield se(s,de,e);}if(Object.values(V).length>0){let s=B__default.default.join(re,p,e!=null&&e.folderSplit?"":"types","shared.ts");yield L__default.default.promises.mkdir(B__default.default.dirname(s),{recursive:true}),yield se(s,Object.values(V).join(`
63
- `),e);}if(Q.length>0){let s=B__default.default.join(re,p,"types","index.ts");yield L__default.default.promises.mkdir(B__default.default.dirname(s),{recursive:true}),yield se(s,`${Object.values(V).length>0?`import * as Shared from "./shared";
63
+ ${r.types}`:r.types;yield ne(b,a,e);}}}if(me.length>0){let s=F__default.default.join(se,p,"endpoints.ts");yield z__default.default.promises.mkdir(F__default.default.dirname(s),{recursive:true}),yield ne(s,me,e);}if(Object.values(V).length>0){let s=F__default.default.join(se,p,e!=null&&e.folderSplit?"":"types","shared.ts");yield z__default.default.promises.mkdir(F__default.default.dirname(s),{recursive:true}),yield ne(s,Object.values(V).join(`
64
+ `),e);}if(Z.length>0){let s=F__default.default.join(se,p,"types","index.ts");yield z__default.default.promises.mkdir(F__default.default.dirname(s),{recursive:true}),yield ne(s,`${Object.values(V).length>0?`import * as Shared from "./shared";
64
65
 
65
- `:""}${Q}`,e);}}),ot=nt;var he=process.cwd(),Vt=n=>g(null,null,function*(){let i;try{X("esbuild-register");}catch(E){throw E}let e=B__default.default.join(he,"openapi.sync.js"),O=B__default.default.join(he,"openapi.sync.ts"),$=B__default.default.join(he,"openapi.sync.json"),C=[e,O,$];try{for(let E of C)L__default.default.existsSync(E)&&(i=X(E),Object.keys(i).length===1&&i.default&&(i=i.default));}catch(E){console.log(E);}typeof i=="function"&&(i=i());let o=i;if(!o)throw new Error("No config found");let p=Object.keys(o.api),f=n&&"refetchInterval"in n&&!isNaN(n==null?void 0:n.refetchInterval)?n.refetchInterval:o.refetchInterval;tt();for(let E=0;E<p.length;E+=1){let k=p[E],M=o.api[k];ot(M,k,o,f);}});exports.Init=Vt;exports.JSONStringify=_;exports.capitalize=W;exports.createCustomCodeMarker=Qe;exports.extractCustomCode=dt;exports.getEndpointDetails=He;exports.getNestedValue=xt;exports.isJson=Ze;exports.isYamlString=pt;exports.mergeCustomCode=Xe;exports.renderTypeRefMD=le;exports.variableName=Ot;exports.variableNameChar=Ye;exports.yamlStringToJson=De;
66
+ `:""}${Z}`,e);}}),at=ot;var $e=process.cwd(),Vt=n=>_(null,null,function*(){let i;try{X("esbuild-register");}catch(x){throw x}let e=F__default.default.join($e,"openapi.sync.js"),O=F__default.default.join($e,"openapi.sync.ts"),$=F__default.default.join($e,"openapi.sync.json"),I=[e,O,$];try{for(let x of I)z__default.default.existsSync(x)&&(i=X(x),Object.keys(i).length===1&&i.default&&(i=i.default));}catch(x){console.log(x);}typeof i=="function"&&(i=i());let o=i;if(!o)throw new Error("No config found");let p=Object.keys(o.api),f=n&&"refetchInterval"in n&&!isNaN(n==null?void 0:n.refetchInterval)?n.refetchInterval:o.refetchInterval;rt();for(let x=0;x<p.length;x+=1){let B=p[x],R=o.api[B];at(R,B,o,f);}});exports.Init=Vt;exports.JSONStringify=ee;exports.capitalize=W;exports.createCustomCodeMarker=Ze;exports.extractCustomCode=dt;exports.getEndpointDetails=He;exports.getNestedValue=xt;exports.isJson=ge;exports.isYamlString=pt;exports.mergeCustomCode=Xe;exports.renderTypeRefMD=le;exports.variableName=Ot;exports.variableNameChar=Qe;exports.yamlStringToJson=De;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import L from'fs';import B from'path';import*as ee from'js-yaml';import ut from'lodash.isequal';import rt from'lodash.get';import yt from'axios';import ct from'axios-retry';import ht from'@apidevtools/swagger-parser';import {CurlGenerator}from'curl-generator';var X=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(i,e)=>(typeof require!="undefined"?require:i)[e]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var g=(n,i,e)=>new Promise((O,$)=>{var C=f=>{try{p(e.next(f));}catch(E){$(E);}},o=f=>{try{p(e.throw(f));}catch(E){$(E);}},p=f=>f.done?O(f.value):Promise.resolve(f.value).then(C,o);p((e=e.apply(n,i)).next());});var Ot=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Ye=/[A-Za-z0-9_$]/;var Ze=n=>["object"].includes(typeof n)&&!(n instanceof Blob),pt=n=>{try{return ee.load(n),!0}catch(i){let e=i;if(e instanceof ee.YAMLException)return false;throw e}},De=n=>{if(pt(n)){let i=ee.load(n),e=JSON.stringify(i,null,2);return JSON.parse(e)}},W=n=>n.substring(0,1).toUpperCase()+n.substring(1),He=(n,i)=>{let e=n.split("/"),O=`${W(i)}`,$=[];return e.forEach(C=>{if(C[0]==="{"&&C[C.length-1]==="}"){let p=C.replace(/{/,"").replace(/}/,"");$.push(p),C=`$${p}`;}else if(C[0]==="<"&&C[C.length-1]===">"){let p=C.replace(/</,"").replace(/>/,"");$.push(p),C=`$${p}`;}else if(C[0]===":"){let p=C.replace(/:/,"");$.push(p),C=`$${p}`;}let o="";C.split("").forEach(p=>{let f=p;Ye.test(p)||(f="/"),o+=f;}),o.split("/").forEach(p=>{O+=W(p);});}),{name:O,variables:$,pathParts:e}},_=(n,i=1)=>{let e="{",O=Object.keys(n);for(let $=0;$<O.length;$++){let C=O[$],o=n[C];if(e+=`
2
- `+" ".repeat(i)+C+": ",Array.isArray(o)){e+="[";for(let p=0;p<o.length;p++){let f=o[p];typeof f=="object"&&f!==null?e+=_(f,i+1):e+=typeof f=="string"?`"${f}"`:f,p<o.length-1&&(e+=", ");}e+="]";}else typeof o=="object"&&o!==null?e+=""+_(o,i+1):e+=o.split(`
1
+ import z from'fs';import F from'path';import*as te from'js-yaml';import ut from'lodash.isequal';import st from'lodash.get';import yt from'axios';import ct from'axios-retry';import ht from'@apidevtools/swagger-parser';import {CurlGenerator}from'curl-generator';var X=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(i,e)=>(typeof require!="undefined"?require:i)[e]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var _=(n,i,e)=>new Promise((O,$)=>{var I=f=>{try{p(e.next(f));}catch(x){$(x);}},o=f=>{try{p(e.throw(f));}catch(x){$(x);}},p=f=>f.done?O(f.value):Promise.resolve(f.value).then(I,o);p((e=e.apply(n,i)).next());});var Ot=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Qe=/[A-Za-z0-9_$]/;var ge=n=>["object"].includes(typeof n)&&!(n instanceof Blob),pt=n=>{try{return te.load(n),!0}catch(i){let e=i;if(e instanceof te.YAMLException)return false;throw e}},De=n=>{if(pt(n)){let i=te.load(n),e=JSON.stringify(i,null,2);return JSON.parse(e)}},W=n=>n.substring(0,1).toUpperCase()+n.substring(1),He=(n,i)=>{let e=n.split("/"),O=`${W(i)}`,$=[];return e.forEach(I=>{if(I[0]==="{"&&I[I.length-1]==="}"){let p=I.replace(/{/,"").replace(/}/,"");$.push(p),I=`$${p}`;}else if(I[0]==="<"&&I[I.length-1]===">"){let p=I.replace(/</,"").replace(/>/,"");$.push(p),I=`$${p}`;}else if(I[0]===":"){let p=I.replace(/:/,"");$.push(p),I=`$${p}`;}let o="";I.split("").forEach(p=>{let f=p;Qe.test(p)||(f="/"),o+=f;}),o.split("/").forEach(p=>{O+=W(p);});}),{name:O,variables:$,pathParts:e}},ee=(n,i=1)=>{let e="{",O=Object.keys(n);for(let $=0;$<O.length;$++){let I=O[$],o=n[I];if(e+=`
2
+ `+" ".repeat(i)+I+": ",Array.isArray(o)){e+="[";for(let p=0;p<o.length;p++){let f=o[p];typeof f=="object"&&f!==null?e+=ee(f,i+1):e+=typeof f=="string"?`"${f}"`:f,p<o.length-1&&(e+=", ");}e+="]";}else typeof o=="object"&&o!==null?e+=""+ee(o,i+1):e+=o.split(`
3
3
  `).filter(p=>p.trim()!=="").join(`
4
4
  ${" ".repeat(i)}`);$<O.length-1&&(e+=", ");}return e+=`
5
5
  ${" ".repeat(i-1)}}`,e},le=(n,i=1)=>`
@@ -7,59 +7,60 @@ ${" ".repeat(i-1)}}`,e},le=(n,i=1)=>`
7
7
  ${" ".repeat(i)} ${n.split(`
8
8
  `).filter(e=>e.trim()!=="").join(`
9
9
  ${" ".repeat(i)} `)}
10
- \`\`\``;function xt(n,i){return i.split(".").reduce((O,$)=>O&&O[$]!==void 0?O[$]:void 0,n)}var dt=(n,i="CUSTOM CODE")=>{let e=`// \u{1F512} ${i} START`,O=`// \u{1F512} ${i} END`,$={beforeGenerated:"",afterGenerated:""},C=0,o=[];for(;C<n.length;){let p=n.indexOf(e,C);if(p===-1)break;let f=n.indexOf(O,p);if(f===-1)break;let E=f+O.length,k=p,ne=n.substring(Math.max(0,p-200),p).lastIndexOf("// ==========");ne!==-1&&(k=Math.max(0,p-200)+ne);let oe=n.substring(k,E);o.push({start:k,end:E,content:oe}),C=E;}return o.length>0&&(n.substring(0,o[0].start).split(`
11
- `).filter(E=>{let k=E.trim();return k.length>0&&!k.startsWith("//")}).join("").length===0?($.beforeGenerated=o[0].content,o.length>1&&($.afterGenerated=o[1].content)):($.afterGenerated=o[0].content,o.length>1&&!$.beforeGenerated&&($.beforeGenerated=o[1].content))),$},Qe=(n,i="CUSTOM CODE",e=true)=>{let O=e?`// ${n==="top"?"Add your custom code below this line":"Add your custom code above this line"}
10
+ \`\`\``;function xt(n,i){return i.split(".").reduce((O,$)=>O&&O[$]!==void 0?O[$]:void 0,n)}var dt=(n,i="CUSTOM CODE")=>{let e=`// \u{1F512} ${i} START`,O=`// \u{1F512} ${i} END`,$={beforeGenerated:"",afterGenerated:""},I=0,o=[];for(;I<n.length;){let p=n.indexOf(e,I);if(p===-1)break;let f=n.indexOf(O,p);if(f===-1)break;let x=f+O.length,B=n.substring(x,x+100),R=B.match(/^\s*\n\s*(\/\/ =+)/);if(R){let oe=B.indexOf(`
11
+ `,R.index+1);oe!==-1?x+=oe+1:x+=R[0].length;}let Q=p,M=n.substring(Math.max(0,p-200),p).lastIndexOf("// ==========");M!==-1&&(Q=Math.max(0,p-200)+M);let U=n.substring(Q,x);o.push({start:Q,end:x,content:U}),I=x;}return o.length>0&&(n.substring(0,o[0].start).split(`
12
+ `).filter(x=>{let B=x.trim();return B.length>0&&!B.startsWith("//")}).join("").length===0?($.beforeGenerated=o[0].content,o.length>1&&($.afterGenerated=o[1].content)):($.afterGenerated=o[0].content,o.length>1&&!$.beforeGenerated&&($.beforeGenerated=o[1].content))),$},Ze=(n,i="CUSTOM CODE",e=true)=>{let O=e?`// ${n==="top"?"Add your custom code below this line":"Add your custom code above this line"}
12
13
  // This section will be preserved during regeneration
13
14
  `:"";return `// ${"=".repeat(60)}
14
15
  // \u{1F512} ${i} START
15
16
  ${O}// ${"=".repeat(60)}
16
17
 
17
18
  // \u{1F512} ${i} END
18
- // ${"=".repeat(60)}`},Xe=(n,i,e={})=>{let{position:O="bottom",markerText:$="CUSTOM CODE",includeInstructions:C=true}=e,o={beforeGenerated:"",afterGenerated:""};i&&(o=dt(i,$)),!o.beforeGenerated&&!o.afterGenerated&&((O==="top"||O==="both")&&(o.beforeGenerated=Qe("top",$,C)),(O==="bottom"||O==="both")&&(o.afterGenerated=Qe("bottom",$,C)));let p=[];return o.beforeGenerated&&(p.push(o.beforeGenerated),p.push("")),p.push(n),o.afterGenerated&&(p.push(""),p.push(o.afterGenerated)),p.join(`
19
- `)};var pe=B.join(__dirname,"../","../db.json");L.existsSync(pe)||L.writeFileSync(pe,"{}");var ue={};try{ue=X(pe);}catch(n){ue={};}var te=ue||{},ge=n=>{L.writeFileSync(pe,JSON.stringify(n));},_e=(n,i)=>{te[n]=i,ge(te);},et=n=>te[n],tt=()=>{te={},ge(te);};var re=process.cwd(),ye={},st=yt.create({timeout:6e4});ct(st,{retries:20,retryCondition:n=>n.code==="ECONNABORTED"||n.message.includes("Network Error"),retryDelay:n=>n*1e3});var se=(n,i,e)=>g(null,null,function*(){var o,p,f,E;if(!(((o=e==null?void 0:e.customCode)==null?void 0:o.enabled)!==false)){yield L.promises.writeFile(n,i);return}let $=null;try{$=yield L.promises.readFile(n,"utf-8");}catch(k){}let C=Xe(i,$,{position:((p=e==null?void 0:e.customCode)==null?void 0:p.position)||"bottom",markerText:(f=e==null?void 0:e.customCode)==null?void 0:f.markerText,includeInstructions:(E=e==null?void 0:e.customCode)==null?void 0:E.includeInstructions});yield L.promises.writeFile(n,C);}),nt=(n,i,e,O)=>g(null,null,function*(){var fe,be,Oe,Ce,Ie,xe;let $=yield st.get(n),C=Ze($.data)?$.data:De($.data),o;try{o=yield ht.parse(C);}catch(s){let r=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse OpenAPI spec for ${i}: ${r}`)}let p=B.join((e==null?void 0:e.folder)||"",i),f={},E=s=>{var r,x;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let b=e.folderSplit.customFolder(s);if(console.log("customFolder",b),b)return b}return (x=e==null?void 0:e.folderSplit)!=null&&x.byTags&&s.tags&&s.tags.length>0?s.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},k=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((be=(fe=o==null?void 0:o.servers)==null?void 0:fe[(e==null?void 0:e.server)||0])==null?void 0:be.url)||"",M=typeof((Ce=(Oe=e==null?void 0:e.types)==null?void 0:Oe.name)==null?void 0:Ce.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",ne=typeof((xe=(Ie=e==null?void 0:e.endpoints)==null?void 0:Ie.name)==null?void 0:xe.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",oe=(s,r)=>{var b,a;let x=W(s);if((a=(b=e==null?void 0:e.types)==null?void 0:b.name)!=null&&a.format){let m=e==null?void 0:e.types.name.format("shared",{name:s},x);if(m)return `${M}${m}`}return `${M}${x}`},q=(s,r,x,b,a,m=0)=>{let I="",l="",d="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let u=(r.$ref||"").split("/");u.shift(),[...u].pop();let w=rt(s,u,null);if(w){w!=null&&w.name&&(I=w.name),l=u[u.length-1];let N=oe(l);N.includes(".")&&(N=N.split(".").map((U,K)=>K===0?U:`["${U}"]`).join("")),d+=`${a!=null&&a.noSharedImport?"":"Shared."}${N}`;}}else d+="";else if(r.anyOf)d+=`(${r.anyOf.map(u=>q(s,u,"",b,a)).filter(u=>!!u).join("|")})`;else if(r.oneOf)d+=`(${r.oneOf.map(u=>q(s,u,"",b,a)).filter(u=>!!u).join("|")})`;else if(r.allOf)d+=`(${r.allOf.map(u=>q(s,u,"",b,a)).filter(u=>!!u).join("&")})`;else if(r.items)d+=`${q(s,r.items,"",false,a)}[]`;else if(r.properties){let u=Object.keys(r.properties),j=r.required||[],S="";u.forEach(w=>{var Z,U,K,Y,ae,D;let N="";!((U=(Z=e==null?void 0:e.types)==null?void 0:Z.doc)!=null&&U.disable)&&((Y=(K=r.properties)==null?void 0:K[w])!=null&&Y.description)&&(N=" * "+((ae=r.properties)==null?void 0:ae[w].description.split(`
19
+ // ${"=".repeat(60)}`},Xe=(n,i,e={})=>{let{position:O="bottom",markerText:$="CUSTOM CODE",includeInstructions:I=true}=e,o={beforeGenerated:"",afterGenerated:""};i&&(o=dt(i,$)),!o.beforeGenerated&&!o.afterGenerated&&((O==="top"||O==="both")&&(o.beforeGenerated=Ze("top",$,I)),(O==="bottom"||O==="both")&&(o.afterGenerated=Ze("bottom",$,I)));let p=[];return o.beforeGenerated&&(p.push(o.beforeGenerated),p.push("")),p.push(n),o.afterGenerated&&(p.push(""),p.push(o.afterGenerated)),p.join(`
20
+ `)};var pe=F.join(__dirname,"../","../db.json");z.existsSync(pe)||z.writeFileSync(pe,"{}");var ye={};try{ye=X(pe);}catch(n){ye={};}var re=ye||{},_e=n=>{z.writeFileSync(pe,JSON.stringify(n));},et=(n,i)=>{re[n]=i,_e(re);},tt=n=>re[n],rt=()=>{re={},_e(re);};var se=process.cwd(),ce={},nt=yt.create({timeout:6e4});ct(nt,{retries:20,retryCondition:n=>n.code==="ECONNABORTED"||n.message.includes("Network Error"),retryDelay:n=>n*1e3});var ne=(n,i,e)=>_(null,null,function*(){var o,p,f,x;if(!(((o=e==null?void 0:e.customCode)==null?void 0:o.enabled)!==false)){yield z.promises.writeFile(n,i);return}let $=null;try{$=yield z.promises.readFile(n,"utf-8");}catch(B){}let I=Xe(i,$,{position:((p=e==null?void 0:e.customCode)==null?void 0:p.position)||"bottom",markerText:(f=e==null?void 0:e.customCode)==null?void 0:f.markerText,includeInstructions:(x=e==null?void 0:e.customCode)==null?void 0:x.includeInstructions});yield z.promises.writeFile(n,I);}),ot=(n,i,e,O)=>_(null,null,function*(){var be,Oe,Ie,Ce,xe,je;let $=yield nt.get(n),I=ge($.data)?$.data:De($.data),o;try{o=yield ht.parse(I);}catch(s){let r=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse OpenAPI spec for ${i}: ${r}`)}let p=F.join((e==null?void 0:e.folder)||"",i),f={},x=s=>{var r,j;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let b=e.folderSplit.customFolder(s);if(console.log("customFolder",b),b)return b}return (j=e==null?void 0:e.folderSplit)!=null&&j.byTags&&s.tags&&s.tags.length>0?s.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},B=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((Oe=(be=o==null?void 0:o.servers)==null?void 0:be[(e==null?void 0:e.server)||0])==null?void 0:Oe.url)||"",R=typeof((Ce=(Ie=e==null?void 0:e.types)==null?void 0:Ie.name)==null?void 0:Ce.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",Q=typeof((je=(xe=e==null?void 0:e.endpoints)==null?void 0:xe.name)==null?void 0:je.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",de=(s,r)=>{var b,a;let j=W(s);if((a=(b=e==null?void 0:e.types)==null?void 0:b.name)!=null&&a.format){let m=e==null?void 0:e.types.name.format("shared",{name:s},j);if(m)return `${R}${m}`}return `${R}${j}`},M=(s,r,j,b,a,m=0)=>{let C="",l="",d="";if(r)if(r.$ref)if(r.$ref[0]==="#"){let u=(r.$ref||"").split("/");u.shift(),[...u].pop();let w=st(s,u,null);if(w){w!=null&&w.name&&(C=w.name),l=u[u.length-1];let N=de(l);N.includes(".")&&(N=N.split(".").map((J,K)=>K===0?J:`["${J}"]`).join("")),d+=`${a!=null&&a.noSharedImport?"":"Shared."}${N}`;}}else d+="";else if(r.anyOf)d+=`(${r.anyOf.map(u=>M(s,u,"",b,a)).filter(u=>!!u).join("|")})`;else if(r.oneOf)d+=`(${r.oneOf.map(u=>M(s,u,"",b,a)).filter(u=>!!u).join("|")})`;else if(r.allOf)d+=`(${r.allOf.map(u=>M(s,u,"",b,a)).filter(u=>!!u).join("&")})`;else if(r.items)d+=`${M(s,r.items,"",false,a)}[]`;else if(r.properties){let u=Object.keys(r.properties),E=r.required||[],S="";u.forEach(w=>{var g,J,K,Y,ae,D;let N="";!((J=(g=e==null?void 0:e.types)==null?void 0:g.doc)!=null&&J.disable)&&((Y=(K=r.properties)==null?void 0:K[w])!=null&&Y.description)&&(N=" * "+((ae=r.properties)==null?void 0:ae[w].description.split(`
20
21
  `).filter(ie=>ie.trim()!=="").join(`
21
22
  *${" ".repeat(1)}`))),S+=(N?`/**
22
23
  ${N}
23
24
  */
24
- `:"")+`${q(s,(D=r.properties)==null?void 0:D[w],w,j.includes(w),a,m+1)}`;}),S.length>0?d+=`{
25
- ${" ".repeat(m)}${S}${" ".repeat(m)}}`:d+="{[k: string]: any}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(d+="("),r.enum.map(u=>JSON.stringify(u)).filter(u=>!!u).forEach((u,j)=>{d+=`${j===0?"":"|"}${u}`;}),r.enum.length>1&&(d+=")");else if(r.type){let u=j=>{let S="";if(typeof j=="string")["string","integer","number","array","boolean","null"].includes(j)?["integer","number"].includes(j)?S+="number":j==="array"?S+="any[]":S+=j:j==="object"&&(r.additionalProperties?S+=`{[k: string]: ${q(s,r.additionalProperties,"",true,a)||"any"}}`:S+="{[k: string]: any}");else if(Array.isArray(j)){let w=j.map(N=>u(N));w.filter(N=>N!==""),w.length>1&&(S+="("+w.join("|")+")");}else S+="any";return S};d=u(r.type);}}else d="string";let c=I||x;a!=null&&a.useComponentName&&!c&&(c=l);let T=c?` "${c}"${b?"":"?"}: `:"",t=r!=null&&r.nullable?" | null":"";return d.length>0?`${T}${d}${t}${c?`;
26
- `:""}`:""},z=(s,r)=>{let a="";if(r)if(r.$ref)if(r.$ref[0]==="#"){let m=(r.$ref||"").split("/");m.shift();let l=rt(s,m,null);l&&(l!=null&&l.name&&(l.name),m[m.length-1],a+=z(s,l));}else a+="";else if(r.anyOf)a+=z(s,r.anyOf[0]);else if(r.oneOf)a+=z(s,r.oneOf[0]);else if(r.allOf)a+=`{${r.allOf.map(m=>`...(${z(s,m)})`).join(",")}}`;else if(r.items)a+=`[${z(s,r.items)}]`;else if(r.properties){let l=Object.keys(r.properties).map(d=>{var c;return ` "${d}": ${z(s,(c=r.properties)==null?void 0:c[d])}`}).join(`,
25
+ `:"")+`${M(s,(D=r.properties)==null?void 0:D[w],w,E.includes(w),a,m+1)}`;}),S.length>0?d+=`{
26
+ ${" ".repeat(m)}${S}${" ".repeat(m)}}`:d+="{[k: string]: any}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(d+="("),r.enum.map(u=>JSON.stringify(u)).filter(u=>!!u).forEach((u,E)=>{d+=`${E===0?"":"|"}${u}`;}),r.enum.length>1&&(d+=")");else if(r.type){let u=E=>{let S="";if(typeof E=="string")["string","integer","number","array","boolean","null"].includes(E)?["integer","number"].includes(E)?S+="number":E==="array"?S+="any[]":S+=E:E==="object"&&(r.additionalProperties?S+=`{[k: string]: ${M(s,r.additionalProperties,"",true,a)||"any"}}`:S+="{[k: string]: any}");else if(Array.isArray(E)){let w=E.map(N=>u(N));w.filter(N=>N!==""),w.length>1&&(S+="("+w.join("|")+")");}else S+="any";return S};d=u(r.type);}else d+="any";else d="string";let c=C||j;a!=null&&a.useComponentName&&!c&&(c=l);let T=c?` "${c}"${b?"":"?"}: `:"",t=r!=null&&r.nullable?" | null":"";return d.length>0?`${T}${d}${t}${c?`;
27
+ `:""}`:""},U=(s,r)=>{let a="";if(r)if(r.$ref)if(r.$ref[0]==="#"){let m=(r.$ref||"").split("/");m.shift();let l=st(s,m,null);l&&(l!=null&&l.name&&(l.name),m[m.length-1],a+=U(s,l));}else a+="";else if(r.anyOf)a+=U(s,r.anyOf[0]);else if(r.oneOf)a+=U(s,r.oneOf[0]);else if(r.allOf)a+=`{${r.allOf.map(m=>`...(${U(s,m)})`).join(",")}}`;else if(r.items)a+=`[${U(s,r.items)}]`;else if(r.properties){let l=Object.keys(r.properties).map(d=>{var c;return ` "${d}": ${U(s,(c=r.properties)==null?void 0:c[d])}`}).join(`,
27
28
  `);l.length>0?a+=`{
28
29
  ${l}
29
- }`:a+="{}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(a+=r.enum[0]);else if(r.type)if(r.example)a+=JSON.stringify(r.example);else {let m=I=>{let l="";if(typeof I=="string")["string","integer","number","array","boolean","null"].includes(I)?["integer","number"].includes(I)?l+="123":I==="array"?l+="[]":I==="boolean"?l+="true":I==="null"?l+="null":l+=`"${I}"`:I==="object"&&(l+="{}");else if(Array.isArray(I)){let d=I.map(c=>m(c));d.filter(c=>c!==""),d.length>1&&(l+=d.join("|"));}else l+="any";return l};a=m(r.type);}else a+="any";else a="string";return a};O&&!isNaN(O)&&O>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(ye[i]&&clearTimeout(ye[i]),ye[i]=setTimeout(()=>nt(n,i,e,O),O)));let at=et(i);if(ut(at,o))return;_e(i,o);let de="",Q="",V={};o.components&&Object.keys(o.components).forEach(s=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(s)){let r=o.components[s],x={},b={};Object.keys(r).forEach(m=>{var d;let I=(d=r[m])!=null&&d.schema?r[m].schema:r[m],l=`${q(o,I,"",true,{noSharedImport:true,useComponentName:["parameters"].includes(s)})}`;if(l){let c=m.split("."),T=x,t=b;for(let u=0;u<c.length;u++){let j=c[u];u<c.length-1?(j in T||(T[j]={},t[j]={}),T=T[j],t=t[j]):(T[j]=l,t[j]=I);}}}),Object.keys(x).forEach(m=>{var c,T,t,u;let I=oe(m),l=x[m],d="";!((T=(c=e==null?void 0:e.types)==null?void 0:c.doc)!=null&&T.disable)&&m in r&&((t=r[m])!=null&&t.description)&&(d=" * "+r[m].description.split(`
30
- `).filter(j=>j.trim()!=="").join(`
30
+ }`:a+="{}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(a+=r.enum[0]);else if(r.type)if(r.example)a+=JSON.stringify(r.example);else {let m=C=>{let l="";if(typeof C=="string")["string","integer","number","array","boolean","null"].includes(C)?["integer","number"].includes(C)?l+="123":C==="array"?l+="[]":C==="boolean"?l+="true":C==="null"?l+="null":l+=`"${C}"`:C==="object"&&(l+="{}");else if(Array.isArray(C)){let d=C.map(c=>m(c));d.filter(c=>c!==""),d.length>1&&(l+=d.join("|"));}else l+="any";return l};a=m(r.type);}else a+="any";else a="string";return a};O&&!isNaN(O)&&O>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(ce[i]&&clearTimeout(ce[i]),ce[i]=setTimeout(()=>ot(n,i,e,O),O)));let oe=tt(i);if(ut(oe,o))return;et(i,o);let me="",Z="",V={};o.components&&Object.keys(o.components).forEach(s=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(s)){let r=o.components[s],j={},b={};Object.keys(r).forEach(m=>{var d;let C=(d=r[m])!=null&&d.schema?r[m].schema:r[m],l=`${M(o,C,"",true,{noSharedImport:true,useComponentName:["parameters"].includes(s)})}`;if(l){let c=m.split("."),T=j,t=b;for(let u=0;u<c.length;u++){let E=c[u];u<c.length-1?(E in T||(T[E]={},t[E]={}),T=T[E],t=t[E]):(T[E]=l,t[E]=C);}}}),Object.keys(j).forEach(m=>{var c,T,t,u;let C=de(m),l=j[m],d="";!((T=(c=e==null?void 0:e.types)==null?void 0:c.doc)!=null&&T.disable)&&m in r&&((t=r[m])!=null&&t.description)&&(d=" * "+r[m].description.split(`
31
+ `).filter(E=>E.trim()!=="").join(`
31
32
  *${" ".repeat(1)}`)),V[m]=((u=V[m])!=null?u:"")+(d?`/**
32
33
  ${d}
33
34
  */
34
- `:"")+"export type "+I+" = "+(typeof l=="string"?l:_(l))+`;
35
- `;});}});let $e=s=>{let r="";if(s.content){let x=Object.keys(s.content);x[0]&&s.content[x[0]].schema&&(r+=`${q(o,s.content[x[0]].schema,"")}`);}return r},it=s=>{var r,x,b,a,m;if((x=(r=e==null?void 0:e.endpoints)==null?void 0:r.value)!=null&&x.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let I=s;return (m=(a=(b=e==null?void 0:e.endpoints)==null?void 0:b.value)==null?void 0:a.replaceWords)==null||m.forEach((l,d)=>{let c=new RegExp(l.replace,"g");I=I.replace(c,l.with||"");}),I}else return s},lt=(s,r,x=[])=>{var m,I;let b=(m=e==null?void 0:e.endpoints)==null?void 0:m.exclude,a=(I=e==null?void 0:e.endpoints)==null?void 0:I.include;if(a){let l=a.tags&&a.tags.length>0?x.some(c=>a.tags.includes(c)):true,d=a.endpoints&&a.endpoints.length>0?a.endpoints.some(c=>{let T=!c.method||c.method.toLowerCase()===r.toLowerCase();return c.path?s===c.path&&T:c.regex?new RegExp(c.regex).test(s)&&T:false}):true;if(!l||!d)return true}return !!(b&&(b.tags&&b.tags.length>0&&x.some(d=>b.tags.includes(d))||b.endpoints&&b.endpoints.length>0&&b.endpoints.some(d=>{let c=!d.method||d.method.toLowerCase()===r.toLowerCase();return d.path?s===d.path&&c:d.regex?new RegExp(d.regex).test(s)&&c:false})))};if(Object.keys(o.paths||{}).forEach(s=>{let r=o.paths[s];Object.keys(r).forEach(b=>{var ie,je,Ee,Ae,Te,Se,we,Ne,ve,Re,ke,Be,Me,Fe,Ge,Pe,qe,Ue,Je,Le,ze,Ke,We,Ve;let a=b,m=He(s,a),I=((ie=r[a])==null?void 0:ie.tags)||[];if(lt(s,a,I))return;let l=r[a],d=E({method:a,path:s,summary:l==null?void 0:l.summary,operationId:l==null?void 0:l.operationId,tags:I,parameters:l==null?void 0:l.parameters,requestBody:l==null?void 0:l.requestBody,responses:l==null?void 0:l.responses});f[d]||(f[d]={endpoints:"",types:""});let c=((Ee=(je=e==null?void 0:e.endpoints)==null?void 0:je.value)!=null&&Ee.includeServer?k:"")+m.pathParts.map(h=>(h[0]==="{"&&h[h.length-1]==="}"?h=`\${${h.replace(/{/,"").replace(/}/,"")}}`:h[0]==="<"&&h[h.length-1]===">"?h=`\${${h.replace(/</,"").replace(/>/,"")}}`:h[0]===":"&&(h=`\${${h.replace(/:/,"")}}`),h)).join("/"),T=`"${c}"`;m.variables.length>0&&(T=`(${m.variables.map(y=>`${y}:string`).join(",")})=> \`${c}\``),T=it(T);let t=r[a],u="";if(t!=null&&t.parameters&&((t==null?void 0:t.parameters).forEach((y,v)=>{(y.$ref||y.in==="query"&&y.name)&&(u+=`${q(o,y.$ref?y:y.schema,y.name||"",y.required)}`);}),u)){u=`{
36
- ${u}}`;let y=`${m.name}Query`;if((Te=(Ae=e==null?void 0:e.types)==null?void 0:Ae.name)!=null&&Te.useOperationId&&(t!=null&&t.operationId)&&(y=`${t.operationId}Query`),y=W(`${M}${y}`),(we=(Se=e==null?void 0:e.types)==null?void 0:Se.name)!=null&&we.format){let G=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"query",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},y);G&&(y=`${M}${G}`);}let v=`export type ${y} = ${u};
37
- `;e!=null&&e.folderSplit?f[d].types+=v:Q+=v;}let j=t==null?void 0:t.requestBody,S="";if(j&&(S=$e(j),S)){let h=`${m.name}DTO`;if((ve=(Ne=e==null?void 0:e.types)==null?void 0:Ne.name)!=null&&ve.useOperationId&&(t!=null&&t.operationId)&&(h=`${t.operationId}DTO`),h=W(`${M}${h}`),(ke=(Re=e==null?void 0:e.types)==null?void 0:Re.name)!=null&&ke.format){let v=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"dto",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},h);v&&(h=`${M}${v}`);}let y=`export type ${h} = ${S};
38
- `;e!=null&&e.folderSplit?f[d].types+=y:Q+=y;}let w={},N="";if(t!=null&&t.responses){let h=t==null?void 0:t.responses;Object.keys(h).forEach(v=>{var G,P,R,F;if(N=$e(h[v]),w[v]=N,N){let A=`${m.name}${v}Response`;if((P=(G=e==null?void 0:e.types)==null?void 0:G.name)!=null&&P.useOperationId&&(t!=null&&t.operationId)&&(A=`${t.operationId}${v}Response`),A=W(`${M}${A}`),(F=(R=e==null?void 0:e.types)==null?void 0:R.name)!=null&&F.format){let H=e==null?void 0:e.types.name.format("endpoint",{code:v,type:"response",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},A);H&&(A=`${M}${H}`);}let J=`export type ${A} = ${N};
39
- `;e!=null&&e.folderSplit?f[d].types+=J:Q+=J;}});}let Z=h=>!h||!h.length?"":h.map(y=>Object.entries(y).map(([G,P])=>{let R=G,F="";return Array.isArray(P)&&P.length&&(F=`
40
- - Scopes: [\`${P.join("`, `")}\`]`,R=`**${R}**`),`
41
- - ${R}${F}`}).join("")).join(`
42
- `),U=t!=null&&t.security?Z(t.security):"",K="";if(!((Me=(Be=e==null?void 0:e.endpoints)==null?void 0:Be.doc)!=null&&Me.disable)){let h="";if((Ge=(Fe=e==null?void 0:e.endpoints)==null?void 0:Fe.doc)!=null&&Ge.showCurl){let y={},v="",G="";(Pe=t.requestBody)!=null&&Pe.content&&Object.keys(t.requestBody.content).forEach(F=>{let A=t.requestBody.content[F].schema;if(A){Array.isArray(y["Content-type"])?y["Content-type"].push(F):y["Content-type"]=[F];let J=z(o,A);J&&(v=J);}}),t!=null&&t.security&&t.security.forEach(R=>{Object.keys(R).forEach(F=>{var J,H;let A=(H=(J=o.components)==null?void 0:J.securitySchemes)==null?void 0:H[F];A&&(A.type==="mutualTLS"?G+=`
43
- --cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:A.type==="apiKey"?y[(A==null?void 0:A.name)||"X-API-KEY"]="{API_KEY_VALUE}":y.Authorization=`${(A==null?void 0:A.scheme)==="basic"?"Basic":"Bearer"} {${(A==null?void 0:A.scheme)==="basic"?"VALUE":"TOKEN"}}`);});});let P={};Object.keys(y).forEach(R=>{Array.isArray(y[R])?P[R]=y[R].join("; "):P[R]=y[R];}),h=`
35
+ `:"")+"export type "+C+" = "+(typeof l=="string"?l:ee(l))+`;
36
+ `;});}});let fe=s=>{let r="";if(s.content){let j=Object.keys(s.content);j[0]&&s.content[j[0]].schema&&(r+=`${M(o,s.content[j[0]].schema,"")}`);}return r},it=s=>{var r,j,b,a,m;if((j=(r=e==null?void 0:e.endpoints)==null?void 0:r.value)!=null&&j.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let C=s;return (m=(a=(b=e==null?void 0:e.endpoints)==null?void 0:b.value)==null?void 0:a.replaceWords)==null||m.forEach((l,d)=>{let c=new RegExp(l.replace,"g");C=C.replace(c,l.with||"");}),C}else return s},lt=(s,r,j=[])=>{var m,C;let b=(m=e==null?void 0:e.endpoints)==null?void 0:m.exclude,a=(C=e==null?void 0:e.endpoints)==null?void 0:C.include;if(a){let l=a.tags&&a.tags.length>0?j.some(c=>a.tags.includes(c)):true,d=a.endpoints&&a.endpoints.length>0?a.endpoints.some(c=>{let T=!c.method||c.method.toLowerCase()===r.toLowerCase();return c.path?s===c.path&&T:c.regex?new RegExp(c.regex).test(s)&&T:false}):true;if(!l||!d)return true}return !!(b&&(b.tags&&b.tags.length>0&&j.some(d=>b.tags.includes(d))||b.endpoints&&b.endpoints.length>0&&b.endpoints.some(d=>{let c=!d.method||d.method.toLowerCase()===r.toLowerCase();return d.path?s===d.path&&c:d.regex?new RegExp(d.regex).test(s)&&c:false})))};if(Object.keys(o.paths||{}).forEach(s=>{let r=o.paths[s];Object.keys(r).forEach(b=>{var ie,Ee,Ae,Te,Se,we,Ne,ke,ve,Re,Be,Me,Fe,Ge,Pe,qe,Ue,Je,Le,ze,Ke,We,Ve,Ye;let a=b,m=He(s,a),C=((ie=r[a])==null?void 0:ie.tags)||[];if(lt(s,a,C))return;let l=r[a],d=x({method:a,path:s,summary:l==null?void 0:l.summary,operationId:l==null?void 0:l.operationId,tags:C,parameters:l==null?void 0:l.parameters,requestBody:l==null?void 0:l.requestBody,responses:l==null?void 0:l.responses});f[d]||(f[d]={endpoints:"",types:""});let c=((Ae=(Ee=e==null?void 0:e.endpoints)==null?void 0:Ee.value)!=null&&Ae.includeServer?B:"")+m.pathParts.map(h=>(h[0]==="{"&&h[h.length-1]==="}"?h=`\${${h.replace(/{/,"").replace(/}/,"")}}`:h[0]==="<"&&h[h.length-1]===">"?h=`\${${h.replace(/</,"").replace(/>/,"")}}`:h[0]===":"&&(h=`\${${h.replace(/:/,"")}}`),h)).join("/"),T=`"${c}"`;m.variables.length>0&&(T=`(${m.variables.map(y=>`${y}:string`).join(",")})=> \`${c}\``),T=it(T);let t=r[a],u="";if(t!=null&&t.parameters&&((t==null?void 0:t.parameters).forEach((y,k)=>{(y.$ref||y.in==="query"&&y.name)&&(u+=`${M(o,y.$ref?y:y.schema,y.name||"",y.required)}`);}),u)){u=`{
37
+ ${u}}`;let y=`${m.name}Query`;if((Se=(Te=e==null?void 0:e.types)==null?void 0:Te.name)!=null&&Se.useOperationId&&(t!=null&&t.operationId)&&(y=`${t.operationId}Query`),y=W(`${R}${y}`),(Ne=(we=e==null?void 0:e.types)==null?void 0:we.name)!=null&&Ne.format){let P=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"query",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},y);P&&(y=`${R}${P}`);}let k=`export type ${y} = ${u};
38
+ `;e!=null&&e.folderSplit?f[d].types+=k:Z+=k;}let E=t==null?void 0:t.requestBody,S="";if(E&&(S=fe(E),S)){let h=`${m.name}DTO`;if((ve=(ke=e==null?void 0:e.types)==null?void 0:ke.name)!=null&&ve.useOperationId&&(t!=null&&t.operationId)&&(h=`${t.operationId}DTO`),h=W(`${R}${h}`),(Be=(Re=e==null?void 0:e.types)==null?void 0:Re.name)!=null&&Be.format){let k=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"dto",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},h);k&&(h=`${R}${k}`);}let y=`export type ${h} = ${S};
39
+ `;e!=null&&e.folderSplit?f[d].types+=y:Z+=y;}let w={},N="";if(t!=null&&t.responses){let h=t==null?void 0:t.responses;Object.keys(h).forEach(k=>{var P,q,v,G;if(N=fe(h[k]),w[k]=N,N){let A=`${m.name}${k}Response`;if((q=(P=e==null?void 0:e.types)==null?void 0:P.name)!=null&&q.useOperationId&&(t!=null&&t.operationId)&&(A=`${t.operationId}${k}Response`),A=W(`${R}${A}`),(G=(v=e==null?void 0:e.types)==null?void 0:v.name)!=null&&G.format){let H=e==null?void 0:e.types.name.format("endpoint",{code:k,type:"response",method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},A);H&&(A=`${R}${H}`);}let L=`export type ${A} = ${N};
40
+ `;e!=null&&e.folderSplit?f[d].types+=L:Z+=L;}});}let g=h=>!h||!h.length?"":h.map(y=>Object.entries(y).map(([P,q])=>{let v=P,G="";return Array.isArray(q)&&q.length&&(G=`
41
+ - Scopes: [\`${q.join("`, `")}\`]`,v=`**${v}**`),`
42
+ - ${v}${G}`}).join("")).join(`
43
+ `),J=t!=null&&t.security?g(t.security):"",K="";if(!((Fe=(Me=e==null?void 0:e.endpoints)==null?void 0:Me.doc)!=null&&Fe.disable)){let h="";if((Pe=(Ge=e==null?void 0:e.endpoints)==null?void 0:Ge.doc)!=null&&Pe.showCurl){let y={},k="",P="";(qe=t.requestBody)!=null&&qe.content&&Object.keys(t.requestBody.content).forEach(G=>{let A=t.requestBody.content[G].schema;if(A){Array.isArray(y["Content-type"])?y["Content-type"].push(G):y["Content-type"]=[G];let L=U(o,A);L&&(k=L);}}),t!=null&&t.security&&t.security.forEach(v=>{Object.keys(v).forEach(G=>{var L,H;let A=(H=(L=o.components)==null?void 0:L.securitySchemes)==null?void 0:H[G];A&&(A.type==="mutualTLS"?P+=`
44
+ --cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:A.type==="apiKey"?y[(A==null?void 0:A.name)||"X-API-KEY"]="{API_KEY_VALUE}":y.Authorization=`${(A==null?void 0:A.scheme)==="basic"?"Basic":"Bearer"} {${(A==null?void 0:A.scheme)==="basic"?"VALUE":"TOKEN"}}`);});});let q={};Object.keys(y).forEach(v=>{Array.isArray(y[v])?q[v]=y[v].join("; "):q[v]=y[v];}),h=`
44
45
  \`\`\`bash
45
- ${CurlGenerator({url:k+s,method:a.toUpperCase(),headers:P,body:v})}${G}
46
+ ${CurlGenerator({url:B+s,method:a.toUpperCase(),headers:q,body:k})}${P}
46
47
  \`\`\``;}K=`/**${t!=null&&t.description?`
47
48
  * ${t==null?void 0:t.description} `:""}
48
49
  * **Method**: \`${a.toUpperCase()}\`
49
50
  * **Summary**: ${(t==null?void 0:t.summary)||""}
50
- * **Tags**: [${((qe=t==null?void 0:t.tags)==null?void 0:qe.join(", "))||""}]
51
+ * **Tags**: [${((Ue=t==null?void 0:t.tags)==null?void 0:Ue.join(", "))||""}]
51
52
  * **OperationId**: ${(t==null?void 0:t.operationId)||""} ${u?`
52
53
  * **Query**: ${le(u)} `:""}${S?`
53
54
  * **DTO**: ${le(S)} `:""}${N?`
54
- * **Response**: ${Object.entries(w).map(([y,v])=>`
55
- - **${y}**: ${le(v,2)} `).join("")}`:""}${U?`
56
- * **Security**: ${U}
55
+ * **Response**: ${Object.entries(w).map(([y,k])=>`
56
+ - **${y}**: ${le(k,2)} `).join("")}`:""}${J?`
57
+ * **Security**: ${J}
57
58
  `:""}${h}
58
59
  */
59
- `;}let Y=(Je=(Ue=e==null?void 0:e.endpoints)==null?void 0:Ue.name)!=null&&Je.useOperationId&&((Le=t==null?void 0:t.operationId)==null?void 0:Le.length)>0?t.operationId:`${m.name}`;if((Ke=(ze=e==null?void 0:e.endpoints)==null?void 0:ze.name)!=null&&Ke.format){let h=e==null?void 0:e.endpoints.name.format({method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},Y);h&&(Y=h);}let ae={method:`"${a}"`,operationId:`"${t==null?void 0:t.operationId}"`,url:T,tags:(t==null?void 0:t.tags)||[]},D=`${K}export const ${ne}${Y} = ${((Ve=(We=e==null?void 0:e.endpoints)==null?void 0:We.value)==null?void 0:Ve.type)==="object"?_(ae):T};
60
- `;e!=null&&e.folderSplit?f[d].endpoints+=D:de+=D;});}),e!=null&&e.folderSplit){for(let[s,r]of Object.entries(f))if(r.endpoints||r.types){let x=B.join(p,s);if(r.endpoints){let b=B.join(re,x,"endpoints.ts");yield L.promises.mkdir(B.dirname(b),{recursive:true}),yield se(b,r.endpoints,e);}if(r.types){let b=B.join(re,x,"types.ts");yield L.promises.mkdir(B.dirname(b),{recursive:true});let a=Object.values(V).length>0?`import * as Shared from "../shared";
60
+ `;}let Y=(Le=(Je=e==null?void 0:e.endpoints)==null?void 0:Je.name)!=null&&Le.useOperationId&&((ze=t==null?void 0:t.operationId)==null?void 0:ze.length)>0?t.operationId:`${m.name}`;if((We=(Ke=e==null?void 0:e.endpoints)==null?void 0:Ke.name)!=null&&We.format){let h=e==null?void 0:e.endpoints.name.format({method:a,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},Y);h&&(Y=h);}let ae={method:`"${a}"`,operationId:`"${t==null?void 0:t.operationId}"`,url:T,tags:(t==null?void 0:t.tags)||[]},D=`${K}export const ${Q}${Y} = ${((Ye=(Ve=e==null?void 0:e.endpoints)==null?void 0:Ve.value)==null?void 0:Ye.type)==="object"?ee(ae):T};
61
+ `;e!=null&&e.folderSplit?f[d].endpoints+=D:me+=D;});}),e!=null&&e.folderSplit){for(let[s,r]of Object.entries(f))if(r.endpoints||r.types){let j=F.join(p,s);if(r.endpoints){let b=F.join(se,j,"endpoints.ts");yield z.promises.mkdir(F.dirname(b),{recursive:true}),yield ne(b,r.endpoints,e);}if(r.types){let b=F.join(se,j,"types.ts");yield z.promises.mkdir(F.dirname(b),{recursive:true});let a=Object.values(V).length>0?`import * as Shared from "../shared";
61
62
 
62
- ${r.types}`:r.types;yield se(b,a,e);}}}if(de.length>0){let s=B.join(re,p,"endpoints.ts");yield L.promises.mkdir(B.dirname(s),{recursive:true}),yield se(s,de,e);}if(Object.values(V).length>0){let s=B.join(re,p,e!=null&&e.folderSplit?"":"types","shared.ts");yield L.promises.mkdir(B.dirname(s),{recursive:true}),yield se(s,Object.values(V).join(`
63
- `),e);}if(Q.length>0){let s=B.join(re,p,"types","index.ts");yield L.promises.mkdir(B.dirname(s),{recursive:true}),yield se(s,`${Object.values(V).length>0?`import * as Shared from "./shared";
63
+ ${r.types}`:r.types;yield ne(b,a,e);}}}if(me.length>0){let s=F.join(se,p,"endpoints.ts");yield z.promises.mkdir(F.dirname(s),{recursive:true}),yield ne(s,me,e);}if(Object.values(V).length>0){let s=F.join(se,p,e!=null&&e.folderSplit?"":"types","shared.ts");yield z.promises.mkdir(F.dirname(s),{recursive:true}),yield ne(s,Object.values(V).join(`
64
+ `),e);}if(Z.length>0){let s=F.join(se,p,"types","index.ts");yield z.promises.mkdir(F.dirname(s),{recursive:true}),yield ne(s,`${Object.values(V).length>0?`import * as Shared from "./shared";
64
65
 
65
- `:""}${Q}`,e);}}),ot=nt;var he=process.cwd(),Vt=n=>g(null,null,function*(){let i;try{X("esbuild-register");}catch(E){throw E}let e=B.join(he,"openapi.sync.js"),O=B.join(he,"openapi.sync.ts"),$=B.join(he,"openapi.sync.json"),C=[e,O,$];try{for(let E of C)L.existsSync(E)&&(i=X(E),Object.keys(i).length===1&&i.default&&(i=i.default));}catch(E){console.log(E);}typeof i=="function"&&(i=i());let o=i;if(!o)throw new Error("No config found");let p=Object.keys(o.api),f=n&&"refetchInterval"in n&&!isNaN(n==null?void 0:n.refetchInterval)?n.refetchInterval:o.refetchInterval;tt();for(let E=0;E<p.length;E+=1){let k=p[E],M=o.api[k];ot(M,k,o,f);}});export{Vt as Init,_ as JSONStringify,W as capitalize,Qe as createCustomCodeMarker,dt as extractCustomCode,He as getEndpointDetails,xt as getNestedValue,Ze as isJson,pt as isYamlString,Xe as mergeCustomCode,le as renderTypeRefMD,Ot as variableName,Ye as variableNameChar,De as yamlStringToJson};
66
+ `:""}${Z}`,e);}}),at=ot;var $e=process.cwd(),Vt=n=>_(null,null,function*(){let i;try{X("esbuild-register");}catch(x){throw x}let e=F.join($e,"openapi.sync.js"),O=F.join($e,"openapi.sync.ts"),$=F.join($e,"openapi.sync.json"),I=[e,O,$];try{for(let x of I)z.existsSync(x)&&(i=X(x),Object.keys(i).length===1&&i.default&&(i=i.default));}catch(x){console.log(x);}typeof i=="function"&&(i=i());let o=i;if(!o)throw new Error("No config found");let p=Object.keys(o.api),f=n&&"refetchInterval"in n&&!isNaN(n==null?void 0:n.refetchInterval)?n.refetchInterval:o.refetchInterval;rt();for(let x=0;x<p.length;x+=1){let B=p[x],R=o.api[B];at(R,B,o,f);}});export{Vt as Init,ee as JSONStringify,W as capitalize,Ze as createCustomCodeMarker,dt as extractCustomCode,He as getEndpointDetails,xt as getNestedValue,ge as isJson,pt as isYamlString,Xe as mergeCustomCode,le as renderTypeRefMD,Ot as variableName,Qe as variableNameChar,De as yamlStringToJson};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-sync",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "A developer-friendly tool designed to keep your API up-to-date by leveraging OpenAPI schemas. It automates the generation of endpoint URIs and type definitions, including shared types, directly from your OpenAPI specification.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",