@hey-api/openapi-ts 0.55.2 → 0.55.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -4296,7 +4296,7 @@ interface ClientConfig {
4296
4296
  * Process output folder with linter?
4297
4297
  * @default false
4298
4298
  */
4299
- lint?: 'biome' | 'eslint' | false;
4299
+ lint?: 'biome' | 'eslint' | 'oxlint' | false;
4300
4300
  /**
4301
4301
  * The relative location of the output folder
4302
4302
  */
package/dist/index.d.ts CHANGED
@@ -4296,7 +4296,7 @@ interface ClientConfig {
4296
4296
  * Process output folder with linter?
4297
4297
  * @default false
4298
4298
  */
4299
- lint?: 'biome' | 'eslint' | false;
4299
+ lint?: 'biome' | 'eslint' | 'oxlint' | false;
4300
4300
  /**
4301
4301
  * The relative location of the output folder
4302
4302
  */
package/dist/index.js CHANGED
@@ -1319,7 +1319,7 @@ export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions<T>)
1319
1319
 
1320
1320
  onCancel(() => xhr.abort());
1321
1321
  });
1322
- };`},useData:!0};var dl=()=>{d.registerHelper("camelCase",function(e){return k({input:e})}),d.registerHelper("equals",function(e,t,r){return e===t?r.fn(this):r.inverse(this)}),d.registerHelper("ifServicesResponse",function(e,t){return b().plugins["@hey-api/services"]?.response===e?t.fn(this):t.inverse(this)}),d.registerHelper("ifdef",function(...e){let t=e.pop();return e.every(r=>!r)?t.inverse(this):t.fn(this)}),d.registerHelper("notEquals",function(e,t,r){return e!==t?r.fn(this):r.inverse(this)}),d.registerHelper("transformServiceName",function(e){return Ce({config:b(),name:e})});},rp=()=>{dl();let e={client:d.template(ua),core:{apiError:d.template(ba),apiRequestOptions:d.template(Oa),apiResult:d.template(Ra),baseHttpRequest:d.template(va),cancelablePromise:d.template(Ea),httpRequest:d.template(Xa),request:d.template(za),settings:d.template(Qa)}};return d.registerPartial("functions/base64",d.template(Da)),d.registerPartial("functions/catchErrorCodes",d.template(Ma)),d.registerPartial("functions/getFormData",d.template(Fa)),d.registerPartial("functions/getQueryString",d.template(La)),d.registerPartial("functions/getUrl",d.template(Ha)),d.registerPartial("functions/isBlob",d.template(_a)),d.registerPartial("functions/isFormData",d.template(Ba)),d.registerPartial("functions/isString",d.template(Va)),d.registerPartial("functions/isStringWithValue",d.template(Ka)),d.registerPartial("functions/isSuccess",d.template(Ua)),d.registerPartial("functions/resolve",d.template(Wa)),d.registerPartial("fetch/getHeaders",d.template(qa)),d.registerPartial("fetch/getRequestBody",d.template(ja)),d.registerPartial("fetch/getResponseBody",d.template(ka)),d.registerPartial("fetch/getResponseHeader",d.template(Na)),d.registerPartial("fetch/request",d.template(wa)),d.registerPartial("fetch/sendRequest",d.template($a)),d.registerPartial("xhr/getHeaders",d.template(Ga)),d.registerPartial("xhr/getRequestBody",d.template(Ja)),d.registerPartial("xhr/getResponseBody",d.template(Ya)),d.registerPartial("xhr/getResponseHeader",d.template(Za)),d.registerPartial("xhr/request",d.template(ep)),d.registerPartial("xhr/sendRequest",d.template(tp)),d.registerPartial("axios/getHeaders",d.template(Ca)),d.registerPartial("axios/getRequestBody",d.template(Ta)),d.registerPartial("axios/getResponseBody",d.template(Pa)),d.registerPartial("axios/getResponseHeader",d.template(Sa)),d.registerPartial("axios/request",d.template(Aa)),d.registerPartial("axios/sendRequest",d.template(Ia)),d.registerPartial("angular/getHeaders",d.template(fa)),d.registerPartial("angular/getRequestBody",d.template(da)),d.registerPartial("angular/getResponseBody",d.template(ya)),d.registerPartial("angular/getResponseHeader",d.template(ga)),d.registerPartial("angular/request",d.template(ha)),d.registerPartial("angular/sendRequest",d.template(xa)),e};var np=e=>`${e}-end`,wn=e=>`${e}-length`,op=e=>`${e}-start`,B={clear:()=>{performance.clearMarks(),performance.clearMeasures();},end:e=>performance.mark(np(e)),getEntriesByName:e=>performance.getEntriesByName(wn(e)),measure:e=>performance.measure(wn(e),op(e),np(e)),start:e=>performance.mark(op(e))},$r=class{totalMeasure;constructor({totalMark:t}){this.totalMeasure=B.measure(t);}report({marks:t}){let r=Math.ceil(this.totalMeasure.duration*100)/100,o=this.totalMeasure.name;console.warn(`${o.substring(0,o.length-wn("").length)}: ${r.toFixed(2)}ms`),t.forEach(n=>{let s=B.measure(n),i=Math.ceil(s.duration*100)/100,a=Math.ceil(s.duration/this.totalMeasure.duration*100*100)/100;console.warn(`${n}: ${i.toFixed(2)}ms (${a.toFixed(2)}%)`);});}};var xl={biome:{args:e=>["format","--write",e],command:"biome",name:"Biome (Format)"},prettier:{args:e=>["--ignore-unknown",e,"--write","--ignore-path","./.prettierignore"],command:"prettier",name:"Prettier"}},bl={biome:{args:e=>["lint","--apply",e],command:"biome",name:"Biome (Lint)"},eslint:{args:e=>[e,"--fix"],command:"eslint",name:"ESLint"}},Ol=({config:e})=>{if(e.output.format){let t=xl[e.output.format];console.log(`\u2728 Running ${t.name}`),(0, $n.sync)(t.command,t.args(e.output.path));}if(e.output.lint){let t=bl[e.output.lint];console.log(`\u2728 Running ${t.name}`),(0, $n.sync)(t.command,t.args(e.output.path));}},Rl=({config:e})=>{switch(e.client.name){case"legacy/angular":return console.log("\u2728 Creating Angular client");case"@hey-api/client-axios":case"legacy/axios":return console.log("\u2728 Creating Axios client");case"@hey-api/client-fetch":case"legacy/fetch":return console.log("\u2728 Creating Fetch client");case"legacy/node":return console.log("\u2728 Creating Node.js client");case"legacy/xhr":return console.log("\u2728 Creating XHR client")}},Cl=e=>{let t={bundle:!1,name:""};return typeof e.client=="string"?t.name=e.client:e.client&&(t={...t,...e.client}),t},Tl=e=>{let t={path:""};return typeof e.input=="string"?t.path=e.input:e.input&&e.input.path?t={...t,...e.input}:t={...t,path:e.input},t},Pl=e=>{let t={format:!1,lint:!1,path:""};return typeof e.output=="string"?t.path=e.output:t={...t,...e.output},t},Sl=({pluginConfigs:e,userPlugins:t})=>{let r=new Set,o=new Set,n=s=>{if(r.has(s))throw new Error(`Circular reference detected at '${s}'`);if(!o.has(s)){r.add(s);let i=e[s];if(!i)throw new Error(`\u{1F6AB} unknown plugin dependency "${s}" - do you need to register a custom plugin with this name?`);for(let a of i._dependencies||[])n(a);for(let a of i._optionalDependencies||[])t.includes(a)&&n(a);r.delete(s),o.add(s);}};for(let s of t)n(s);return Array.from(o)},Al=e=>{let t={},r=(e.plugins??["@hey-api/types","@hey-api/schemas","@hey-api/services"]).map(s=>typeof s=="string"?s:(s.name&&(t[s.name]=s),s.name)).filter(Boolean),o=Sl({pluginConfigs:{...t,...Nn},userPlugins:r}),n=o.reduce((s,i)=>{let a=Nn[i],c=t[i];if(c&&a){let m=Object.keys(c).find(l=>l.startsWith("_"));if(m)throw new Error(`\u{1F6AB} cannot register plugin "${c.name}" - attempting to override a native plugin option "${m}"`)}return s[i]={...a,...c},s},{});return {pluginOrder:o,plugins:n}},Il=async({config:e})=>{let t=e.input.path;if(typeof e.input.path=="string"){let r=existsSync(e.input.path)?ce.resolve(e.input.path):e.input.path;t=await gl.bundle(r);}return t},vl=async e=>{let t;if(e.configFile){let n=e.configFile.split(".");t=n.slice(0,n.length-1).join(".");}let{config:r}=await loadConfig({configFile:t,name:"openapi-ts"});return (Array.isArray(e)?e:Array.isArray(r)?r.map(n=>({...n,...e})):[{...r??{},...e}]).map(n=>{let{base:s,configFile:i="",debug:a=!1,dryRun:c=!1,exportCore:m=!0,experimentalParser:l=!1,name:u,request:f,useOptions:g=!0}=n;a&&console.warn("userConfig:",n);let h=Tl(n),x=Pl(n);if(!h.path)throw new Error("\u{1F6AB} missing input - which OpenAPI specification should we use to generate your client?");if(!x.path)throw new Error("\u{1F6AB} missing output - where should we generate your client?");let T=Cl(n);if(T.name&&!la.includes(T.name))throw new Error("\u{1F6AB} invalid client - select a valid client value");g||console.warn("\u2757\uFE0F Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://heyapi.dev/openapi-ts/migrating.html#v0-27-38"),x.path=ce.resolve(process.cwd(),x.path);let C=vo({...Al(n),base:s,client:T,configFile:i,debug:a,dryRun:c,experimentalParser:l,exportCore:P(T)?m:!1,input:h,name:u,output:x,request:f,useOptions:g});return a&&console.warn("config:",C),C})};async function El(e){B.start("createClient"),B.start("config");let t=await vl(e);B.end("config"),B.start("handlebars");let r=rp();B.end("handlebars");let o=i=>async()=>{B.start("spec");let a=await Il({config:i});B.end("spec");let c,m;B.start("parser");let l={filterFn:{operation:ks,operationParameter:Ns},nameFn:{operation:ws,operationParameter:$s}};if(i.experimentalParser&&!P(i)&&!q(i)&&(m=mi({config:i,parserConfig:l,spec:a})),!m){let u=ci({openApi:a,parserConfig:l});c=Ci(u);}return B.end("parser"),Rl({config:i}),B.start("generator"),m?await di({context:m}):c&&await fi({client:c,openApi:a,templates:r}),B.end("generator"),B.start("postprocess"),i.dryRun||(Ol({config:i}),console.log("\u2728 Done! Your client is located in:",i.output.path)),B.end("postprocess"),m||c},n=[],s=t.map(i=>o(i));for(let i of s){let a=await i();a&&"version"in a&&n.push(a);}return B.end("createClient"),e.debug&&new $r({totalMark:"createClient"}).report({marks:["config","openapi","handlebars","parser","generator","postprocess"]}),n}var ql=e=>e,TT={createClient:El,defineConfig:ql};
1322
+ };`},useData:!0};var dl=()=>{d.registerHelper("camelCase",function(e){return k({input:e})}),d.registerHelper("equals",function(e,t,r){return e===t?r.fn(this):r.inverse(this)}),d.registerHelper("ifServicesResponse",function(e,t){return b().plugins["@hey-api/services"]?.response===e?t.fn(this):t.inverse(this)}),d.registerHelper("ifdef",function(...e){let t=e.pop();return e.every(r=>!r)?t.inverse(this):t.fn(this)}),d.registerHelper("notEquals",function(e,t,r){return e!==t?r.fn(this):r.inverse(this)}),d.registerHelper("transformServiceName",function(e){return Ce({config:b(),name:e})});},rp=()=>{dl();let e={client:d.template(ua),core:{apiError:d.template(ba),apiRequestOptions:d.template(Oa),apiResult:d.template(Ra),baseHttpRequest:d.template(va),cancelablePromise:d.template(Ea),httpRequest:d.template(Xa),request:d.template(za),settings:d.template(Qa)}};return d.registerPartial("functions/base64",d.template(Da)),d.registerPartial("functions/catchErrorCodes",d.template(Ma)),d.registerPartial("functions/getFormData",d.template(Fa)),d.registerPartial("functions/getQueryString",d.template(La)),d.registerPartial("functions/getUrl",d.template(Ha)),d.registerPartial("functions/isBlob",d.template(_a)),d.registerPartial("functions/isFormData",d.template(Ba)),d.registerPartial("functions/isString",d.template(Va)),d.registerPartial("functions/isStringWithValue",d.template(Ka)),d.registerPartial("functions/isSuccess",d.template(Ua)),d.registerPartial("functions/resolve",d.template(Wa)),d.registerPartial("fetch/getHeaders",d.template(qa)),d.registerPartial("fetch/getRequestBody",d.template(ja)),d.registerPartial("fetch/getResponseBody",d.template(ka)),d.registerPartial("fetch/getResponseHeader",d.template(Na)),d.registerPartial("fetch/request",d.template(wa)),d.registerPartial("fetch/sendRequest",d.template($a)),d.registerPartial("xhr/getHeaders",d.template(Ga)),d.registerPartial("xhr/getRequestBody",d.template(Ja)),d.registerPartial("xhr/getResponseBody",d.template(Ya)),d.registerPartial("xhr/getResponseHeader",d.template(Za)),d.registerPartial("xhr/request",d.template(ep)),d.registerPartial("xhr/sendRequest",d.template(tp)),d.registerPartial("axios/getHeaders",d.template(Ca)),d.registerPartial("axios/getRequestBody",d.template(Ta)),d.registerPartial("axios/getResponseBody",d.template(Pa)),d.registerPartial("axios/getResponseHeader",d.template(Sa)),d.registerPartial("axios/request",d.template(Aa)),d.registerPartial("axios/sendRequest",d.template(Ia)),d.registerPartial("angular/getHeaders",d.template(fa)),d.registerPartial("angular/getRequestBody",d.template(da)),d.registerPartial("angular/getResponseBody",d.template(ya)),d.registerPartial("angular/getResponseHeader",d.template(ga)),d.registerPartial("angular/request",d.template(ha)),d.registerPartial("angular/sendRequest",d.template(xa)),e};var np=e=>`${e}-end`,wn=e=>`${e}-length`,op=e=>`${e}-start`,B={clear:()=>{performance.clearMarks(),performance.clearMeasures();},end:e=>performance.mark(np(e)),getEntriesByName:e=>performance.getEntriesByName(wn(e)),measure:e=>performance.measure(wn(e),op(e),np(e)),start:e=>performance.mark(op(e))},$r=class{totalMeasure;constructor({totalMark:t}){this.totalMeasure=B.measure(t);}report({marks:t}){let r=Math.ceil(this.totalMeasure.duration*100)/100,o=this.totalMeasure.name;console.warn(`${o.substring(0,o.length-wn("").length)}: ${r.toFixed(2)}ms`),t.forEach(n=>{let s=B.measure(n),i=Math.ceil(s.duration*100)/100,a=Math.ceil(s.duration/this.totalMeasure.duration*100*100)/100;console.warn(`${n}: ${i.toFixed(2)}ms (${a.toFixed(2)}%)`);});}};var xl={biome:{args:e=>["format","--write",e],command:"biome",name:"Biome (Format)"},prettier:{args:e=>["--ignore-unknown",e,"--write","--ignore-path","./.prettierignore"],command:"prettier",name:"Prettier"}},bl={biome:{args:e=>["lint","--apply",e],command:"biome",name:"Biome (Lint)"},eslint:{args:e=>[e,"--fix"],command:"eslint",name:"ESLint"},oxlint:{args:e=>["--fix",e],command:"oxlint",name:"oxlint"}},Ol=({config:e})=>{if(e.output.format){let t=xl[e.output.format];console.log(`\u2728 Running ${t.name}`),(0, $n.sync)(t.command,t.args(e.output.path));}if(e.output.lint){let t=bl[e.output.lint];console.log(`\u2728 Running ${t.name}`),(0, $n.sync)(t.command,t.args(e.output.path));}},Rl=({config:e})=>{switch(e.client.name){case"legacy/angular":return console.log("\u2728 Creating Angular client");case"@hey-api/client-axios":case"legacy/axios":return console.log("\u2728 Creating Axios client");case"@hey-api/client-fetch":case"legacy/fetch":return console.log("\u2728 Creating Fetch client");case"legacy/node":return console.log("\u2728 Creating Node.js client");case"legacy/xhr":return console.log("\u2728 Creating XHR client")}},Cl=e=>{let t={bundle:!1,name:""};return typeof e.client=="string"?t.name=e.client:e.client&&(t={...t,...e.client}),t},Tl=e=>{let t={path:""};return typeof e.input=="string"?t.path=e.input:e.input&&e.input.path?t={...t,...e.input}:t={...t,path:e.input},t},Pl=e=>{let t={format:!1,lint:!1,path:""};return typeof e.output=="string"?t.path=e.output:t={...t,...e.output},t},Sl=({pluginConfigs:e,userPlugins:t})=>{let r=new Set,o=new Set,n=s=>{if(r.has(s))throw new Error(`Circular reference detected at '${s}'`);if(!o.has(s)){r.add(s);let i=e[s];if(!i)throw new Error(`\u{1F6AB} unknown plugin dependency "${s}" - do you need to register a custom plugin with this name?`);for(let a of i._dependencies||[])n(a);for(let a of i._optionalDependencies||[])t.includes(a)&&n(a);r.delete(s),o.add(s);}};for(let s of t)n(s);return Array.from(o)},Al=e=>{let t={},r=(e.plugins??["@hey-api/types","@hey-api/schemas","@hey-api/services"]).map(s=>typeof s=="string"?s:(s.name&&(t[s.name]=s),s.name)).filter(Boolean),o=Sl({pluginConfigs:{...t,...Nn},userPlugins:r}),n=o.reduce((s,i)=>{let a=Nn[i],c=t[i];if(c&&a){let m=Object.keys(c).find(l=>l.startsWith("_"));if(m)throw new Error(`\u{1F6AB} cannot register plugin "${c.name}" - attempting to override a native plugin option "${m}"`)}return s[i]={...a,...c},s},{});return {pluginOrder:o,plugins:n}},Il=async({config:e})=>{let t=e.input.path;if(typeof e.input.path=="string"){let r=existsSync(e.input.path)?ce.resolve(e.input.path):e.input.path;t=await gl.bundle(r);}return t},vl=async e=>{let t;if(e.configFile){let n=e.configFile.split(".");t=n.slice(0,n.length-1).join(".");}let{config:r}=await loadConfig({configFile:t,name:"openapi-ts"});return (Array.isArray(e)?e:Array.isArray(r)?r.map(n=>({...n,...e})):[{...r??{},...e}]).map(n=>{let{base:s,configFile:i="",debug:a=!1,dryRun:c=!1,exportCore:m=!0,experimentalParser:l=!1,name:u,request:f,useOptions:g=!0}=n;a&&console.warn("userConfig:",n);let h=Tl(n),x=Pl(n);if(!h.path)throw new Error("\u{1F6AB} missing input - which OpenAPI specification should we use to generate your client?");if(!x.path)throw new Error("\u{1F6AB} missing output - where should we generate your client?");let T=Cl(n);if(T.name&&!la.includes(T.name))throw new Error("\u{1F6AB} invalid client - select a valid client value");g||console.warn("\u2757\uFE0F Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://heyapi.dev/openapi-ts/migrating.html#v0-27-38"),x.path=ce.resolve(process.cwd(),x.path);let C=vo({...Al(n),base:s,client:T,configFile:i,debug:a,dryRun:c,experimentalParser:l,exportCore:P(T)?m:!1,input:h,name:u,output:x,request:f,useOptions:g});return a&&console.warn("config:",C),C})};async function El(e){B.start("createClient"),B.start("config");let t=await vl(e);B.end("config"),B.start("handlebars");let r=rp();B.end("handlebars");let o=i=>async()=>{B.start("spec");let a=await Il({config:i});B.end("spec");let c,m;B.start("parser");let l={filterFn:{operation:ks,operationParameter:Ns},nameFn:{operation:ws,operationParameter:$s}};if(i.experimentalParser&&!P(i)&&!q(i)&&(m=mi({config:i,parserConfig:l,spec:a})),!m){let u=ci({openApi:a,parserConfig:l});c=Ci(u);}return B.end("parser"),Rl({config:i}),B.start("generator"),m?await di({context:m}):c&&await fi({client:c,openApi:a,templates:r}),B.end("generator"),B.start("postprocess"),i.dryRun||(Ol({config:i}),console.log("\u2728 Done! Your client is located in:",i.output.path)),B.end("postprocess"),m||c},n=[],s=t.map(i=>o(i));for(let i of s){let a=await i();a&&"version"in a&&n.push(a);}return B.end("createClient"),e.debug&&new $r({totalMark:"createClient"}).report({marks:["config","openapi","handlebars","parser","generator","postprocess"]}),n}var ql=e=>e,TT={createClient:El,defineConfig:ql};
1323
1323
 
1324
1324
  export { El as createClient, TT as default, ql as defineConfig };
1325
1325
  //# sourceMappingURL=index.js.map