openapi-sync 2.1.16 → 2.1.17

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.d.mts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { Method } from 'axios';
2
- export { JSONStringify, capitalize, getEndpointDetails, getNestedValue, isJson, isYamlString, renderTypeRefMD, yamlStringToJson } from './helpers.mjs';
3
- export { variableName, variableNameChar } from './regex.mjs';
4
2
 
5
3
  type IOpenApiSpec = Record<"openapi", string> & Record<string, any>;
6
4
  type IOpenApSchemaSpec = {
@@ -151,8 +149,24 @@ type IOpenApiSecuritySchemes = {
151
149
  };
152
150
  };
153
151
 
152
+ declare const isJson: (value: any) => boolean;
153
+ declare const isYamlString: (fileContent: string) => boolean;
154
+ declare const yamlStringToJson: (fileContent: string) => any;
155
+ declare const capitalize: (text: string) => string;
156
+ declare const getEndpointDetails: (path: string, method: string) => {
157
+ name: string;
158
+ variables: string[];
159
+ pathParts: string[];
160
+ };
161
+ declare const JSONStringify: (obj: Record<string, any>, indent?: number) => string;
162
+ declare const renderTypeRefMD: (typeRef: string, indent?: number) => string;
163
+ declare function getNestedValue<T>(obj: object, path: string): T | undefined;
164
+
165
+ declare const variableName: RegExp;
166
+ declare const variableNameChar: RegExp;
167
+
154
168
  declare const Init: (options?: {
155
169
  refetchInterval?: number;
156
170
  }) => Promise<void>;
157
171
 
158
- export { type IConfig, type IConfigDoc, type IConfigExclude, type IConfigFolderSplit, type IConfigInclude, type IConfigReplaceWord, type IOpenApSchemaSpec, type IOpenApiMediaTypeSpec, type IOpenApiParameterSpec, type IOpenApiRequestBodySpec, type IOpenApiResponseSpec, type IOpenApiSecuritySchemes, type IOpenApiSpec, Init };
172
+ export { type IConfig, type IConfigDoc, type IConfigExclude, type IConfigFolderSplit, type IConfigInclude, type IConfigReplaceWord, type IOpenApSchemaSpec, type IOpenApiMediaTypeSpec, type IOpenApiParameterSpec, type IOpenApiRequestBodySpec, type IOpenApiResponseSpec, type IOpenApiSecuritySchemes, type IOpenApiSpec, Init, JSONStringify, capitalize, getEndpointDetails, getNestedValue, isJson, isYamlString, renderTypeRefMD, variableName, variableNameChar, yamlStringToJson };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { Method } from 'axios';
2
- export { JSONStringify, capitalize, getEndpointDetails, getNestedValue, isJson, isYamlString, renderTypeRefMD, yamlStringToJson } from './helpers.js';
3
- export { variableName, variableNameChar } from './regex.js';
4
2
 
5
3
  type IOpenApiSpec = Record<"openapi", string> & Record<string, any>;
6
4
  type IOpenApSchemaSpec = {
@@ -151,8 +149,24 @@ type IOpenApiSecuritySchemes = {
151
149
  };
152
150
  };
153
151
 
152
+ declare const isJson: (value: any) => boolean;
153
+ declare const isYamlString: (fileContent: string) => boolean;
154
+ declare const yamlStringToJson: (fileContent: string) => any;
155
+ declare const capitalize: (text: string) => string;
156
+ declare const getEndpointDetails: (path: string, method: string) => {
157
+ name: string;
158
+ variables: string[];
159
+ pathParts: string[];
160
+ };
161
+ declare const JSONStringify: (obj: Record<string, any>, indent?: number) => string;
162
+ declare const renderTypeRefMD: (typeRef: string, indent?: number) => string;
163
+ declare function getNestedValue<T>(obj: object, path: string): T | undefined;
164
+
165
+ declare const variableName: RegExp;
166
+ declare const variableNameChar: RegExp;
167
+
154
168
  declare const Init: (options?: {
155
169
  refetchInterval?: number;
156
170
  }) => Promise<void>;
157
171
 
158
- export { type IConfig, type IConfigDoc, type IConfigExclude, type IConfigFolderSplit, type IConfigInclude, type IConfigReplaceWord, type IOpenApSchemaSpec, type IOpenApiMediaTypeSpec, type IOpenApiParameterSpec, type IOpenApiRequestBodySpec, type IOpenApiResponseSpec, type IOpenApiSecuritySchemes, type IOpenApiSpec, Init };
172
+ export { type IConfig, type IConfigDoc, type IConfigExclude, type IConfigFolderSplit, type IConfigInclude, type IConfigReplaceWord, type IOpenApSchemaSpec, type IOpenApiMediaTypeSpec, type IOpenApiParameterSpec, type IOpenApiRequestBodySpec, type IOpenApiResponseSpec, type IOpenApiSecuritySchemes, type IOpenApiSpec, Init, JSONStringify, capitalize, getEndpointDetails, getNestedValue, isJson, isYamlString, renderTypeRefMD, variableName, variableNameChar, yamlStringToJson };
package/dist/index.mjs CHANGED
@@ -1,47 +1,56 @@
1
- import {a as a$1,c,f,e,d,g}from'./chunk-ALDCDVEN.mjs';export{f as JSONStringify,d as capitalize,e as getEndpointDetails,h as getNestedValue,a as isJson,b as isYamlString,g as renderTypeRefMD,c as yamlStringToJson}from'./chunk-ALDCDVEN.mjs';import {a,b}from'./chunk-6GQNHE6A.mjs';export{c as variableName,d as variableNameChar}from'./chunk-6GQNHE6A.mjs';import F from'fs';import w from'path';import at from'lodash.isequal';import Ze from'lodash.get';import ot from'axios';import pt from'axios-retry';import it from'@apidevtools/swagger-parser';import {CurlGenerator}from'curl-generator';var se=w.join(__dirname,"../","../db.json");F.existsSync(se)||F.writeFileSync(se,"{}");var ie={};try{ie=a(se);}catch(I){ie={};}var D=ie||{},ze=I=>{F.writeFileSync(se,JSON.stringify(I));},Ye=(I,j)=>{D[I]=j,ze(D);},He=I=>D[I],Xe=()=>{D={},ze(D);};var _=process.cwd(),le={},De=ot.create({timeout:6e4});pt(De,{retries:20,retryCondition:I=>I.code==="ECONNABORTED"||I.message.includes("Network Error"),retryDelay:I=>I*1e3});var _e=(I,j,e$1,M)=>b(null,null,function*(){var $e,he,fe,Oe,Ie,je;let W=yield De.get(I),ne=a$1(W.data)?W.data:c(W.data),f$1;try{f$1=yield it.parse(ne);}catch(s){let r=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse OpenAPI spec for ${j}: ${r}`)}let U=w.join((e$1==null?void 0:e$1.folder)||"",j),P={},T=s=>{var r,$;if((r=e$1==null?void 0:e$1.folderSplit)!=null&&r.customFolder){let u=e$1.folderSplit.customFolder(s);if(console.log("customFolder",u),u)return u}return ($=e$1==null?void 0:e$1.folderSplit)!=null&&$.byTags&&s.tags&&s.tags.length>0?s.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},G=typeof(e$1==null?void 0:e$1.server)=="string"?e$1==null?void 0:e$1.server:((he=($e=f$1==null?void 0:f$1.servers)==null?void 0:$e[(e$1==null?void 0:e$1.server)||0])==null?void 0:he.url)||"",R=typeof((Oe=(fe=e$1==null?void 0:e$1.types)==null?void 0:fe.name)==null?void 0:Oe.prefix)=="string"?e$1==null?void 0:e$1.types.name.prefix:"I",et=typeof((je=(Ie=e$1==null?void 0:e$1.endpoints)==null?void 0:Ie.name)==null?void 0:je.prefix)=="string"?e$1==null?void 0:e$1.endpoints.name.prefix:"",ue=(s,r)=>{var u,n;let $=d(s);if((n=(u=e$1==null?void 0:e$1.types)==null?void 0:u.name)!=null&&n.format){let p=e$1==null?void 0:e$1.types.name.format("shared",{name:s},$);if(p)return `${R}${p}`}return `${R}${$}`},q=(s,r,$,u,n,p=0)=>{let y="",a="",o="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let i=(r.$ref||"").split("/");i.shift(),[...i].pop();let c=Ze(s,i,null);if(c){c!=null&&c.name&&(y=c.name),a=i[i.length-1];let A=ue(a);A.includes(".")&&(A=A.split(".").map((k,K)=>K===0?k:`["${k}"]`).join("")),o+=`${n!=null&&n.noSharedImport?"":"Shared."}${A}`;}}else o+="";else if(r.anyOf)o+=`(${r.anyOf.map(i=>q(s,i,"",u,n)).filter(i=>!!i).join("|")})`;else if(r.oneOf)o+=`(${r.oneOf.map(i=>q(s,i,"",u,n)).filter(i=>!!i).join("|")})`;else if(r.allOf)o+=`(${r.allOf.map(i=>q(s,i,"",u,n)).filter(i=>!!i).join("&")})`;else if(r.items)o+=`${q(s,r.items,"",false,n)}[]`;else if(r.properties){let i=Object.keys(r.properties),h=r.required||[],C="";i.forEach(c=>{var z,k,K,V,g,Y;let A="";!((k=(z=e$1==null?void 0:e$1.types)==null?void 0:z.doc)!=null&&k.disable)&&((V=(K=r.properties)==null?void 0:K[c])!=null&&V.description)&&(A=" * "+((g=r.properties)==null?void 0:g[c].description.split(`
2
- `).filter(ee=>ee.trim()!=="").join(`
3
- *${" ".repeat(1)}`))),C+=(A?`/**
4
- ${A}
1
+ import M from'fs';import F from'path';import*as g from'js-yaml';import pt from'lodash.isequal';import _e from'lodash.get';import lt from'axios';import mt from'axios-retry';import dt from'@apidevtools/swagger-parser';import {CurlGenerator}from'curl-generator';var D=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(m,e)=>(typeof require!="undefined"?require:m)[e]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var ne=(o,m,e)=>new Promise((C,A)=>{var b=O=>{try{h(e.next(O));}catch(R){A(R);}},u=O=>{try{h(e.throw(O));}catch(R){A(R);}},h=O=>O.done?C(O.value):Promise.resolve(O.value).then(b,u);h((e=e.apply(o,m)).next());});var ft=/^[A-Za-z_$][A-Za-z0-9_$]*$/,We=/[A-Za-z0-9_$]/;var Ye=o=>["object"].includes(typeof o)&&!(o instanceof Blob),ot=o=>{try{return g.load(o),!0}catch(m){let e=m;if(e instanceof g.YAMLException)return false;throw e}},Ge=o=>{if(ot(o)){let m=g.load(o),e=JSON.stringify(m,null,2);return JSON.parse(e)}},V=o=>o.substring(0,1).toUpperCase()+o.substring(1),Qe=(o,m)=>{let e=o.split("/"),C=`${V(m)}`,A=[];return e.forEach(b=>{if(b[0]==="{"&&b[b.length-1]==="}"){let h=b.replace(/{/,"").replace(/}/,"");A.push(h),b=`$${h}`;}else if(b[0]==="<"&&b[b.length-1]===">"){let h=b.replace(/</,"").replace(/>/,"");A.push(h),b=`$${h}`;}else if(b[0]===":"){let h=b.replace(/:/,"");A.push(h),b=`$${h}`;}let u="";b.split("").forEach(h=>{let O=h;We.test(h)||(O="/"),u+=O;}),u.split("/").forEach(h=>{C+=V(h);});}),{name:C,variables:A,pathParts:e}},_=(o,m=1)=>{let e="{",C=Object.keys(o);for(let A=0;A<C.length;A++){let b=C[A],u=o[b];if(e+=`
2
+ `+" ".repeat(m)+b+": ",Array.isArray(u)){e+="[";for(let h=0;h<u.length;h++){let O=u[h];typeof O=="object"&&O!==null?e+=_(O,m+1):e+=typeof O=="string"?`"${O}"`:O,h<u.length-1&&(e+=", ");}e+="]";}else typeof u=="object"&&u!==null?e+=""+_(u,m+1):e+=u.split(`
3
+ `).filter(h=>h.trim()!=="").join(`
4
+ ${" ".repeat(m)}`);A<C.length-1&&(e+=", ");}return e+=`
5
+ ${" ".repeat(m-1)}}`,e},ae=(o,m=1)=>`
6
+ \`\`\`typescript
7
+ ${" ".repeat(m)} ${o.split(`
8
+ `).filter(e=>e.trim()!=="").join(`
9
+ ${" ".repeat(m)} `)}
10
+ \`\`\``;function Ot(o,m){return m.split(".").reduce((C,A)=>C&&C[A]!==void 0?C[A]:void 0,o)}var oe=F.join(__dirname,"../","../db.json");M.existsSync(oe)||M.writeFileSync(oe,"{}");var le={};try{le=D(oe);}catch(o){le={};}var ee=le||{},Ze=o=>{M.writeFileSync(oe,JSON.stringify(o));},He=(o,m)=>{ee[o]=m,Ze(ee);},Xe=o=>ee[o],De=()=>{ee={},Ze(ee);};var te=process.cwd(),me={},ge=lt.create({timeout:6e4});mt(ge,{retries:20,retryCondition:o=>o.code==="ECONNABORTED"||o.message.includes("Network Error"),retryDelay:o=>o*1e3});var et=(o,m,e,C)=>ne(null,null,function*(){var fe,he,ce,Oe,Ie,je;let A=yield ge.get(o),b=Ye(A.data)?A.data:Ge(A.data),u;try{u=yield dt.parse(b);}catch(s){let r=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse OpenAPI spec for ${m}: ${r}`)}let h=F.join((e==null?void 0:e.folder)||"",m),O={},R=s=>{var r,I;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let f=e.folderSplit.customFolder(s);if(console.log("customFolder",f),f)return f}return (I=e==null?void 0:e.folderSplit)!=null&&I.byTags&&s.tags&&s.tags.length>0?s.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},G=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((he=(fe=u==null?void 0:u.servers)==null?void 0:fe[(e==null?void 0:e.server)||0])==null?void 0:he.url)||"",k=typeof((Oe=(ce=e==null?void 0:e.types)==null?void 0:ce.name)==null?void 0:Oe.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",rt=typeof((je=(Ie=e==null?void 0:e.endpoints)==null?void 0:Ie.name)==null?void 0:je.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",ye=(s,r)=>{var f,n;let I=V(s);if((n=(f=e==null?void 0:e.types)==null?void 0:f.name)!=null&&n.format){let p=e==null?void 0:e.types.name.format("shared",{name:s},I);if(p)return `${k}${p}`}return `${k}${I}`},J=(s,r,I,f,n,p=0)=>{let c="",a="",i="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let l=(r.$ref||"").split("/");l.shift(),[...l].pop();let w=_e(s,l,null);if(w){w!=null&&w.name&&(c=w.name),a=l[l.length-1];let S=ye(a);S.includes(".")&&(S=S.split(".").map((U,K)=>K===0?U:`["${U}"]`).join("")),i+=`${n!=null&&n.noSharedImport?"":"Shared."}${S}`;}}else i+="";else if(r.anyOf)i+=`(${r.anyOf.map(l=>J(s,l,"",f,n)).filter(l=>!!l).join("|")})`;else if(r.oneOf)i+=`(${r.oneOf.map(l=>J(s,l,"",f,n)).filter(l=>!!l).join("|")})`;else if(r.allOf)i+=`(${r.allOf.map(l=>J(s,l,"",f,n)).filter(l=>!!l).join("&")})`;else if(r.items)i+=`${J(s,r.items,"",false,n)}[]`;else if(r.properties){let l=Object.keys(r.properties),j=r.required||[],T="";l.forEach(w=>{var Z,U,K,Y,re,H;let S="";!((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)&&(S=" * "+((re=r.properties)==null?void 0:re[w].description.split(`
11
+ `).filter(se=>se.trim()!=="").join(`
12
+ *${" ".repeat(1)}`))),T+=(S?`/**
13
+ ${S}
5
14
  */
6
- `:"")+`${q(s,(Y=r.properties)==null?void 0:Y[c],c,h.includes(c),n,p+1)}`;}),C.length>0?o+=`{
7
- ${" ".repeat(p)}${C}${" ".repeat(p)}}`:o+="{[k: string]: any}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(o+="("),r.enum.map(i=>JSON.stringify(i)).filter(i=>!!i).forEach((i,h)=>{o+=`${h===0?"":"|"}${i}`;}),r.enum.length>1&&(o+=")");else if(r.type){let i=h=>{let C="";if(typeof h=="string")["string","integer","number","array","boolean","null"].includes(h)?["integer","number"].includes(h)?C+="number":h==="array"?C+="any[]":C+=h:h==="object"&&(r.additionalProperties?C+=`{[k: string]: ${q(s,r.additionalProperties,"",true,n)||"any"}}`:C+="{[k: string]: any}");else if(Array.isArray(h)){let c=h.map(A=>i(A));c.filter(A=>A!==""),c.length>1&&(C+="("+c.join("|")+")");}else C+="any";return C};o=i(r.type);}}else o="string";let m=y||$;n!=null&&n.useComponentName&&!m&&(m=a);let b=m?` "${m}"${u?"":"?"}: `:"",t=r!=null&&r.nullable?" | null":"";return o.length>0?`${b}${o}${t}${m?`;
8
- `:""}`:""},J=(s,r)=>{let n="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let p=(r.$ref||"").split("/");p.shift();let a=Ze(s,p,null);a&&(a!=null&&a.name&&(a.name),p[p.length-1],n+=J(s,a));}else n+="";else if(r.anyOf)n+=J(s,r.anyOf[0]);else if(r.oneOf)n+=J(s,r.oneOf[0]);else if(r.allOf)n+=`{${r.allOf.map(p=>`...(${J(s,p)})`).join(",")}}`;else if(r.items)n+=`[${J(s,r.items)}]`;else if(r.properties){let a=Object.keys(r.properties).map(o=>{var m;return ` "${o}": ${J(s,(m=r.properties)==null?void 0:m[o])}`}).join(`,
15
+ `:"")+`${J(s,(H=r.properties)==null?void 0:H[w],w,j.includes(w),n,p+1)}`;}),T.length>0?i+=`{
16
+ ${" ".repeat(p)}${T}${" ".repeat(p)}}`:i+="{[k: string]: any}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(i+="("),r.enum.map(l=>JSON.stringify(l)).filter(l=>!!l).forEach((l,j)=>{i+=`${j===0?"":"|"}${l}`;}),r.enum.length>1&&(i+=")");else if(r.type){let l=j=>{let T="";if(typeof j=="string")["string","integer","number","array","boolean","null"].includes(j)?["integer","number"].includes(j)?T+="number":j==="array"?T+="any[]":T+=j:j==="object"&&(r.additionalProperties?T+=`{[k: string]: ${J(s,r.additionalProperties,"",true,n)||"any"}}`:T+="{[k: string]: any}");else if(Array.isArray(j)){let w=j.map(S=>l(S));w.filter(S=>S!==""),w.length>1&&(T+="("+w.join("|")+")");}else T+="any";return T};i=l(r.type);}}else i="string";let y=c||I;n!=null&&n.useComponentName&&!y&&(y=a);let E=y?` "${y}"${f?"":"?"}: `:"",t=r!=null&&r.nullable?" | null":"";return i.length>0?`${E}${i}${t}${y?`;
17
+ `:""}`:""},z=(s,r)=>{let n="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let p=(r.$ref||"").split("/");p.shift();let a=_e(s,p,null);a&&(a!=null&&a.name&&(a.name),p[p.length-1],n+=z(s,a));}else n+="";else if(r.anyOf)n+=z(s,r.anyOf[0]);else if(r.oneOf)n+=z(s,r.oneOf[0]);else if(r.allOf)n+=`{${r.allOf.map(p=>`...(${z(s,p)})`).join(",")}}`;else if(r.items)n+=`[${z(s,r.items)}]`;else if(r.properties){let a=Object.keys(r.properties).map(i=>{var y;return ` "${i}": ${z(s,(y=r.properties)==null?void 0:y[i])}`}).join(`,
9
18
  `);a.length>0?n+=`{
10
19
  ${a}
11
- }`:n+="{}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(n+=r.enum[0]);else if(r.type)if(r.example)n+=JSON.stringify(r.example);else {let p=y=>{let a="";if(typeof y=="string")["string","integer","number","array","boolean","null"].includes(y)?["integer","number"].includes(y)?a+="123":y==="array"?a+="[]":y==="boolean"?a+="true":y==="null"?a+="null":a+=`"${y}"`:y==="object"&&(a+="{}");else if(Array.isArray(y)){let o=y.map(m=>p(m));o.filter(m=>m!==""),o.length>1&&(a+=o.join("|"));}else a+="any";return a};n=p(r.type);}}else n="string";return n};M&&!isNaN(M)&&M>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(le[j]&&clearTimeout(le[j]),le[j]=setTimeout(()=>_e(I,j,e$1,M),M)));let tt=He(j);if(at(tt,f$1))return;Ye(j,f$1);let ae="",Q="",L={};f$1.components&&Object.keys(f$1.components).forEach(s=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(s)){let r=f$1.components[s],$={},u={};Object.keys(r).forEach(p=>{var o;let y=(o=r[p])!=null&&o.schema?r[p].schema:r[p],a=`${q(f$1,y,"",true,{noSharedImport:true,useComponentName:["parameters"].includes(s)})}`;if(a){let m=p.split("."),b=$,t=u;for(let i=0;i<m.length;i++){let h=m[i];i<m.length-1?(h in b||(b[h]={},t[h]={}),b=b[h],t=t[h]):(b[h]=a,t[h]=y);}}}),Object.keys($).forEach(p=>{var m,b,t,i;let y=ue(p),a=$[p],o="";!((b=(m=e$1==null?void 0:e$1.types)==null?void 0:m.doc)!=null&&b.disable)&&p in r&&((t=r[p])!=null&&t.description)&&(o=" * "+r[p].description.split(`
12
- `).filter(h=>h.trim()!=="").join(`
13
- *${" ".repeat(1)}`)),L[p]=((i=L[p])!=null?i:"")+(o?`/**
14
- ${o}
20
+ }`:n+="{}";}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(n+=r.enum[0]);else if(r.type)if(r.example)n+=JSON.stringify(r.example);else {let p=c=>{let a="";if(typeof c=="string")["string","integer","number","array","boolean","null"].includes(c)?["integer","number"].includes(c)?a+="123":c==="array"?a+="[]":c==="boolean"?a+="true":c==="null"?a+="null":a+=`"${c}"`:c==="object"&&(a+="{}");else if(Array.isArray(c)){let i=c.map(y=>p(y));i.filter(y=>y!==""),i.length>1&&(a+=i.join("|"));}else a+="any";return a};n=p(r.type);}}else n="string";return n};C&&!isNaN(C)&&C>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(me[m]&&clearTimeout(me[m]),me[m]=setTimeout(()=>et(o,m,e,C),C)));let st=Xe(m);if(pt(st,u))return;He(m,u);let ie="",Q="",W={};u.components&&Object.keys(u.components).forEach(s=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(s)){let r=u.components[s],I={},f={};Object.keys(r).forEach(p=>{var i;let c=(i=r[p])!=null&&i.schema?r[p].schema:r[p],a=`${J(u,c,"",true,{noSharedImport:true,useComponentName:["parameters"].includes(s)})}`;if(a){let y=p.split("."),E=I,t=f;for(let l=0;l<y.length;l++){let j=y[l];l<y.length-1?(j in E||(E[j]={},t[j]={}),E=E[j],t=t[j]):(E[j]=a,t[j]=c);}}}),Object.keys(I).forEach(p=>{var y,E,t,l;let c=ye(p),a=I[p],i="";!((E=(y=e==null?void 0:e.types)==null?void 0:y.doc)!=null&&E.disable)&&p in r&&((t=r[p])!=null&&t.description)&&(i=" * "+r[p].description.split(`
21
+ `).filter(j=>j.trim()!=="").join(`
22
+ *${" ".repeat(1)}`)),W[p]=((l=W[p])!=null?l:"")+(i?`/**
23
+ ${i}
15
24
  */
16
- `:"")+"export type "+y+" = "+(typeof a=="string"?a:f(a))+`;
17
- `;});}});let ye=s=>{let r="";if(s.content){let $=Object.keys(s.content);$[0]&&s.content[$[0]].schema&&(r+=`${q(f$1,s.content[$[0]].schema,"")}`);}return r},rt=s=>{var r,$,u,n,p;if(($=(r=e$1==null?void 0:e$1.endpoints)==null?void 0:r.value)!=null&&$.replaceWords&&Array.isArray(e$1==null?void 0:e$1.endpoints.value.replaceWords)){let y=s;return (p=(n=(u=e$1==null?void 0:e$1.endpoints)==null?void 0:u.value)==null?void 0:n.replaceWords)==null||p.forEach((a,o)=>{let m=new RegExp(a.replace,"g");y=y.replace(m,a.with||"");}),y}else return s},st=(s,r,$=[])=>{var p,y;let u=(p=e$1==null?void 0:e$1.endpoints)==null?void 0:p.exclude,n=(y=e$1==null?void 0:e$1.endpoints)==null?void 0:y.include;if(n){let a=n.tags&&n.tags.length>0?$.some(m=>n.tags.includes(m)):true,o=n.endpoints&&n.endpoints.length>0?n.endpoints.some(m=>{let b=!m.method||m.method.toLowerCase()===r.toLowerCase();return m.path?s===m.path&&b:m.regex?new RegExp(m.regex).test(s)&&b:false}):true;if(!a||!o)return true}return !!(u&&(u.tags&&u.tags.length>0&&$.some(o=>u.tags.includes(o))||u.endpoints&&u.endpoints.length>0&&u.endpoints.some(o=>{let m=!o.method||o.method.toLowerCase()===r.toLowerCase();return o.path?s===o.path&&m:o.regex?new RegExp(o.regex).test(s)&&m:false})))};if(Object.keys(f$1.paths||{}).forEach(s=>{let r=f$1.paths[s];Object.keys(r).forEach(u=>{var ee,be,Ce,ce,Ae,xe,Ee,Te,we,Se,Re,ve,Ne,Fe,Pe,qe,ke,Be,Me,Ue,Je,Ke,Le,Ve;let n=u,p=e(s,n),y=((ee=r[n])==null?void 0:ee.tags)||[];if(st(s,n,y))return;let a=r[n],o=T({method:n,path:s,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId,tags:y,parameters:a==null?void 0:a.parameters,requestBody:a==null?void 0:a.requestBody,responses:a==null?void 0:a.responses});P[o]||(P[o]={endpoints:"",types:""});let m=((Ce=(be=e$1==null?void 0:e$1.endpoints)==null?void 0:be.value)!=null&&Ce.includeServer?G:"")+p.pathParts.map(d=>(d[0]==="{"&&d[d.length-1]==="}"?d=`\${${d.replace(/{/,"").replace(/}/,"")}}`:d[0]==="<"&&d[d.length-1]===">"?d=`\${${d.replace(/</,"").replace(/>/,"")}}`:d[0]===":"&&(d=`\${${d.replace(/:/,"")}}`),d)).join("/"),b=`"${m}"`;p.variables.length>0&&(b=`(${p.variables.map(l=>`${l}:string`).join(",")})=> \`${m}\``),b=rt(b);let t=r[n],i="";if(t!=null&&t.parameters&&((t==null?void 0:t.parameters).forEach((l,x)=>{(l.$ref||l.in==="query"&&l.name)&&(i+=`${q(f$1,l.$ref?l:l.schema,l.name||"",l.required)}`);}),i)){i=`{
18
- ${i}}`;let l=`${p.name}Query`;if((Ae=(ce=e$1==null?void 0:e$1.types)==null?void 0:ce.name)!=null&&Ae.useOperationId&&(t!=null&&t.operationId)&&(l=`${t.operationId}Query`),l=d(`${R}${l}`),(Ee=(xe=e$1==null?void 0:e$1.types)==null?void 0:xe.name)!=null&&Ee.format){let v=e$1==null?void 0:e$1.types.name.format("endpoint",{code:"",type:"query",method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},l);v&&(l=`${R}${v}`);}let x=`export type ${l} = ${i};
19
- `;e$1!=null&&e$1.folderSplit?P[o].types+=x:Q+=x;}let h=t==null?void 0:t.requestBody,C="";if(h&&(C=ye(h),C)){let d$1=`${p.name}DTO`;if((we=(Te=e$1==null?void 0:e$1.types)==null?void 0:Te.name)!=null&&we.useOperationId&&(t!=null&&t.operationId)&&(d$1=`${t.operationId}DTO`),d$1=d(`${R}${d$1}`),(Re=(Se=e$1==null?void 0:e$1.types)==null?void 0:Se.name)!=null&&Re.format){let x=e$1==null?void 0:e$1.types.name.format("endpoint",{code:"",type:"dto",method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},d$1);x&&(d$1=`${R}${x}`);}let l=`export type ${d$1} = ${C};
20
- `;e$1!=null&&e$1.folderSplit?P[o].types+=l:Q+=l;}let c={},A="";if(t!=null&&t.responses){let d$1=t==null?void 0:t.responses;Object.keys(d$1).forEach(x=>{var v,N,E,S;if(A=ye(d$1[x]),c[x]=A,A){let O=`${p.name}${x}Response`;if((N=(v=e$1==null?void 0:e$1.types)==null?void 0:v.name)!=null&&N.useOperationId&&(t!=null&&t.operationId)&&(O=`${t.operationId}${x}Response`),O=d(`${R}${O}`),(S=(E=e$1==null?void 0:e$1.types)==null?void 0:E.name)!=null&&S.format){let H=e$1==null?void 0:e$1.types.name.format("endpoint",{code:x,type:"response",method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},O);H&&(O=`${R}${H}`);}let B=`export type ${O} = ${A};
21
- `;e$1!=null&&e$1.folderSplit?P[o].types+=B:Q+=B;}});}let z=d=>!d||!d.length?"":d.map(l=>Object.entries(l).map(([v,N])=>{let E=v,S="";return Array.isArray(N)&&N.length&&(S=`
22
- - Scopes: [\`${N.join("`, `")}\`]`,E=`**${E}**`),`
23
- - ${E}${S}`}).join("")).join(`
24
- `),k=t!=null&&t.security?z(t.security):"",K="";if(!((Ne=(ve=e$1==null?void 0:e$1.endpoints)==null?void 0:ve.doc)!=null&&Ne.disable)){let d="";if((Pe=(Fe=e$1==null?void 0:e$1.endpoints)==null?void 0:Fe.doc)!=null&&Pe.showCurl){let l={},x="",v="";(qe=t.requestBody)!=null&&qe.content&&Object.keys(t.requestBody.content).forEach(S=>{let O=t.requestBody.content[S].schema;if(O){Array.isArray(l["Content-type"])?l["Content-type"].push(S):l["Content-type"]=[S];let B=J(f$1,O);B&&(x=B);}}),t!=null&&t.security&&t.security.forEach(E=>{Object.keys(E).forEach(S=>{var B,H;let O=(H=(B=f$1.components)==null?void 0:B.securitySchemes)==null?void 0:H[S];O&&(O.type==="mutualTLS"?v+=`
25
- --cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:O.type==="apiKey"?l[(O==null?void 0:O.name)||"X-API-KEY"]="{API_KEY_VALUE}":l.Authorization=`${(O==null?void 0:O.scheme)==="basic"?"Basic":"Bearer"} {${(O==null?void 0:O.scheme)==="basic"?"VALUE":"TOKEN"}}`);});});let N={};Object.keys(l).forEach(E=>{Array.isArray(l[E])?N[E]=l[E].join("; "):N[E]=l[E];}),d=`
25
+ `:"")+"export type "+c+" = "+(typeof a=="string"?a:_(a))+`;
26
+ `;});}});let $e=s=>{let r="";if(s.content){let I=Object.keys(s.content);I[0]&&s.content[I[0]].schema&&(r+=`${J(u,s.content[I[0]].schema,"")}`);}return r},nt=s=>{var r,I,f,n,p;if((I=(r=e==null?void 0:e.endpoints)==null?void 0:r.value)!=null&&I.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let c=s;return (p=(n=(f=e==null?void 0:e.endpoints)==null?void 0:f.value)==null?void 0:n.replaceWords)==null||p.forEach((a,i)=>{let y=new RegExp(a.replace,"g");c=c.replace(y,a.with||"");}),c}else return s},at=(s,r,I=[])=>{var p,c;let f=(p=e==null?void 0:e.endpoints)==null?void 0:p.exclude,n=(c=e==null?void 0:e.endpoints)==null?void 0:c.include;if(n){let a=n.tags&&n.tags.length>0?I.some(y=>n.tags.includes(y)):true,i=n.endpoints&&n.endpoints.length>0?n.endpoints.some(y=>{let E=!y.method||y.method.toLowerCase()===r.toLowerCase();return y.path?s===y.path&&E:y.regex?new RegExp(y.regex).test(s)&&E:false}):true;if(!a||!i)return true}return !!(f&&(f.tags&&f.tags.length>0&&I.some(i=>f.tags.includes(i))||f.endpoints&&f.endpoints.length>0&&f.endpoints.some(i=>{let y=!i.method||i.method.toLowerCase()===r.toLowerCase();return i.path?s===i.path&&y:i.regex?new RegExp(i.regex).test(s)&&y:false})))};if(Object.keys(u.paths||{}).forEach(s=>{let r=u.paths[s];Object.keys(r).forEach(f=>{var se,be,xe,Ce,Ae,Ee,Te,we,Se,Ne,Re,ve,Fe,Pe,ke,qe,Be,Me,Je,Ue,Le,ze,Ke,Ve;let n=f,p=Qe(s,n),c=((se=r[n])==null?void 0:se.tags)||[];if(at(s,n,c))return;let a=r[n],i=R({method:n,path:s,summary:a==null?void 0:a.summary,operationId:a==null?void 0:a.operationId,tags:c,parameters:a==null?void 0:a.parameters,requestBody:a==null?void 0:a.requestBody,responses:a==null?void 0:a.responses});O[i]||(O[i]={endpoints:"",types:""});let y=((xe=(be=e==null?void 0:e.endpoints)==null?void 0:be.value)!=null&&xe.includeServer?G:"")+p.pathParts.map($=>($[0]==="{"&&$[$.length-1]==="}"?$=`\${${$.replace(/{/,"").replace(/}/,"")}}`:$[0]==="<"&&$[$.length-1]===">"?$=`\${${$.replace(/</,"").replace(/>/,"")}}`:$[0]===":"&&($=`\${${$.replace(/:/,"")}}`),$)).join("/"),E=`"${y}"`;p.variables.length>0&&(E=`(${p.variables.map(d=>`${d}:string`).join(",")})=> \`${y}\``),E=nt(E);let t=r[n],l="";if(t!=null&&t.parameters&&((t==null?void 0:t.parameters).forEach((d,N)=>{(d.$ref||d.in==="query"&&d.name)&&(l+=`${J(u,d.$ref?d:d.schema,d.name||"",d.required)}`);}),l)){l=`{
27
+ ${l}}`;let d=`${p.name}Query`;if((Ae=(Ce=e==null?void 0:e.types)==null?void 0:Ce.name)!=null&&Ae.useOperationId&&(t!=null&&t.operationId)&&(d=`${t.operationId}Query`),d=V(`${k}${d}`),(Te=(Ee=e==null?void 0:e.types)==null?void 0:Ee.name)!=null&&Te.format){let q=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"query",method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},d);q&&(d=`${k}${q}`);}let N=`export type ${d} = ${l};
28
+ `;e!=null&&e.folderSplit?O[i].types+=N:Q+=N;}let j=t==null?void 0:t.requestBody,T="";if(j&&(T=$e(j),T)){let $=`${p.name}DTO`;if((Se=(we=e==null?void 0:e.types)==null?void 0:we.name)!=null&&Se.useOperationId&&(t!=null&&t.operationId)&&($=`${t.operationId}DTO`),$=V(`${k}${$}`),(Re=(Ne=e==null?void 0:e.types)==null?void 0:Ne.name)!=null&&Re.format){let N=e==null?void 0:e.types.name.format("endpoint",{code:"",type:"dto",method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},$);N&&($=`${k}${N}`);}let d=`export type ${$} = ${T};
29
+ `;e!=null&&e.folderSplit?O[i].types+=d:Q+=d;}let w={},S="";if(t!=null&&t.responses){let $=t==null?void 0:t.responses;Object.keys($).forEach(N=>{var q,B,v,P;if(S=$e($[N]),w[N]=S,S){let x=`${p.name}${N}Response`;if((B=(q=e==null?void 0:e.types)==null?void 0:q.name)!=null&&B.useOperationId&&(t!=null&&t.operationId)&&(x=`${t.operationId}${N}Response`),x=V(`${k}${x}`),(P=(v=e==null?void 0:e.types)==null?void 0:v.name)!=null&&P.format){let X=e==null?void 0:e.types.name.format("endpoint",{code:N,type:"response",method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},x);X&&(x=`${k}${X}`);}let L=`export type ${x} = ${S};
30
+ `;e!=null&&e.folderSplit?O[i].types+=L:Q+=L;}});}let Z=$=>!$||!$.length?"":$.map(d=>Object.entries(d).map(([q,B])=>{let v=q,P="";return Array.isArray(B)&&B.length&&(P=`
31
+ - Scopes: [\`${B.join("`, `")}\`]`,v=`**${v}**`),`
32
+ - ${v}${P}`}).join("")).join(`
33
+ `),U=t!=null&&t.security?Z(t.security):"",K="";if(!((Fe=(ve=e==null?void 0:e.endpoints)==null?void 0:ve.doc)!=null&&Fe.disable)){let $="";if((ke=(Pe=e==null?void 0:e.endpoints)==null?void 0:Pe.doc)!=null&&ke.showCurl){let d={},N="",q="";(qe=t.requestBody)!=null&&qe.content&&Object.keys(t.requestBody.content).forEach(P=>{let x=t.requestBody.content[P].schema;if(x){Array.isArray(d["Content-type"])?d["Content-type"].push(P):d["Content-type"]=[P];let L=z(u,x);L&&(N=L);}}),t!=null&&t.security&&t.security.forEach(v=>{Object.keys(v).forEach(P=>{var L,X;let x=(X=(L=u.components)==null?void 0:L.securitySchemes)==null?void 0:X[P];x&&(x.type==="mutualTLS"?q+=`
34
+ --cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:x.type==="apiKey"?d[(x==null?void 0:x.name)||"X-API-KEY"]="{API_KEY_VALUE}":d.Authorization=`${(x==null?void 0:x.scheme)==="basic"?"Basic":"Bearer"} {${(x==null?void 0:x.scheme)==="basic"?"VALUE":"TOKEN"}}`);});});let B={};Object.keys(d).forEach(v=>{Array.isArray(d[v])?B[v]=d[v].join("; "):B[v]=d[v];}),$=`
26
35
  \`\`\`bash
27
- ${CurlGenerator({url:G+s,method:n.toUpperCase(),headers:N,body:x})}${v}
36
+ ${CurlGenerator({url:G+s,method:n.toUpperCase(),headers:B,body:N})}${q}
28
37
  \`\`\``;}K=`/**${t!=null&&t.description?`
29
38
  * ${t==null?void 0:t.description} `:""}
30
39
  * **Method**: \`${n.toUpperCase()}\`
31
40
  * **Summary**: ${(t==null?void 0:t.summary)||""}
32
- * **Tags**: [${((ke=t==null?void 0:t.tags)==null?void 0:ke.join(", "))||""}]
33
- * **OperationId**: ${(t==null?void 0:t.operationId)||""} ${i?`
34
- * **Query**: ${g(i)} `:""}${C?`
35
- * **DTO**: ${g(C)} `:""}${A?`
36
- * **Response**: ${Object.entries(c).map(([l,x])=>`
37
- - **${l}**: ${g(x,2)} `).join("")}`:""}${k?`
38
- * **Security**: ${k}
39
- `:""}${d}
41
+ * **Tags**: [${((Be=t==null?void 0:t.tags)==null?void 0:Be.join(", "))||""}]
42
+ * **OperationId**: ${(t==null?void 0:t.operationId)||""} ${l?`
43
+ * **Query**: ${ae(l)} `:""}${T?`
44
+ * **DTO**: ${ae(T)} `:""}${S?`
45
+ * **Response**: ${Object.entries(w).map(([d,N])=>`
46
+ - **${d}**: ${ae(N,2)} `).join("")}`:""}${U?`
47
+ * **Security**: ${U}
48
+ `:""}${$}
40
49
  */
41
- `;}let V=(Me=(Be=e$1==null?void 0:e$1.endpoints)==null?void 0:Be.name)!=null&&Me.useOperationId&&((Ue=t==null?void 0:t.operationId)==null?void 0:Ue.length)>0?t.operationId:`${p.name}`;if((Ke=(Je=e$1==null?void 0:e$1.endpoints)==null?void 0:Je.name)!=null&&Ke.format){let d=e$1==null?void 0:e$1.endpoints.name.format({method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},V);d&&(V=d);}let g$1={method:`"${n}"`,operationId:`"${t==null?void 0:t.operationId}"`,url:b,tags:(t==null?void 0:t.tags)||[]},Y=`${K}export const ${et}${V} = ${((Ve=(Le=e$1==null?void 0:e$1.endpoints)==null?void 0:Le.value)==null?void 0:Ve.type)==="object"?f(g$1):b};
42
- `;e$1!=null&&e$1.folderSplit?P[o].endpoints+=Y:ae+=Y;});}),e$1!=null&&e$1.folderSplit){for(let[s,r]of Object.entries(P))if(r.endpoints||r.types){let $=w.join(U,s);if(r.endpoints){let u=w.join(_,$,"endpoints.ts");yield F.promises.mkdir(w.dirname(u),{recursive:true}),yield F.promises.writeFile(u,r.endpoints);}if(r.types){let u=w.join(_,$,"types.ts");yield F.promises.mkdir(w.dirname(u),{recursive:true});let n=Object.values(L).length>0?`import * as Shared from "../shared";
50
+ `;}let Y=(Je=(Me=e==null?void 0:e.endpoints)==null?void 0:Me.name)!=null&&Je.useOperationId&&((Ue=t==null?void 0:t.operationId)==null?void 0:Ue.length)>0?t.operationId:`${p.name}`;if((ze=(Le=e==null?void 0:e.endpoints)==null?void 0:Le.name)!=null&&ze.format){let $=e==null?void 0:e.endpoints.name.format({method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},Y);$&&(Y=$);}let re={method:`"${n}"`,operationId:`"${t==null?void 0:t.operationId}"`,url:E,tags:(t==null?void 0:t.tags)||[]},H=`${K}export const ${rt}${Y} = ${((Ve=(Ke=e==null?void 0:e.endpoints)==null?void 0:Ke.value)==null?void 0:Ve.type)==="object"?_(re):E};
51
+ `;e!=null&&e.folderSplit?O[i].endpoints+=H:ie+=H;});}),e!=null&&e.folderSplit){for(let[s,r]of Object.entries(O))if(r.endpoints||r.types){let I=F.join(h,s);if(r.endpoints){let f=F.join(te,I,"endpoints.ts");yield M.promises.mkdir(F.dirname(f),{recursive:true}),yield M.promises.writeFile(f,r.endpoints);}if(r.types){let f=F.join(te,I,"types.ts");yield M.promises.mkdir(F.dirname(f),{recursive:true});let n=Object.values(W).length>0?`import * as Shared from "../shared";
43
52
 
44
- ${r.types}`:r.types;yield F.promises.writeFile(u,n);}}}if(ae.length>0){let s=w.join(_,U,"endpoints.ts");yield F.promises.mkdir(w.dirname(s),{recursive:true}),yield F.promises.writeFile(s,ae);}if(Object.values(L).length>0){let s=w.join(_,U,e$1!=null&&e$1.folderSplit?"":"types","shared.ts");yield F.promises.mkdir(w.dirname(s),{recursive:true}),yield F.promises.writeFile(s,Object.values(L).join(`
45
- `));}if(Q.length>0){let s=w.join(_,U,"types","index.ts");yield F.promises.mkdir(w.dirname(s),{recursive:true}),yield F.promises.writeFile(s,`${Object.values(L).length>0?`import * as Shared from "./shared";
53
+ ${r.types}`:r.types;yield M.promises.writeFile(f,n);}}}if(ie.length>0){let s=F.join(te,h,"endpoints.ts");yield M.promises.mkdir(F.dirname(s),{recursive:true}),yield M.promises.writeFile(s,ie);}if(Object.values(W).length>0){let s=F.join(te,h,e!=null&&e.folderSplit?"":"types","shared.ts");yield M.promises.mkdir(F.dirname(s),{recursive:true}),yield M.promises.writeFile(s,Object.values(W).join(`
54
+ `));}if(Q.length>0){let s=F.join(te,h,"types","index.ts");yield M.promises.mkdir(F.dirname(s),{recursive:true}),yield M.promises.writeFile(s,`${Object.values(W).length>0?`import * as Shared from "./shared";
46
55
 
47
- `:""}${Q}`);}}),ge=_e;var de=process.cwd(),Bt=I=>b(null,null,function*(){let j;try{a("esbuild-register");}catch(T){throw T}let e=w.join(de,"openapi.sync.js"),M=w.join(de,"openapi.sync.ts"),W=w.join(de,"openapi.sync.json"),ne=[e,M,W];try{for(let T of ne)F.existsSync(T)&&(j=a(T),Object.keys(j).length===1&&j.default&&(j=j.default));}catch(T){console.log(T);}typeof j=="function"&&(j=j());let f=j;if(!f)throw new Error("No config found");let U=Object.keys(f.api),P=I&&"refetchInterval"in I&&!isNaN(I==null?void 0:I.refetchInterval)?I.refetchInterval:f.refetchInterval;Xe();for(let T=0;T<U.length;T+=1){let G=U[T],R=f.api[G];ge(R,G,f,P);}});export{Bt as Init};
56
+ `:""}${Q}`);}}),tt=et;var ue=process.cwd(),zt=o=>ne(null,null,function*(){let m;try{D("esbuild-register");}catch(R){throw R}let e=F.join(ue,"openapi.sync.js"),C=F.join(ue,"openapi.sync.ts"),A=F.join(ue,"openapi.sync.json"),b=[e,C,A];try{for(let R of b)M.existsSync(R)&&(m=D(R),Object.keys(m).length===1&&m.default&&(m=m.default));}catch(R){console.log(R);}typeof m=="function"&&(m=m());let u=m;if(!u)throw new Error("No config found");let h=Object.keys(u.api),O=o&&"refetchInterval"in o&&!isNaN(o==null?void 0:o.refetchInterval)?o.refetchInterval:u.refetchInterval;De();for(let R=0;R<h.length;R+=1){let G=h[R],k=u.api[G];tt(k,G,u,O);}});export{zt as Init,_ as JSONStringify,V as capitalize,Qe as getEndpointDetails,Ot as getNestedValue,Ye as isJson,ot as isYamlString,ae as renderTypeRefMD,ft as variableName,We as variableNameChar,Ge as yamlStringToJson};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-sync",
3
- "version": "2.1.16",
3
+ "version": "2.1.17",
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",
@@ -1 +0,0 @@
1
- var b=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(o,r)=>(typeof require!="undefined"?require:o)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var c=(e,o,r)=>new Promise((A,z)=>{var Z=a=>{try{t(r.next(a));}catch($){z($);}},_=a=>{try{t(r.throw(a));}catch($){z($);}},t=a=>a.done?A(a.value):Promise.resolve(a.value).then(Z,_);t((r=r.apply(e,o)).next());});var l=/^[A-Za-z_$][A-Za-z0-9_$]*$/,m=/[A-Za-z0-9_$]/;export{b as a,c as b,l as c,m as d};
@@ -1,10 +0,0 @@
1
- import {d as d$1}from'./chunk-6GQNHE6A.mjs';import*as a from'js-yaml';var d=n=>["object"].includes(typeof n)&&!(n instanceof Blob),u=n=>{try{return a.load(n),!0}catch(s){let e=s;if(e instanceof a.YAMLException)return false;throw e}},h=n=>{if(u(n)){let s=a.load(n),e=JSON.stringify(s,null,2);return JSON.parse(e)}},p=n=>n.substring(0,1).toUpperCase()+n.substring(1),m=(n,s)=>{let e=n.split("/"),i=`${p(s)}`,o=[];return e.forEach(r=>{if(r[0]==="{"&&r[r.length-1]==="}"){let t=r.replace(/{/,"").replace(/}/,"");o.push(t),r=`$${t}`;}else if(r[0]==="<"&&r[r.length-1]===">"){let t=r.replace(/</,"").replace(/>/,"");o.push(t),r=`$${t}`;}else if(r[0]===":"){let t=r.replace(/:/,"");o.push(t),r=`$${t}`;}let l="";r.split("").forEach(t=>{let c=t;d$1.test(t)||(c="/"),l+=c;}),l.split("/").forEach(t=>{i+=p(t);});}),{name:i,variables:o,pathParts:e}},g=(n,s=1)=>{let e="{",i=Object.keys(n);for(let o=0;o<i.length;o++){let r=i[o],l=n[r];if(e+=`
2
- `+" ".repeat(s)+r+": ",Array.isArray(l)){e+="[";for(let t=0;t<l.length;t++){let c=l[t];typeof c=="object"&&c!==null?e+=g(c,s+1):e+=typeof c=="string"?`"${c}"`:c,t<l.length-1&&(e+=", ");}e+="]";}else typeof l=="object"&&l!==null?e+=""+g(l,s+1):e+=l.split(`
3
- `).filter(t=>t.trim()!=="").join(`
4
- ${" ".repeat(s)}`);o<i.length-1&&(e+=", ");}return e+=`
5
- ${" ".repeat(s-1)}}`,e},$=(n,s=1)=>`
6
- \`\`\`typescript
7
- ${" ".repeat(s)} ${n.split(`
8
- `).filter(e=>e.trim()!=="").join(`
9
- ${" ".repeat(s)} `)}
10
- \`\`\``;function j(n,s){return s.split(".").reduce((i,o)=>i&&i[o]!==void 0?i[o]:void 0,n)}export{d as a,u as b,h as c,p as d,m as e,g as f,$ as g,j as h};
@@ -1,14 +0,0 @@
1
- declare const isJson: (value: any) => boolean;
2
- declare const isYamlString: (fileContent: string) => boolean;
3
- declare const yamlStringToJson: (fileContent: string) => any;
4
- declare const capitalize: (text: string) => string;
5
- declare const getEndpointDetails: (path: string, method: string) => {
6
- name: string;
7
- variables: string[];
8
- pathParts: string[];
9
- };
10
- declare const JSONStringify: (obj: Record<string, any>, indent?: number) => string;
11
- declare const renderTypeRefMD: (typeRef: string, indent?: number) => string;
12
- declare function getNestedValue<T>(obj: object, path: string): T | undefined;
13
-
14
- export { JSONStringify, capitalize, getEndpointDetails, getNestedValue, isJson, isYamlString, renderTypeRefMD, yamlStringToJson };
package/dist/helpers.d.ts DELETED
@@ -1,14 +0,0 @@
1
- declare const isJson: (value: any) => boolean;
2
- declare const isYamlString: (fileContent: string) => boolean;
3
- declare const yamlStringToJson: (fileContent: string) => any;
4
- declare const capitalize: (text: string) => string;
5
- declare const getEndpointDetails: (path: string, method: string) => {
6
- name: string;
7
- variables: string[];
8
- pathParts: string[];
9
- };
10
- declare const JSONStringify: (obj: Record<string, any>, indent?: number) => string;
11
- declare const renderTypeRefMD: (typeRef: string, indent?: number) => string;
12
- declare function getNestedValue<T>(obj: object, path: string): T | undefined;
13
-
14
- export { JSONStringify, capitalize, getEndpointDetails, getNestedValue, isJson, isYamlString, renderTypeRefMD, yamlStringToJson };
package/dist/helpers.js DELETED
@@ -1,10 +0,0 @@
1
- 'use strict';var c=require('js-yaml');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 c__namespace=/*#__PURE__*/_interopNamespace(c);var p=/[A-Za-z0-9_$]/;var $=n=>["object"].includes(typeof n)&&!(n instanceof Blob),u=n=>{try{return c__namespace.load(n),!0}catch(s){let e=s;if(e instanceof c__namespace.YAMLException)return false;throw e}},h=n=>{if(u(n)){let s=c__namespace.load(n),e=JSON.stringify(s,null,2);return JSON.parse(e)}},f=n=>n.substring(0,1).toUpperCase()+n.substring(1),d=(n,s)=>{let e=n.split("/"),i=`${f(s)}`,o=[];return e.forEach(r=>{if(r[0]==="{"&&r[r.length-1]==="}"){let t=r.replace(/{/,"").replace(/}/,"");o.push(t),r=`$${t}`;}else if(r[0]==="<"&&r[r.length-1]===">"){let t=r.replace(/</,"").replace(/>/,"");o.push(t),r=`$${t}`;}else if(r[0]===":"){let t=r.replace(/:/,"");o.push(t),r=`$${t}`;}let l="";r.split("").forEach(t=>{let a=t;p.test(t)||(a="/"),l+=a;}),l.split("/").forEach(t=>{i+=f(t);});}),{name:i,variables:o,pathParts:e}},g=(n,s=1)=>{let e="{",i=Object.keys(n);for(let o=0;o<i.length;o++){let r=i[o],l=n[r];if(e+=`
2
- `+" ".repeat(s)+r+": ",Array.isArray(l)){e+="[";for(let t=0;t<l.length;t++){let a=l[t];typeof a=="object"&&a!==null?e+=g(a,s+1):e+=typeof a=="string"?`"${a}"`:a,t<l.length-1&&(e+=", ");}e+="]";}else typeof l=="object"&&l!==null?e+=""+g(l,s+1):e+=l.split(`
3
- `).filter(t=>t.trim()!=="").join(`
4
- ${" ".repeat(s)}`);o<i.length-1&&(e+=", ");}return e+=`
5
- ${" ".repeat(s-1)}}`,e},x=(n,s=1)=>`
6
- \`\`\`typescript
7
- ${" ".repeat(s)} ${n.split(`
8
- `).filter(e=>e.trim()!=="").join(`
9
- ${" ".repeat(s)} `)}
10
- \`\`\``;function b(n,s){return s.split(".").reduce((i,o)=>i&&i[o]!==void 0?i[o]:void 0,n)}exports.JSONStringify=g;exports.capitalize=f;exports.getEndpointDetails=d;exports.getNestedValue=b;exports.isJson=$;exports.isYamlString=u;exports.renderTypeRefMD=x;exports.yamlStringToJson=h;
package/dist/helpers.mjs DELETED
@@ -1 +0,0 @@
1
- export{f as JSONStringify,d as capitalize,e as getEndpointDetails,h as getNestedValue,a as isJson,b as isYamlString,g as renderTypeRefMD,c as yamlStringToJson}from'./chunk-ALDCDVEN.mjs';import'./chunk-6GQNHE6A.mjs';
package/dist/regex.d.mts DELETED
@@ -1,4 +0,0 @@
1
- declare const variableName: RegExp;
2
- declare const variableNameChar: RegExp;
3
-
4
- export { variableName, variableNameChar };
package/dist/regex.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare const variableName: RegExp;
2
- declare const variableNameChar: RegExp;
3
-
4
- export { variableName, variableNameChar };
package/dist/regex.js DELETED
@@ -1 +0,0 @@
1
- 'use strict';var a=/^[A-Za-z_$][A-Za-z0-9_$]*$/,e=/[A-Za-z0-9_$]/;exports.variableName=a;exports.variableNameChar=e;
package/dist/regex.mjs DELETED
@@ -1 +0,0 @@
1
- export{c as variableName,d as variableNameChar}from'./chunk-6GQNHE6A.mjs';