openapi-sync 2.1.12 → 2.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![NPM Version](https://img.shields.io/npm/v/openapi-sync.svg)](https://www.npmjs.com/package/openapi-sync)
2
2
  [![License](https://img.shields.io/npm/l/openapi-sync.svg)](https://github.com/akintomiwa-fisayo/openapi-sync/blob/main/LICENSE)
3
+ [![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)](https://github.com/akintomiwa-fisayo/openapi-sync)
3
4
 
4
5
  **OpenAPI Sync** is a powerful developer tool that automates the synchronization of your API documentation with your codebase using OpenAPI (formerly Swagger) specifications. It generates TypeScript types, endpoint definitions, and comprehensive documentation from your OpenAPI schema, ensuring your API documentation stays up-to-date with your code.
5
6
 
@@ -436,15 +437,12 @@ OpenAPI Sync generates a structured output in your specified folder:
436
437
  ```
437
438
  src/api/
438
439
  ├── petstore/
439
- │ ├── endpoints.ts # Endpoint URLs and metadata
440
- │ └── types/
441
- ├── index.ts # Endpoint-specific types
442
- └── shared.ts # Shared component types
443
- └── auth-api/
444
- ├── endpoints.ts
445
- └── types/
446
- ├── index.ts
447
- └── shared.ts
440
+ │ ├── endpoints.ts # Endpoint URLs and metadata
441
+ │ └── types.ts # Endpoint-specific types
442
+ ├── auth-api/
443
+ ├── endpoints.ts # Endpoint URLs and metadata
444
+ └── types.ts # Endpoint-specific types
445
+ └── shared.ts # Shared component types
448
446
  ```
449
447
 
450
448
  ### Folder Splitting Structure
@@ -456,26 +454,21 @@ src/api/
456
454
  ├── petstore/
457
455
  │ ├── admin/ # Endpoints with "admin" tag
458
456
  │ │ ├── endpoints.ts
459
- │ │ └── types/
460
- │ │ ├── index.ts
461
- │ │ └── shared.ts
457
+ │ │ └── types.ts
462
458
  │ ├── public/ # Endpoints with "public" tag
463
459
  │ │ ├── endpoints.ts
464
- │ │ └── types/
465
- │ │ ├── index.ts
466
- │ │ └── shared.ts
460
+ │ │ └── types.ts
467
461
  │ └── user/ # Endpoints with "user" tag
468
462
  │ ├── endpoints.ts
469
- │ └── types/
470
- │ ├── index.ts
471
- └── shared.ts
472
- └── auth-api/
473
- ├── v1/ # Custom folder logic
474
- ├── endpoints.ts
475
- └── types/
476
- └── v2/
477
- ├── endpoints.ts
478
- └── types/
463
+ │ └── types.ts
464
+ │── auth-api/
465
+ ├── v1/ # Custom folder logic
466
+ │ │ ├── endpoints.ts
467
+ │ │ └── types.ts
468
+ └── v2/
469
+ ├── endpoints.ts
470
+ └── types.ts
471
+ └── shared.ts # Shared component types
479
472
  ```
480
473
 
481
474
  ### Generated Endpoints
@@ -1186,9 +1179,21 @@ The tool maintains state in `db.json` to track changes:
1186
1179
 
1187
1180
  ### Previous Versions
1188
1181
 
1182
+ - v2.1.13: Fix dts type fixes and Clean up tsup build config and introduction of unit testing
1183
+ - v2.1.12: Add automatic sync support for function-based config, improved handling of missing OpenAPI urls
1184
+ - v2.1.11: Folder splitting configuration for organized code generation
1185
+ - v2.1.10: OperationId-based naming for types and endpoints, enhanced filtering and tag support
1189
1186
  - v2.1.9: Enhanced JSONStringify function improvements
1190
1187
  - v2.1.8: File extension corrections and path handling
1191
1188
  - v2.1.7: Endpoint tags support in API documentation
1189
+ - v2.1.6: Improved handling of nullable fields in generated types
1190
+ - v2.1.5: Fixed bug with recursive schema references
1191
+ - v2.1.4: Enhanced error messages on invalid config
1192
+ - v2.1.3: Add more informative debugging logs
1193
+ - v2.1.2: Support enum descriptions in output
1194
+ - v2.1.1: Update dependencies, minor TypeScript type fixes
1195
+ - v2.1.0: Initial v2 major release with new sync engine
1196
+ - v2.0.0: Major refactor and breaking changes for v2
1192
1197
 
1193
1198
  ## License
1194
1199
 
package/bin/cli.js CHANGED
@@ -7,6 +7,7 @@ const { hideBin } = require("yargs/helpers");
7
7
 
8
8
  // Setup yargs
9
9
  const argv = yargs(hideBin(process.argv))
10
+ .usage("Usage: $0 [options]")
10
11
  .option("refreshinterval", {
11
12
  alias: "ri",
12
13
  type: "number",
@@ -0,0 +1 @@
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};
@@ -0,0 +1,10 @@
1
+ import{d as f}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!1;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;f.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};
@@ -0,0 +1,14 @@
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 };
@@ -0,0 +1,14 @@
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 };
@@ -0,0 +1,10 @@
1
+ "use strict";var $=Object.create;var p=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var j=(e,n)=>{for(var t in n)p(e,t,{get:n[t],enumerable:!0})},u=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of d(n))!b.call(e,r)&&r!==t&&p(e,r,{get:()=>n[r],enumerable:!(i=h(n,r))||i.enumerable});return e};var N=(e,n,t)=>(t=e!=null?$(x(e)):{},u(n||!e||!e.__esModule?p(t,"default",{value:e,enumerable:!0}):t,e)),S=e=>u(p({},"__esModule",{value:!0}),e);var k={};j(k,{JSONStringify:()=>g,capitalize:()=>f,getEndpointDetails:()=>E,getNestedValue:()=>T,isJson:()=>z,isYamlString:()=>m,renderTypeRefMD:()=>J,yamlStringToJson:()=>A});module.exports=S(k);var y=/[A-Za-z0-9_$]/;var c=N(require("js-yaml")),z=e=>["object"].includes(typeof e)&&!(e instanceof Blob),m=e=>{try{return c.load(e),!0}catch(n){let t=n;if(t instanceof c.YAMLException)return!1;throw t}},A=e=>{if(m(e)){let n=c.load(e),t=JSON.stringify(n,null,2);return JSON.parse(t)}},f=e=>e.substring(0,1).toUpperCase()+e.substring(1),E=(e,n)=>{let t=e.split("/"),i=`${f(n)}`,r=[];return t.forEach(o=>{if(o[0]==="{"&&o[o.length-1]==="}"){let s=o.replace(/{/,"").replace(/}/,"");r.push(s),o=`$${s}`}else if(o[0]==="<"&&o[o.length-1]===">"){let s=o.replace(/</,"").replace(/>/,"");r.push(s),o=`$${s}`}else if(o[0]===":"){let s=o.replace(/:/,"");r.push(s),o=`$${s}`}let l="";o.split("").forEach(s=>{let a=s;y.test(s)||(a="/"),l+=a}),l.split("/").forEach(s=>{i+=f(s)})}),{name:i,variables:r,pathParts:t}},g=(e,n=1)=>{let t="{",i=Object.keys(e);for(let r=0;r<i.length;r++){let o=i[r],l=e[o];if(t+=`
2
+ `+" ".repeat(n)+o+": ",Array.isArray(l)){t+="[";for(let s=0;s<l.length;s++){let a=l[s];typeof a=="object"&&a!==null?t+=g(a,n+1):t+=typeof a=="string"?`"${a}"`:a,s<l.length-1&&(t+=", ")}t+="]"}else typeof l=="object"&&l!==null?t+=""+g(l,n+1):t+=l.split(`
3
+ `).filter(s=>s.trim()!=="").join(`
4
+ ${" ".repeat(n)}`);r<i.length-1&&(t+=", ")}return t+=`
5
+ ${" ".repeat(n-1)}}`,t},J=(e,n=1)=>`
6
+ \`\`\`typescript
7
+ ${" ".repeat(n)} ${e.split(`
8
+ `).filter(t=>t.trim()!=="").join(`
9
+ ${" ".repeat(n)} `)}
10
+ \`\`\``;function T(e,n){return n.split(".").reduce((i,r)=>i&&i[r]!==void 0?i[r]:void 0,e)}0&&(module.exports={JSONStringify,capitalize,getEndpointDetails,getNestedValue,isJson,isYamlString,renderTypeRefMD,yamlStringToJson});
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-ALDCDVEN.mjs";import"./chunk-6GQNHE6A.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};
package/dist/index.d.mts CHANGED
@@ -1,4 +1,6 @@
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';
2
4
 
3
5
  type IOpenApiSpec = Record<"openapi", string> & Record<string, any>;
4
6
  type IOpenApSchemaSpec = {
@@ -149,24 +151,8 @@ type IOpenApiSecuritySchemes = {
149
151
  };
150
152
  };
151
153
 
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
-
168
154
  declare const Init: (options?: {
169
155
  refetchInterval?: number;
170
156
  }) => Promise<void>;
171
157
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
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';
2
4
 
3
5
  type IOpenApiSpec = Record<"openapi", string> & Record<string, any>;
4
6
  type IOpenApSchemaSpec = {
@@ -149,24 +151,8 @@ type IOpenApiSecuritySchemes = {
149
151
  };
150
152
  };
151
153
 
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
-
168
154
  declare const Init: (options?: {
169
155
  refetchInterval?: number;
170
156
  }) => Promise<void>;
171
157
 
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 };
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 };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ ${" ".repeat(i-1)}}`,e},ee=(n,i=1)=>`
7
7
  ${" ".repeat(i)} ${n.split(`
8
8
  `).filter(e=>e.trim()!=="").join(`
9
9
  ${" ".repeat(i)} `)}
10
- \`\`\``;function Tt(n,i){return i.split(".").reduce((j,O)=>j&&j[O]!==void 0?j[O]:void 0,n)}var at=q(require("lodash.isequal")),Ie=q(require("lodash.get")),it=q(require("axios")),lt=q(require("axios-retry")),pe=require("@redocly/openapi-core");var tt=q(require("path")),ie=q(require("fs")),le=tt.default.join(__dirname,"../","../db.json");ie.default.existsSync(le)||ie.default.writeFileSync(le,"{}");var ce={};try{ce=require(le)}catch(n){ce={}}var te=ce||{},rt=n=>{ie.default.writeFileSync(le,JSON.stringify(n))},st=(n,i)=>{te[n]=i,rt(te)},nt=n=>te[n],ot=()=>{te={},rt(te)};var pt=require("curl-generator");var re=process.cwd(),Oe={},mt=it.default.create({timeout:6e4});(0,lt.default)(mt,{retries:20,retryCondition:n=>n.code==="ECONNABORTED"||n.message.includes("Network Error"),retryDelay:n=>n*1e3});var dt=(n,i,e,j)=>ae(null,null,function*(){var Ae,Ee,Te,Se,we,Ne;let O=yield mt.get(n),x=yield(0,pe.createConfig)({extends:["minimal"]}),E=JSON.stringify($e(O.data)?O.data:fe(O.data)),c=yield(0,pe.bundleFromString)({source:E,config:x}),C=F.default.join((e==null?void 0:e.folder)||"",i),f=c.bundle.parsed,B={},de=s=>{var r,I;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let $=e.folderSplit.customFolder(s);if($)return $}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"},je=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((Ee=(Ae=f==null?void 0:f.servers)==null?void 0:Ae[(e==null?void 0:e.server)||0])==null?void 0:Ee.url)||"",L=typeof((Se=(Te=e==null?void 0:e.types)==null?void 0:Te.name)==null?void 0:Se.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",$t=typeof((Ne=(we=e==null?void 0:e.endpoints)==null?void 0:we.name)==null?void 0:Ne.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",Ce=(s,r)=>{var $,o;let I=V(s);if((o=($=e==null?void 0:e.types)==null?void 0:$.name)!=null&&o.format){let p=e==null?void 0:e.types.name.format("shared",{name:s},I);if(p)return`${L}${p}`}return`${L}${I}`},U=(s,r,I,$,o,p=0)=>{let h="",a="",l="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let m=(r.$ref||"").split("/");m.shift(),[...m].pop();let w=(0,Ie.default)(s,m,null);if(w){w!=null&&w.name&&(h=w.name),a=m[m.length-1];let N=Ce(a);N.includes(".")&&(N=N.split(".").map((z,Y)=>Y===0?z:`["${z}"]`).join("")),l+=`${o!=null&&o.noSharedImport?"":"Shared."}${N}`}}else l+="";else if(r.anyOf)l+=`(${r.anyOf.map(m=>U(s,m,"",$,o)).filter(m=>!!m).join("|")})`;else if(r.oneOf)l+=`(${r.oneOf.map(m=>U(s,m,"",$,o)).filter(m=>!!m).join("|")})`;else if(r.allOf)l+=`(${r.allOf.map(m=>U(s,m,"",$,o)).filter(m=>!!m).join("&")})`;else if(r.items)l+=`${U(s,r.items,"",!1,o)}[]`;else if(r.properties){let m=Object.keys(r.properties),b=r.required||[],S="";m.forEach(w=>{var X,z,Y,Q,se,D;let N="";!((z=(X=e==null?void 0:e.types)==null?void 0:X.doc)!=null&&z.disable)&&((Q=(Y=r.properties)==null?void 0:Y[w])!=null&&Q.description)&&(N=" * "+((se=r.properties)==null?void 0:se[w].description.split(`
10
+ \`\`\``;function Tt(n,i){return i.split(".").reduce((j,O)=>j&&j[O]!==void 0?j[O]:void 0,n)}var at=q(require("lodash.isequal")),Ie=q(require("lodash.get")),it=q(require("axios")),lt=q(require("axios-retry")),pe=require("@redocly/openapi-core");var tt=q(require("path")),ie=q(require("fs")),le=tt.default.join(__dirname,"../","../db.json");ie.default.existsSync(le)||ie.default.writeFileSync(le,"{}");var ce={};try{ce=require(le)}catch(n){ce={}}var te=ce||{},rt=n=>{ie.default.writeFileSync(le,JSON.stringify(n))},st=(n,i)=>{te[n]=i,rt(te)},nt=n=>te[n],ot=()=>{te={},rt(te)};var pt=require("curl-generator");var re=process.cwd(),Oe={},mt=it.default.create({timeout:6e4});(0,lt.default)(mt,{retries:20,retryCondition:n=>n.code==="ECONNABORTED"||n.message.includes("Network Error"),retryDelay:n=>n*1e3});var dt=(n,i,e,j)=>ae(null,null,function*(){var Ae,Ee,Te,Se,we,Ne;let O=yield mt.get(n),x=yield(0,pe.createConfig)({extends:["minimal"]}),E=JSON.stringify($e(O.data)?O.data:fe(O.data)),c=yield(0,pe.bundleFromString)({source:E,config:x}),C=F.default.join((e==null?void 0:e.folder)||"",i),f=c.bundle.parsed,B={},de=s=>{var r,I;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let $=e.folderSplit.customFolder(s);if(console.log("customFolder",$),$)return $}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"},je=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((Ee=(Ae=f==null?void 0:f.servers)==null?void 0:Ae[(e==null?void 0:e.server)||0])==null?void 0:Ee.url)||"",L=typeof((Se=(Te=e==null?void 0:e.types)==null?void 0:Te.name)==null?void 0:Se.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",$t=typeof((Ne=(we=e==null?void 0:e.endpoints)==null?void 0:we.name)==null?void 0:Ne.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",Ce=(s,r)=>{var $,o;let I=V(s);if((o=($=e==null?void 0:e.types)==null?void 0:$.name)!=null&&o.format){let p=e==null?void 0:e.types.name.format("shared",{name:s},I);if(p)return`${L}${p}`}return`${L}${I}`},U=(s,r,I,$,o,p=0)=>{let h="",a="",l="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let m=(r.$ref||"").split("/");m.shift(),[...m].pop();let w=(0,Ie.default)(s,m,null);if(w){w!=null&&w.name&&(h=w.name),a=m[m.length-1];let N=Ce(a);N.includes(".")&&(N=N.split(".").map((z,Y)=>Y===0?z:`["${z}"]`).join("")),l+=`${o!=null&&o.noSharedImport?"":"Shared."}${N}`}}else l+="";else if(r.anyOf)l+=`(${r.anyOf.map(m=>U(s,m,"",$,o)).filter(m=>!!m).join("|")})`;else if(r.oneOf)l+=`(${r.oneOf.map(m=>U(s,m,"",$,o)).filter(m=>!!m).join("|")})`;else if(r.allOf)l+=`(${r.allOf.map(m=>U(s,m,"",$,o)).filter(m=>!!m).join("&")})`;else if(r.items)l+=`${U(s,r.items,"",!1,o)}[]`;else if(r.properties){let m=Object.keys(r.properties),b=r.required||[],S="";m.forEach(w=>{var X,z,Y,Q,se,D;let N="";!((z=(X=e==null?void 0:e.types)==null?void 0:X.doc)!=null&&z.disable)&&((Q=(Y=r.properties)==null?void 0:Y[w])!=null&&Q.description)&&(N=" * "+((se=r.properties)==null?void 0:se[w].description.split(`
11
11
  `).filter(ne=>ne.trim()!=="").join(`
12
12
  *${" ".repeat(1)}`))),S+=(N?`/**
13
13
  ${N}
@@ -53,4 +53,4 @@ ${(0,pt.CurlGenerator)({url:je+s,method:o.toUpperCase(),headers:M,body:R})}${J}
53
53
  ${r.types}`:r.types;yield P.default.promises.writeFile($,o)}}}if(ue.length>0){let s=F.default.join(re,C,"endpoints.ts");yield P.default.promises.mkdir(F.default.dirname(s),{recursive:!0}),yield P.default.promises.writeFile(s,ue)}if(Object.values(G).length>0){let s=F.default.join(re,C,e!=null&&e.folderSplit?"":"types","shared.ts");yield P.default.promises.mkdir(F.default.dirname(s),{recursive:!0}),yield P.default.promises.writeFile(s,Object.values(G).join(`
54
54
  `))}if(H.length>0){let s=F.default.join(re,C,"types","index.ts");yield P.default.promises.mkdir(F.default.dirname(s),{recursive:!0}),yield P.default.promises.writeFile(s,`${Object.values(G).length>0?`import * as Shared from "./shared";
55
55
 
56
- `:""}${H}`)}}),ut=dt;var me=q(require("path")),yt=q(require("fs"));var be=process.cwd(),St=n=>ae(null,null,function*(){let i;try{require("esbuild-register")}catch(f){throw f}let e=me.default.join(be,"openapi.sync.js"),j=me.default.join(be,"openapi.sync.ts"),O=me.default.join(be,"openapi.sync.json"),x=[e,j,O];try{for(let f of x)yt.default.existsSync(f)&&(i=require(f),Object.keys(i).length===1&&i.default&&(i=i.default))}catch(f){}typeof i=="function"&&(i=i());let E=i;if(!E)throw new Error("No config found");let c=Object.keys(E.api),C=n&&"refetchInterval"in n&&!isNaN(n==null?void 0:n.refetchInterval)?n.refetchInterval:E.refetchInterval;ot();for(let f=0;f<c.length;f+=1){let B=c[f],de=E.api[B];ut(de,B,E,C)}});0&&(module.exports={Init,JSONStringify,capitalize,getEndpointDetails,getNestedValue,isJson,isYamlString,renderTypeRefMD,variableName,variableNameChar,yamlStringToJson});
56
+ `:""}${H}`)}}),ut=dt;var me=q(require("path")),yt=q(require("fs"));var be=process.cwd(),St=n=>ae(null,null,function*(){let i;try{require("esbuild-register")}catch(f){throw f}let e=me.default.join(be,"openapi.sync.js"),j=me.default.join(be,"openapi.sync.ts"),O=me.default.join(be,"openapi.sync.json"),x=[e,j,O];try{for(let f of x)yt.default.existsSync(f)&&(i=require(f),Object.keys(i).length===1&&i.default&&(i=i.default))}catch(f){console.log(f)}typeof i=="function"&&(i=i());let E=i;if(!E)throw new Error("No config found");let c=Object.keys(E.api),C=n&&"refetchInterval"in n&&!isNaN(n==null?void 0:n.refetchInterval)?n.refetchInterval:E.refetchInterval;ot();for(let f=0;f<c.length;f+=1){let B=c[f],de=E.api[B];ut(de,B,E,C)}});0&&(module.exports={Init,JSONStringify,capitalize,getEndpointDetails,getNestedValue,isJson,isYamlString,renderTypeRefMD,variableName,variableNameChar,yamlStringToJson});
package/dist/index.mjs CHANGED
@@ -1,56 +1,47 @@
1
- var D=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(m,e)=>(typeof require!="undefined"?require:m)[e]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var ne=(a,m,e)=>new Promise((x,A)=>{var j=b=>{try{c(e.next(b))}catch(f){A(f)}},E=b=>{try{c(e.throw(b))}catch(f){A(f)}},c=b=>b.done?x(b.value):Promise.resolve(b.value).then(j,E);c((e=e.apply(a,m)).next())});import J from"fs";import F from"path";var Ot=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Ge=/[A-Za-z0-9_$]/;import*as g from"js-yaml";var Qe=a=>["object"].includes(typeof a)&&!(a instanceof Blob),lt=a=>{try{return g.load(a),!0}catch(m){let e=m;if(e instanceof g.YAMLException)return!1;throw e}},Ze=a=>{if(lt(a)){let m=g.load(a),e=JSON.stringify(m,null,2);return JSON.parse(e)}},W=a=>a.substring(0,1).toUpperCase()+a.substring(1),He=(a,m)=>{let e=a.split("/"),x=`${W(m)}`,A=[];return e.forEach(j=>{if(j[0]==="{"&&j[j.length-1]==="}"){let c=j.replace(/{/,"").replace(/}/,"");A.push(c),j=`$${c}`}else if(j[0]==="<"&&j[j.length-1]===">"){let c=j.replace(/</,"").replace(/>/,"");A.push(c),j=`$${c}`}else if(j[0]===":"){let c=j.replace(/:/,"");A.push(c),j=`$${c}`}let E="";j.split("").forEach(c=>{let b=c;Ge.test(c)||(b="/"),E+=b}),E.split("/").forEach(c=>{x+=W(c)})}),{name:x,variables:A,pathParts:e}},_=(a,m=1)=>{let e="{",x=Object.keys(a);for(let A=0;A<x.length;A++){let j=x[A],E=a[j];if(e+=`
2
- `+" ".repeat(m)+j+": ",Array.isArray(E)){e+="[";for(let c=0;c<E.length;c++){let b=E[c];typeof b=="object"&&b!==null?e+=_(b,m+1):e+=typeof b=="string"?`"${b}"`:b,c<E.length-1&&(e+=", ")}e+="]"}else typeof E=="object"&&E!==null?e+=""+_(E,m+1):e+=E.split(`
3
- `).filter(c=>c.trim()!=="").join(`
4
- ${" ".repeat(m)}`);A<x.length-1&&(e+=", ")}return e+=`
5
- ${" ".repeat(m-1)}}`,e},oe=(a,m=1)=>`
6
- \`\`\`typescript
7
- ${" ".repeat(m)} ${a.split(`
8
- `).filter(e=>e.trim()!=="").join(`
9
- ${" ".repeat(m)} `)}
10
- \`\`\``;function jt(a,m){return m.split(".").reduce((x,A)=>x&&x[A]!==void 0?x[A]:void 0,a)}import mt from"lodash.isequal";import et from"lodash.get";import dt from"axios";import ut from"axios-retry";import{bundleFromString as yt,createConfig as $t}from"@redocly/openapi-core";import pt from"path";import pe from"fs";var ae=pt.join(__dirname,"../","../db.json");pe.existsSync(ae)||pe.writeFileSync(ae,"{}");var me={};try{me=D(ae)}catch(a){me={}}var ee=me||{},Xe=a=>{pe.writeFileSync(ae,JSON.stringify(a))},De=(a,m)=>{ee[a]=m,Xe(ee)},_e=a=>ee[a],ge=()=>{ee={},Xe(ee)};import{CurlGenerator as ft}from"curl-generator";var te=process.cwd(),de={},tt=dt.create({timeout:6e4});ut(tt,{retries:20,retryCondition:a=>a.code==="ECONNABORTED"||a.message.includes("Network Error"),retryDelay:a=>a*1e3});var rt=(a,m,e,x)=>ne(null,null,function*(){var ce,Oe,Ie,be,je,Ce;let A=yield tt.get(a),j=yield $t({extends:["minimal"]}),E=JSON.stringify(Qe(A.data)?A.data:Ze(A.data)),c=yield yt({source:E,config:j}),b=F.join((e==null?void 0:e.folder)||"",m),f=c.bundle.parsed,q={},ie=s=>{var r,O;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let $=e.folderSplit.customFolder(s);if($)return $}return(O=e==null?void 0:e.folderSplit)!=null&&O.byTags&&s.tags&&s.tags.length>0?s.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},$e=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((Oe=(ce=f==null?void 0:f.servers)==null?void 0:ce[(e==null?void 0:e.server)||0])==null?void 0:Oe.url)||"",U=typeof((be=(Ie=e==null?void 0:e.types)==null?void 0:Ie.name)==null?void 0:be.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",nt=typeof((Ce=(je=e==null?void 0:e.endpoints)==null?void 0:je.name)==null?void 0:Ce.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",fe=(s,r)=>{var $,n;let O=W(s);if((n=($=e==null?void 0:e.types)==null?void 0:$.name)!=null&&n.format){let l=e==null?void 0:e.types.name.format("shared",{name:s},O);if(l)return`${U}${l}`}return`${U}${O}`},M=(s,r,O,$,n,l=0)=>{let h="",o="",i="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let p=(r.$ref||"").split("/");p.shift(),[...p].pop();let w=et(s,p,null);if(w){w!=null&&w.name&&(h=w.name),o=p[p.length-1];let N=fe(o);N.includes(".")&&(N=N.split(".").map((L,V)=>V===0?L:`["${L}"]`).join("")),i+=`${n!=null&&n.noSharedImport?"":"Shared."}${N}`}}else i+="";else if(r.anyOf)i+=`(${r.anyOf.map(p=>M(s,p,"",$,n)).filter(p=>!!p).join("|")})`;else if(r.oneOf)i+=`(${r.oneOf.map(p=>M(s,p,"",$,n)).filter(p=>!!p).join("|")})`;else if(r.allOf)i+=`(${r.allOf.map(p=>M(s,p,"",$,n)).filter(p=>!!p).join("&")})`;else if(r.items)i+=`${M(s,r.items,"",!1,n)}[]`;else if(r.properties){let p=Object.keys(r.properties),I=r.required||[],S="";p.forEach(w=>{var Z,L,V,G,re,H;let N="";!((L=(Z=e==null?void 0:e.types)==null?void 0:Z.doc)!=null&&L.disable)&&((G=(V=r.properties)==null?void 0:V[w])!=null&&G.description)&&(N=" * "+((re=r.properties)==null?void 0:re[w].description.split(`
11
- `).filter(se=>se.trim()!=="").join(`
12
- *${" ".repeat(1)}`))),S+=(N?`/**
13
- ${N}
1
+ import{a as Qe,b as ft,c as ze,d as X,e as Ye,f as pe,g as re,h as Ot}from"./chunk-ALDCDVEN.mjs";import{a as H,b as te,c as $t,d as ht}from"./chunk-6GQNHE6A.mjs";import v from"fs";import T from"path";import pt from"lodash.isequal";import _e from"lodash.get";import it from"axios";import lt from"axios-retry";import{bundleFromString as dt,createConfig as mt}from"@redocly/openapi-core";import ot from"path";import ie from"fs";var se=ot.join(__dirname,"../","../db.json");ie.existsSync(se)||ie.writeFileSync(se,"{}");var le={};try{le=H(se)}catch(I){le={}}var Z=le||{},He=I=>{ie.writeFileSync(se,JSON.stringify(I))},Xe=(I,b)=>{Z[I]=b,He(Z)},Ze=I=>Z[I],De=()=>{Z={},He(Z)};import{CurlGenerator as ut}from"curl-generator";var D=process.cwd(),de={},ge=it.create({timeout:6e4});lt(ge,{retries:20,retryCondition:I=>I.code==="ECONNABORTED"||I.message.includes("Network Error"),retryDelay:I=>I*1e3});var et=(I,b,e,B)=>te(null,null,function*(){var fe,Oe,Ie,je,be,Ce;let W=yield ge.get(I),ne=yield mt({extends:["minimal"]}),M=JSON.stringify(Qe(W.data)?W.data:ze(W.data)),_=yield dt({source:M,config:ne}),K=T.join((e==null?void 0:e.folder)||"",b),h=_.bundle.parsed,R={},ae=s=>{var r,$;if((r=e==null?void 0:e.folderSplit)!=null&&r.customFolder){let u=e.folderSplit.customFolder(s);if(console.log("customFolder",u),u)return u}return($=e==null?void 0:e.folderSplit)!=null&&$.byTags&&s.tags&&s.tags.length>0?s.tags[0].toLowerCase().replace(/\s+/g,"-"):"default"},ye=typeof(e==null?void 0:e.server)=="string"?e==null?void 0:e.server:((Oe=(fe=h==null?void 0:h.servers)==null?void 0:fe[(e==null?void 0:e.server)||0])==null?void 0:Oe.url)||"",q=typeof((je=(Ie=e==null?void 0:e.types)==null?void 0:Ie.name)==null?void 0:je.prefix)=="string"?e==null?void 0:e.types.name.prefix:"I",rt=typeof((Ce=(be=e==null?void 0:e.endpoints)==null?void 0:be.name)==null?void 0:Ce.prefix)=="string"?e==null?void 0:e.endpoints.name.prefix:"",$e=(s,r)=>{var u,n;let $=X(s);if((n=(u=e==null?void 0:e.types)==null?void 0:u.name)!=null&&n.format){let p=e==null?void 0:e.types.name.format("shared",{name:s},$);if(p)return`${q}${p}`}return`${q}${$}`},F=(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=_e(s,i,null);if(c){c!=null&&c.name&&(y=c.name),a=i[i.length-1];let x=$e(a);x.includes(".")&&(x=x.split(".").map((P,J)=>J===0?P:`["${P}"]`).join("")),o+=`${n!=null&&n.noSharedImport?"":"Shared."}${x}`}}else o+="";else if(r.anyOf)o+=`(${r.anyOf.map(i=>F(s,i,"",u,n)).filter(i=>!!i).join("|")})`;else if(r.oneOf)o+=`(${r.oneOf.map(i=>F(s,i,"",u,n)).filter(i=>!!i).join("|")})`;else if(r.allOf)o+=`(${r.allOf.map(i=>F(s,i,"",u,n)).filter(i=>!!i).join("&")})`;else if(r.items)o+=`${F(s,r.items,"",!1,n)}[]`;else if(r.properties){let i=Object.keys(r.properties),f=r.required||[],C="";i.forEach(c=>{var Q,P,J,V,g,z;let x="";!((P=(Q=e==null?void 0:e.types)==null?void 0:Q.doc)!=null&&P.disable)&&((V=(J=r.properties)==null?void 0:J[c])!=null&&V.description)&&(x=" * "+((g=r.properties)==null?void 0:g[c].description.split(`
2
+ `).filter(ee=>ee.trim()!=="").join(`
3
+ *${" ".repeat(1)}`))),C+=(x?`/**
4
+ ${x}
14
5
  */
15
- `:"")+`${M(s,(H=r.properties)==null?void 0:H[w],w,I.includes(w),n,l+1)}`}),S.length>0?i+=`{
16
- ${" ".repeat(l)}${S}${" ".repeat(l)}}`:i+="{[k: string]: any}"}else if(r.enum&&r.enum.length>0)r.enum.length>1&&(i+="("),r.enum.map(p=>JSON.stringify(p)).filter(p=>!!p).forEach((p,I)=>{i+=`${I===0?"":"|"}${p}`}),r.enum.length>1&&(i+=")");else if(r.type){let p=I=>{let S="";if(typeof I=="string")["string","integer","number","array","boolean","null"].includes(I)?["integer","number"].includes(I)?S+="number":I==="array"?S+="any[]":S+=I:I==="object"&&(r.additionalProperties?S+=`{[k: string]: ${M(s,r.additionalProperties,"",!0,n)||"any"}}`:S+="{[k: string]: any}");else if(Array.isArray(I)){let w=I.map(N=>p(N));w.filter(N=>N!==""),w.length>1&&(S+="("+w.join("|")+")")}else S+="any";return S};i=p(r.type)}}else i="string";let u=h||O;n!=null&&n.useComponentName&&!u&&(u=o);let T=u?` "${u}"${$?"":"?"}: `:"",t=r!=null&&r.nullable?" | null":"";return i.length>0?`${T}${i}${t}${u?`;
17
- `:""}`:""},K=(s,r)=>{let O="",$="",n="";if(r){if(r.$ref)if(r.$ref[0]==="#"){let l=(r.$ref||"").split("/");l.shift();let o=et(s,l,null);o&&(o!=null&&o.name&&(O=o.name),$=l[l.length-1],n+=K(s,o))}else n+="";else if(r.anyOf)n+=K(s,r.anyOf[0]);else if(r.oneOf)n+=K(s,r.oneOf[0]);else if(r.allOf)n+=`{${r.allOf.map(l=>`...(${K(s,l)})`).join(",")}}`;else if(r.items)n+=`[${K(s,r.items)}]`;else if(r.properties){let o=Object.keys(r.properties).map(i=>{var u;return` "${i}": ${K(s,(u=r.properties)==null?void 0:u[i])}`}).join(`,
18
- `);o.length>0?n+=`{
6
+ `:"")+`${F(s,(z=r.properties)==null?void 0:z[c],c,f.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,f)=>{o+=`${f===0?"":"|"}${i}`}),r.enum.length>1&&(o+=")");else if(r.type){let i=f=>{let C="";if(typeof f=="string")["string","integer","number","array","boolean","null"].includes(f)?["integer","number"].includes(f)?C+="number":f==="array"?C+="any[]":C+=f:f==="object"&&(r.additionalProperties?C+=`{[k: string]: ${F(s,r.additionalProperties,"",!0,n)||"any"}}`:C+="{[k: string]: any}");else if(Array.isArray(f)){let c=f.map(x=>i(x));c.filter(x=>x!==""),c.length>1&&(C+="("+c.join("|")+")")}else C+="any";return C};o=i(r.type)}}else o="string";let d=y||$;n!=null&&n.useComponentName&&!d&&(d=a);let j=d?` "${d}"${u?"":"?"}: `:"",t=r!=null&&r.nullable?" | null":"";return o.length>0?`${j}${o}${t}${d?`;
8
+ `:""}`:""},U=(s,r)=>{let $="",u="",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),u=p[p.length-1],n+=U(s,a))}else n+="";else if(r.anyOf)n+=U(s,r.anyOf[0]);else if(r.oneOf)n+=U(s,r.oneOf[0]);else if(r.allOf)n+=`{${r.allOf.map(p=>`...(${U(s,p)})`).join(",")}}`;else if(r.items)n+=`[${U(s,r.items)}]`;else if(r.properties){let a=Object.keys(r.properties).map(o=>{var d;return` "${o}": ${U(s,(d=r.properties)==null?void 0:d[o])}`}).join(`,
9
+ `);a.length>0?n+=`{
10
+ ${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(d=>p(d));o.filter(d=>d!==""),o.length>1&&(a+=o.join("|"))}else a+="any";return a};n=p(r.type)}}else n="string";return n};B&&!isNaN(B)&&B>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(de[b]&&clearTimeout(de[b]),de[b]=setTimeout(()=>et(I,b,e,B),B)));let st=Ze(b);if(pt(st,h))return;Xe(b,h);let oe="",G="",L={};h.components&&Object.keys(h.components).forEach(s=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(s)){let r=h.components[s],$={},u={};Object.keys(r).forEach(p=>{var o;let y=(o=r[p])!=null&&o.schema?r[p].schema:r[p],a=`${F(h,y,"",!0,{noSharedImport:!0,useComponentName:["parameters"].includes(s)})}`;if(a){let d=p.split("."),j=$,t=u;for(let i=0;i<d.length;i++){let f=d[i];i<d.length-1?(f in j||(j[f]={},t[f]={}),j=j[f],t=t[f]):(j[f]=a,t[f]=y)}}}),Object.keys($).forEach(p=>{var d,j,t,i;let y=$e(p),a=$[p],o="";!((j=(d=e==null?void 0:e.types)==null?void 0:d.doc)!=null&&j.disable)&&p in r&&((t=r[p])!=null&&t.description)&&(o=" * "+r[p].description.split(`
12
+ `).filter(f=>f.trim()!=="").join(`
13
+ *${" ".repeat(1)}`)),L[p]=((i=L[p])!=null?i:"")+(o?`/**
19
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 l=h=>{let o="";if(typeof h=="string")["string","integer","number","array","boolean","null"].includes(h)?["integer","number"].includes(h)?o+="123":h==="array"?o+="[]":h==="boolean"?o+="true":h==="null"?o+="null":o+=`"${h}"`:h==="object"&&(o+="{}");else if(Array.isArray(h)){let i=h.map(u=>l(u));i.filter(u=>u!==""),i.length>1&&(o+=i.join("|"))}else o+="any";return o};n=l(r.type)}}else n="string";return n};x&&!isNaN(x)&&x>0&&(process.env.NODE_ENV&&["production","prod","test","staging"].includes(process.env.NODE_ENV)||(de[m]&&clearTimeout(de[m]),de[m]=setTimeout(()=>rt(a,m,e,x),x)));let ot=_e(m);if(mt(ot,f))return;De(m,f);let le="",Q="",Y={};f.components&&Object.keys(f.components).forEach(s=>{if(["schemas","responses","parameters","examples","requestBodies","headers","links","callbacks"].includes(s)){let r=f.components[s],O={},$={};Object.keys(r).forEach(l=>{var i;let h=(i=r[l])!=null&&i.schema?r[l].schema:r[l],o=`${M(f,h,"",!0,{noSharedImport:!0,useComponentName:["parameters"].includes(s)})}`;if(o){let u=l.split("."),T=O,t=$;for(let p=0;p<u.length;p++){let I=u[p];p<u.length-1?(I in T||(T[I]={},t[I]={}),T=T[I],t=t[I]):(T[I]=o,t[I]=h)}}}),Object.keys(O).forEach(l=>{var u,T,t,p;let h=fe(l),o=O[l],i="";!((T=(u=e==null?void 0:e.types)==null?void 0:u.doc)!=null&&T.disable)&&l in r&&((t=r[l])!=null&&t.description)&&(i=" * "+r[l].description.split(`
21
- `).filter(I=>I.trim()!=="").join(`
22
- *${" ".repeat(1)}`)),Y[l]=((p=Y[l])!=null?p:"")+(i?`/**
23
- ${i}
24
15
  */
25
- `:"")+"export type "+h+" = "+(typeof o=="string"?o:_(o))+`;
26
- `})}});let he=s=>{let r="";if(s.content){let O=Object.keys(s.content);O[0]&&s.content[O[0]].schema&&(r+=`${M(f,s.content[O[0]].schema,"")}`)}return r},at=s=>{var r,O,$,n,l;if((O=(r=e==null?void 0:e.endpoints)==null?void 0:r.value)!=null&&O.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let h=s;return(l=(n=($=e==null?void 0:e.endpoints)==null?void 0:$.value)==null?void 0:n.replaceWords)==null||l.forEach((o,i)=>{let u=new RegExp(o.replace,"g");h=h.replace(u,o.with||"")}),h}else return s},it=(s,r,O=[])=>{var l,h;let $=(l=e==null?void 0:e.endpoints)==null?void 0:l.exclude,n=(h=e==null?void 0:e.endpoints)==null?void 0:h.include;if(n){let o=n.tags&&n.tags.length>0?O.some(u=>n.tags.includes(u)):!0,i=n.endpoints&&n.endpoints.length>0?n.endpoints.some(u=>{let T=!u.method||u.method.toLowerCase()===r.toLowerCase();return u.path?s===u.path&&T:u.regex?new RegExp(u.regex).test(s)&&T:!1}):!0;if(!o||!i)return!0}return!!($&&($.tags&&$.tags.length>0&&O.some(i=>$.tags.includes(i))||$.endpoints&&$.endpoints.length>0&&$.endpoints.some(i=>{let u=!i.method||i.method.toLowerCase()===r.toLowerCase();return i.path?s===i.path&&u:i.regex?new RegExp(i.regex).test(s)&&u:!1})))};if(Object.keys(f.paths||{}).forEach(s=>{let r=f.paths[s];Object.keys(r).forEach($=>{var se,xe,Ae,Ee,Te,Se,we,Ne,Re,ve,Fe,ke,qe,Pe,Be,Je,Me,Ue,Le,ze,Ke,Ve,We,Ye;let n=$,l=He(s,n),h=((se=r[n])==null?void 0:se.tags)||[];if(it(s,n,h))return;let o=r[n],i=ie({method:n,path:s,summary:o==null?void 0:o.summary,operationId:o==null?void 0:o.operationId,tags:h,parameters:o==null?void 0:o.parameters,requestBody:o==null?void 0:o.requestBody,responses:o==null?void 0:o.responses});q[i]||(q[i]={endpoints:"",types:""});let u=((Ae=(xe=e==null?void 0:e.endpoints)==null?void 0:xe.value)!=null&&Ae.includeServer?$e:"")+l.pathParts.map(y=>(y[0]==="{"&&y[y.length-1]==="}"?y=`\${${y.replace(/{/,"").replace(/}/,"")}}`:y[0]==="<"&&y[y.length-1]===">"?y=`\${${y.replace(/</,"").replace(/>/,"")}}`:y[0]===":"&&(y=`\${${y.replace(/:/,"")}}`),y)).join("/"),T=`"${u}"`;l.variables.length>0&&(T=`(${l.variables.map(d=>`${d}:string`).join(",")})=> \`${u}\``),T=at(T);let t=r[n],p="";if(t!=null&&t.parameters&&((t==null?void 0:t.parameters).forEach((d,R)=>{(d.$ref||d.in==="query"&&d.name)&&(p+=`${M(f,d.$ref?d:d.schema,d.name||"",d.required)}`)}),p)){p=`{
27
- ${p}}`;let d=`${l.name}Query`;if((Te=(Ee=e==null?void 0:e.types)==null?void 0:Ee.name)!=null&&Te.useOperationId&&(t!=null&&t.operationId)&&(d=`${t.operationId}Query`),d=W(`${U}${d}`),(we=(Se=e==null?void 0:e.types)==null?void 0:Se.name)!=null&&we.format){let P=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);P&&(d=`${U}${P}`)}let R=`export type ${d} = ${p};
28
- `;e!=null&&e.folderSplit?q[i].types+=R:Q+=R}let I=t==null?void 0:t.requestBody,S="";if(I&&(S=he(I),S)){let y=`${l.name}DTO`;if((Re=(Ne=e==null?void 0:e.types)==null?void 0:Ne.name)!=null&&Re.useOperationId&&(t!=null&&t.operationId)&&(y=`${t.operationId}DTO`),y=W(`${U}${y}`),(Fe=(ve=e==null?void 0:e.types)==null?void 0:ve.name)!=null&&Fe.format){let R=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},y);R&&(y=`${U}${R}`)}let d=`export type ${y} = ${S};
29
- `;e!=null&&e.folderSplit?q[i].types+=d:Q+=d}let w={},N="";if(t!=null&&t.responses){let y=t==null?void 0:t.responses;Object.keys(y).forEach(R=>{var P,B,v,k;if(N=he(y[R]),w[R]=N,N){let C=`${l.name}${R}Response`;if((B=(P=e==null?void 0:e.types)==null?void 0:P.name)!=null&&B.useOperationId&&(t!=null&&t.operationId)&&(C=`${t.operationId}${R}Response`),C=W(`${U}${C}`),(k=(v=e==null?void 0:e.types)==null?void 0:v.name)!=null&&k.format){let X=e==null?void 0:e.types.name.format("endpoint",{code:R,type:"response",method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},C);X&&(C=`${U}${X}`)}let z=`export type ${C} = ${N};
30
- `;e!=null&&e.folderSplit?q[i].types+=z:Q+=z}})}let Z=y=>!y||!y.length?"":y.map(d=>Object.entries(d).map(([P,B])=>{let v=P,k="";return Array.isArray(B)&&B.length&&(k=`
31
- - Scopes: [\`${B.join("`, `")}\`]`,v=`**${v}**`),`
32
- - ${v}${k}`}).join("")).join(`
33
- `),L=t!=null&&t.security?Z(t.security):"",V="";if(!((qe=(ke=e==null?void 0:e.endpoints)==null?void 0:ke.doc)!=null&&qe.disable)){let y="";if((Be=(Pe=e==null?void 0:e.endpoints)==null?void 0:Pe.doc)!=null&&Be.showCurl){let d={},R="",P="";(Je=t.requestBody)!=null&&Je.content&&Object.keys(t.requestBody.content).forEach(k=>{let C=t.requestBody.content[k].schema;if(C){Array.isArray(d["Content-type"])?d["Content-type"].push(k):d["Content-type"]=[k];let z=K(f,C);z&&(R=z)}}),t!=null&&t.security&&t.security.forEach(v=>{Object.keys(v).forEach(k=>{var z,X;let C=(X=(z=f.components)==null?void 0:z.securitySchemes)==null?void 0:X[k];C&&(C.type==="mutualTLS"?P+=`
34
- --cert client-certificate.crt --key client-private-key.key --cacert ca-certificate.crt`:C.type==="apiKey"?d[(C==null?void 0:C.name)||"X-API-KEY"]="{API_KEY_VALUE}":d.Authorization=`${(C==null?void 0:C.scheme)==="basic"?"Basic":"Bearer"} {${(C==null?void 0:C.scheme)==="basic"?"VALUE":"TOKEN"}}`)})});let B={};Object.keys(d).forEach(v=>{Array.isArray(d[v])?B[v]=d[v].join("; "):B[v]=d[v]}),y=`
16
+ `:"")+"export type "+y+" = "+(typeof a=="string"?a:pe(a))+`;
17
+ `})}});let he=s=>{let r="";if(s.content){let $=Object.keys(s.content);$[0]&&s.content[$[0]].schema&&(r+=`${F(h,s.content[$[0]].schema,"")}`)}return r},nt=s=>{var r,$,u,n,p;if(($=(r=e==null?void 0:e.endpoints)==null?void 0:r.value)!=null&&$.replaceWords&&Array.isArray(e==null?void 0:e.endpoints.value.replaceWords)){let y=s;return(p=(n=(u=e==null?void 0:e.endpoints)==null?void 0:u.value)==null?void 0:n.replaceWords)==null||p.forEach((a,o)=>{let d=new RegExp(a.replace,"g");y=y.replace(d,a.with||"")}),y}else return s},at=(s,r,$=[])=>{var p,y;let u=(p=e==null?void 0:e.endpoints)==null?void 0:p.exclude,n=(y=e==null?void 0:e.endpoints)==null?void 0:y.include;if(n){let a=n.tags&&n.tags.length>0?$.some(d=>n.tags.includes(d)):!0,o=n.endpoints&&n.endpoints.length>0?n.endpoints.some(d=>{let j=!d.method||d.method.toLowerCase()===r.toLowerCase();return d.path?s===d.path&&j:d.regex?new RegExp(d.regex).test(s)&&j:!1}):!0;if(!a||!o)return!0}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 d=!o.method||o.method.toLowerCase()===r.toLowerCase();return o.path?s===o.path&&d:o.regex?new RegExp(o.regex).test(s)&&d:!1})))};if(Object.keys(h.paths||{}).forEach(s=>{let r=h.paths[s];Object.keys(r).forEach(u=>{var ee,ce,xe,Ae,Ee,Te,we,Re,Se,Ne,ve,Fe,qe,Pe,ke,Be,Me,Ue,Je,Ke,Le,Ve,We,Ge;let n=u,p=Ye(s,n),y=((ee=r[n])==null?void 0:ee.tags)||[];if(at(s,n,y))return;let a=r[n],o=ae({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});R[o]||(R[o]={endpoints:"",types:""});let d=((xe=(ce=e==null?void 0:e.endpoints)==null?void 0:ce.value)!=null&&xe.includeServer?ye:"")+p.pathParts.map(m=>(m[0]==="{"&&m[m.length-1]==="}"?m=`\${${m.replace(/{/,"").replace(/}/,"")}}`:m[0]==="<"&&m[m.length-1]===">"?m=`\${${m.replace(/</,"").replace(/>/,"")}}`:m[0]===":"&&(m=`\${${m.replace(/:/,"")}}`),m)).join("/"),j=`"${d}"`;p.variables.length>0&&(j=`(${p.variables.map(l=>`${l}:string`).join(",")})=> \`${d}\``),j=nt(j);let t=r[n],i="";if(t!=null&&t.parameters&&((t==null?void 0:t.parameters).forEach((l,A)=>{(l.$ref||l.in==="query"&&l.name)&&(i+=`${F(h,l.$ref?l:l.schema,l.name||"",l.required)}`)}),i)){i=`{
18
+ ${i}}`;let l=`${p.name}Query`;if((Ee=(Ae=e==null?void 0:e.types)==null?void 0:Ae.name)!=null&&Ee.useOperationId&&(t!=null&&t.operationId)&&(l=`${t.operationId}Query`),l=X(`${q}${l}`),(we=(Te=e==null?void 0:e.types)==null?void 0:Te.name)!=null&&we.format){let S=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},l);S&&(l=`${q}${S}`)}let A=`export type ${l} = ${i};
19
+ `;e!=null&&e.folderSplit?R[o].types+=A:G+=A}let f=t==null?void 0:t.requestBody,C="";if(f&&(C=he(f),C)){let m=`${p.name}DTO`;if((Se=(Re=e==null?void 0:e.types)==null?void 0:Re.name)!=null&&Se.useOperationId&&(t!=null&&t.operationId)&&(m=`${t.operationId}DTO`),m=X(`${q}${m}`),(ve=(Ne=e==null?void 0:e.types)==null?void 0:Ne.name)!=null&&ve.format){let A=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},m);A&&(m=`${q}${A}`)}let l=`export type ${m} = ${C};
20
+ `;e!=null&&e.folderSplit?R[o].types+=l:G+=l}let c={},x="";if(t!=null&&t.responses){let m=t==null?void 0:t.responses;Object.keys(m).forEach(A=>{var S,N,E,w;if(x=he(m[A]),c[A]=x,x){let O=`${p.name}${A}Response`;if((N=(S=e==null?void 0:e.types)==null?void 0:S.name)!=null&&N.useOperationId&&(t!=null&&t.operationId)&&(O=`${t.operationId}${A}Response`),O=X(`${q}${O}`),(w=(E=e==null?void 0:e.types)==null?void 0:E.name)!=null&&w.format){let Y=e==null?void 0:e.types.name.format("endpoint",{code:A,type:"response",method:n,path:s,summary:t==null?void 0:t.summary,operationId:t==null?void 0:t.operationId},O);Y&&(O=`${q}${Y}`)}let k=`export type ${O} = ${x};
21
+ `;e!=null&&e.folderSplit?R[o].types+=k:G+=k}})}let Q=m=>!m||!m.length?"":m.map(l=>Object.entries(l).map(([S,N])=>{let E=S,w="";return Array.isArray(N)&&N.length&&(w=`
22
+ - Scopes: [\`${N.join("`, `")}\`]`,E=`**${E}**`),`
23
+ - ${E}${w}`}).join("")).join(`
24
+ `),P=t!=null&&t.security?Q(t.security):"",J="";if(!((qe=(Fe=e==null?void 0:e.endpoints)==null?void 0:Fe.doc)!=null&&qe.disable)){let m="";if((ke=(Pe=e==null?void 0:e.endpoints)==null?void 0:Pe.doc)!=null&&ke.showCurl){let l={},A="",S="";(Be=t.requestBody)!=null&&Be.content&&Object.keys(t.requestBody.content).forEach(w=>{let O=t.requestBody.content[w].schema;if(O){Array.isArray(l["Content-type"])?l["Content-type"].push(w):l["Content-type"]=[w];let k=U(h,O);k&&(A=k)}}),t!=null&&t.security&&t.security.forEach(E=>{Object.keys(E).forEach(w=>{var k,Y;let O=(Y=(k=h.components)==null?void 0:k.securitySchemes)==null?void 0:Y[w];O&&(O.type==="mutualTLS"?S+=`
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]}),m=`
35
26
  \`\`\`bash
36
- ${ft({url:$e+s,method:n.toUpperCase(),headers:B,body:R})}${P}
37
- \`\`\``}V=`/**${t!=null&&t.description?`
27
+ ${ut({url:ye+s,method:n.toUpperCase(),headers:N,body:A})}${S}
28
+ \`\`\``}J=`/**${t!=null&&t.description?`
38
29
  * ${t==null?void 0:t.description} `:""}
39
30
  * **Method**: \`${n.toUpperCase()}\`
40
31
  * **Summary**: ${(t==null?void 0:t.summary)||""}
41
32
  * **Tags**: [${((Me=t==null?void 0:t.tags)==null?void 0:Me.join(", "))||""}]
42
- * **OperationId**: ${(t==null?void 0:t.operationId)||""} ${p?`
43
- * **Query**: ${oe(p)} `:""}${S?`
44
- * **DTO**: ${oe(S)} `:""}${N?`
45
- * **Response**: ${Object.entries(w).map(([d,R])=>`
46
- - **${d}**: ${oe(R,2)} `).join("")}`:""}${L?`
47
- * **Security**: ${L}
48
- `:""}${y}
33
+ * **OperationId**: ${(t==null?void 0:t.operationId)||""} ${i?`
34
+ * **Query**: ${re(i)} `:""}${C?`
35
+ * **DTO**: ${re(C)} `:""}${x?`
36
+ * **Response**: ${Object.entries(c).map(([l,A])=>`
37
+ - **${l}**: ${re(A,2)} `).join("")}`:""}${P?`
38
+ * **Security**: ${P}
39
+ `:""}${m}
49
40
  */
50
- `}let G=(Le=(Ue=e==null?void 0:e.endpoints)==null?void 0:Ue.name)!=null&&Le.useOperationId&&((ze=t==null?void 0:t.operationId)==null?void 0:ze.length)>0?t.operationId:`${l.name}`;if((Ve=(Ke=e==null?void 0:e.endpoints)==null?void 0:Ke.name)!=null&&Ve.format){let y=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},G);y&&(G=y)}let re={method:`"${n}"`,operationId:`"${t==null?void 0:t.operationId}"`,url:T,tags:(t==null?void 0:t.tags)||[]},H=`${V}export const ${nt}${G} = ${((Ye=(We=e==null?void 0:e.endpoints)==null?void 0:We.value)==null?void 0:Ye.type)==="object"?_(re):T};
51
- `;e!=null&&e.folderSplit?q[i].endpoints+=H:le+=H})}),e!=null&&e.folderSplit){for(let[s,r]of Object.entries(q))if(r.endpoints||r.types){let O=F.join(b,s);if(r.endpoints){let $=F.join(te,O,"endpoints.ts");yield J.promises.mkdir(F.dirname($),{recursive:!0}),yield J.promises.writeFile($,r.endpoints)}if(r.types){let $=F.join(te,O,"types.ts");yield J.promises.mkdir(F.dirname($),{recursive:!0});let n=Object.values(Y).length>0?`import * as Shared from "../shared";
41
+ `}let V=(Je=(Ue=e==null?void 0:e.endpoints)==null?void 0:Ue.name)!=null&&Je.useOperationId&&((Ke=t==null?void 0:t.operationId)==null?void 0:Ke.length)>0?t.operationId:`${p.name}`;if((Ve=(Le=e==null?void 0:e.endpoints)==null?void 0:Le.name)!=null&&Ve.format){let m=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},V);m&&(V=m)}let g={method:`"${n}"`,operationId:`"${t==null?void 0:t.operationId}"`,url:j,tags:(t==null?void 0:t.tags)||[]},z=`${J}export const ${rt}${V} = ${((Ge=(We=e==null?void 0:e.endpoints)==null?void 0:We.value)==null?void 0:Ge.type)==="object"?pe(g):j};
42
+ `;e!=null&&e.folderSplit?R[o].endpoints+=z:oe+=z})}),e!=null&&e.folderSplit){for(let[s,r]of Object.entries(R))if(r.endpoints||r.types){let $=T.join(K,s);if(r.endpoints){let u=T.join(D,$,"endpoints.ts");yield v.promises.mkdir(T.dirname(u),{recursive:!0}),yield v.promises.writeFile(u,r.endpoints)}if(r.types){let u=T.join(D,$,"types.ts");yield v.promises.mkdir(T.dirname(u),{recursive:!0});let n=Object.values(L).length>0?`import * as Shared from "../shared";
52
43
 
53
- ${r.types}`:r.types;yield J.promises.writeFile($,n)}}}if(le.length>0){let s=F.join(te,b,"endpoints.ts");yield J.promises.mkdir(F.dirname(s),{recursive:!0}),yield J.promises.writeFile(s,le)}if(Object.values(Y).length>0){let s=F.join(te,b,e!=null&&e.folderSplit?"":"types","shared.ts");yield J.promises.mkdir(F.dirname(s),{recursive:!0}),yield J.promises.writeFile(s,Object.values(Y).join(`
54
- `))}if(Q.length>0){let s=F.join(te,b,"types","index.ts");yield J.promises.mkdir(F.dirname(s),{recursive:!0}),yield J.promises.writeFile(s,`${Object.values(Y).length>0?`import * as Shared from "./shared";
44
+ ${r.types}`:r.types;yield v.promises.writeFile(u,n)}}}if(oe.length>0){let s=T.join(D,K,"endpoints.ts");yield v.promises.mkdir(T.dirname(s),{recursive:!0}),yield v.promises.writeFile(s,oe)}if(Object.values(L).length>0){let s=T.join(D,K,e!=null&&e.folderSplit?"":"types","shared.ts");yield v.promises.mkdir(T.dirname(s),{recursive:!0}),yield v.promises.writeFile(s,Object.values(L).join(`
45
+ `))}if(G.length>0){let s=T.join(D,K,"types","index.ts");yield v.promises.mkdir(T.dirname(s),{recursive:!0}),yield v.promises.writeFile(s,`${Object.values(L).length>0?`import * as Shared from "./shared";
55
46
 
56
- `:""}${Q}`)}}),st=rt;import ue from"path";import ht from"fs";var ye=process.cwd(),Wt=a=>ne(null,null,function*(){let m;try{D("esbuild-register")}catch(f){throw f}let e=ue.join(ye,"openapi.sync.js"),x=ue.join(ye,"openapi.sync.ts"),A=ue.join(ye,"openapi.sync.json"),j=[e,x,A];try{for(let f of j)ht.existsSync(f)&&(m=D(f),Object.keys(m).length===1&&m.default&&(m=m.default))}catch(f){}typeof m=="function"&&(m=m());let E=m;if(!E)throw new Error("No config found");let c=Object.keys(E.api),b=a&&"refetchInterval"in a&&!isNaN(a==null?void 0:a.refetchInterval)?a.refetchInterval:E.refetchInterval;ge();for(let f=0;f<c.length;f+=1){let q=c[f],ie=E.api[q];st(ie,q,E,b)}});export{Wt as Init,_ as JSONStringify,W as capitalize,He as getEndpointDetails,jt as getNestedValue,Qe as isJson,lt as isYamlString,oe as renderTypeRefMD,Ot as variableName,Ge as variableNameChar,Ze as yamlStringToJson};
47
+ `:""}${G}`)}}),tt=et;import me from"path";import yt from"fs";var ue=process.cwd(),Jt=I=>te(null,null,function*(){let b;try{H("esbuild-register")}catch(h){throw h}let e=me.join(ue,"openapi.sync.js"),B=me.join(ue,"openapi.sync.ts"),W=me.join(ue,"openapi.sync.json"),ne=[e,B,W];try{for(let h of ne)yt.existsSync(h)&&(b=H(h),Object.keys(b).length===1&&b.default&&(b=b.default))}catch(h){console.log(h)}typeof b=="function"&&(b=b());let M=b;if(!M)throw new Error("No config found");let _=Object.keys(M.api),K=I&&"refetchInterval"in I&&!isNaN(I==null?void 0:I.refetchInterval)?I.refetchInterval:M.refetchInterval;De();for(let h=0;h<_.length;h+=1){let R=_[h],ae=M.api[R];tt(ae,R,M,K)}});export{Jt as Init,pe as JSONStringify,X as capitalize,Ye as getEndpointDetails,Ot as getNestedValue,Qe as isJson,ft as isYamlString,re as renderTypeRefMD,$t as variableName,ht as variableNameChar,ze as yamlStringToJson};
@@ -0,0 +1,4 @@
1
+ declare const variableName: RegExp;
2
+ declare const variableNameChar: RegExp;
3
+
4
+ export { variableName, variableNameChar };
@@ -0,0 +1,4 @@
1
+ declare const variableName: RegExp;
2
+ declare const variableNameChar: RegExp;
3
+
4
+ export { variableName, variableNameChar };
package/dist/regex.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var t=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var _=(e,a)=>{for(var o in a)t(e,o,{get:a[o],enumerable:!0})},b=(e,a,o,$)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of A(a))!Z.call(e,r)&&r!==o&&t(e,r,{get:()=>a[r],enumerable:!($=z(a,r))||$.enumerable});return e};var c=e=>b(t({},"__esModule",{value:!0}),e);var m={};_(m,{variableName:()=>i,variableNameChar:()=>l});module.exports=c(m);var i=/^[A-Za-z_$][A-Za-z0-9_$]*$/,l=/[A-Za-z0-9_$]/;0&&(module.exports={variableName,variableNameChar});
package/dist/regex.mjs ADDED
@@ -0,0 +1 @@
1
+ import{c as a,d as b}from"./chunk-6GQNHE6A.mjs";export{a as variableName,b as variableNameChar};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-sync",
3
- "version": "2.1.12",
3
+ "version": "2.1.13",
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",
@@ -18,7 +18,8 @@
18
18
  "node",
19
19
  "codegen",
20
20
  "generation",
21
- "generator"
21
+ "generator",
22
+ "generate types"
22
23
  ],
23
24
  "files": [
24
25
  "bin",
@@ -39,16 +40,23 @@
39
40
  "scripts": {
40
41
  "build-tsc": "rm -rf dist && tsc",
41
42
  "build": "rm -rf dist && tsup",
42
- "publish-package": "npm run build && npm publish"
43
+ "publish-package": "npm run build && npm publish",
44
+ "test": "jest",
45
+ "test:watch": "jest --watch",
46
+ "test:coverage": "jest --coverage",
47
+ "test:ci": "jest --ci --coverage --watchAll=false"
43
48
  },
44
49
  "author": "P-Technologies",
45
50
  "license": "ISC",
46
51
  "devDependencies": {
52
+ "@types/jest": "^30.0.0",
47
53
  "@types/js-yaml": "^4.0.9",
48
54
  "@types/lodash": "^4.17.7",
49
55
  "@types/lodash.get": "^4.4.9",
50
56
  "@types/lodash.isequal": "^4.5.8",
51
57
  "@types/node": "^22.1.0",
58
+ "jest": "^30.2.0",
59
+ "ts-jest": "^29.4.4",
52
60
  "typescript": "^5.5.4"
53
61
  },
54
62
  "dependencies": {
@@ -63,4 +71,4 @@
63
71
  "tsup": "^8.5.0",
64
72
  "yargs": "^17.7.2"
65
73
  }
66
- }
74
+ }