@hey-api/openapi-ts 0.86.2 → 0.86.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{i as e,r as t,t as n}from"./chunk-C-EqMg7d.js";import{A as r,C as i,D as a,E as o,F as s,I as c,M as l,N as u,O as d,P as f,S as p,T as m,_ as h,a as g,b as _,c as v,d as y,f as b,g as x,h as S,i as C,j as ee,k as te,l as ne,m as re,n as ie,o as w,p as T,r as E,s as ae,t as oe,u as se,v as D,w as O,x as ce,y as k}from"./getSpec-54k1Qp12.js";import A from"ansi-colors";import le from"color-support";import j from"node:fs";import M from"node:path";import{$RefParser as N}from"@hey-api/json-schema-ref-parser";import P from"handlebars";const F=()=>{if(typeof Bun<`u`){let[e]=Bun.version.split(`.`).map(Number);if(e<1)throw new a(`Unsupported Bun version ${Bun.version}. Please use Bun 1.0.0 or newer.`)}else if(typeof process<`u`&&process.versions?.node){let[e]=process.versions.node.split(`.`).map(Number);if(e<20)throw new a(`Unsupported Node version ${process.versions.node}. Please use Node 20 or newer.`)}},I=e=>{switch(e){case`legacy/angular`:return`AngularHttpRequest`;case`legacy/axios`:return`AxiosHttpRequest`;case`legacy/fetch`:return`FetchHttpRequest`;case`legacy/node`:return`NodeHttpRequest`;case`legacy/xhr`:return`XHRHttpRequest`;default:return``}},L=async(e,t,n,r)=>{let a=i(),s=o(a),c=r.client({$config:a,...n,httpRequest:I(s.name),models:b(n.models),services:b(n.services)});m(a)&&(f(t),j.writeFileSync(M.resolve(t,`${m(a)}.ts`),c))},R=async(e,t,n)=>{let r=i();if(r.exportCore){let i=o(r),a={httpRequest:I(i.name),server:r.base===void 0?t.server:r.base,version:t.version};if(j.rmSync(M.resolve(e),{force:!0,recursive:!0}),j.mkdirSync(M.resolve(e),{recursive:!0}),await j.writeFileSync(M.resolve(e,`OpenAPI.ts`),n.core.settings({$config:r,...a})),await j.writeFileSync(M.resolve(e,`ApiError.ts`),n.core.apiError({$config:r,...a})),await j.writeFileSync(M.resolve(e,`ApiRequestOptions.ts`),n.core.apiRequestOptions({$config:r,...a})),await j.writeFileSync(M.resolve(e,`ApiResult.ts`),n.core.apiResult({$config:r,...a})),i.name!==`legacy/angular`&&await j.writeFileSync(M.resolve(e,`CancelablePromise.ts`),n.core.cancelablePromise({$config:r,...a})),await j.writeFileSync(M.resolve(e,`request.ts`),n.core.request({$config:r,...a})),m(r)&&(await j.writeFileSync(M.resolve(e,`BaseHttpRequest.ts`),n.core.baseHttpRequest({$config:r,...a})),await j.writeFileSync(M.resolve(e,`${a.httpRequest}.ts`),n.core.httpRequest({$config:r,...a}))),r.request){let t=M.resolve(process.cwd(),r.request);if(!await j.existsSync(t))throw Error(`Custom request file "${t}" does not exists`);await j.copyFileSync(t,M.resolve(e,`request.ts`))}}},z=({files:e})=>{let t=i();e.index=new C({dir:t.output.path,id:`index`,name:`index.ts`}),m(t)&&e.index.add(D.exportNamedDeclaration({exports:m(t),module:`./${m(t)}`})),t.exportCore&&(e.index.add(D.exportNamedDeclaration({exports:`ApiError`,module:`./core/ApiError`})),t.plugins[`@hey-api/sdk`]?.config.response===`response`&&e.index.add(D.exportNamedDeclaration({exports:{asType:!0,name:`ApiResult`},module:`./core/ApiResult`})),m(t)&&e.index.add(D.exportNamedDeclaration({exports:`BaseHttpRequest`,module:`./core/BaseHttpRequest`})),o(t).name!==`legacy/angular`&&e.index.add(D.exportNamedDeclaration({exports:[`CancelablePromise`,`CancelError`],module:`./core/CancelablePromise`})),e.index.add(D.exportNamedDeclaration({exports:[`OpenAPI`,{asType:!0,name:`OpenAPIConfig`}],module:`./core/OpenAPI`}))),Object.keys(e).sort().forEach(t=>{let n=e[t];t===`index`||n.isEmpty()||n.exportFromIndex&&e.index.add(D.exportAllDeclaration({module:`./${n.nameWithoutExtension()}`}))})},B=async({client:e,openApi:t,templates:n})=>{let r=i(),a=t;if(e){if(r.plugins[`@hey-api/sdk`]?.config.include&&r.plugins[`@hey-api/sdk`].config.asClass){let t=new RegExp(r.plugins[`@hey-api/sdk`].config.include);e.services=e.services.filter(e=>t.test(e.name))}if(r.plugins[`@hey-api/typescript`]?.config.include){let t=new RegExp(r.plugins[`@hey-api/typescript`].config.include);e.models=e.models.filter(e=>t.test(e.name))}}let c=M.resolve(r.output.path);r.output.clean&&s(c);let l=o(r);!O(r)&&`bundle`in l.config&&l.config.bundle&&w({meta:{importFileExtension:r.output.importFileExtension},outputPath:c,plugin:l}),await L(a,c,e,n),await R(M.resolve(r.output.path,`core`),e,n);let u={};for(let t of r.pluginOrder){let n=r.plugins[t],i=(n.output??``).split(`/`),o=M.resolve(r.output.path,...i.slice(0,i.length-1));u[n.name]=new C({dir:o,id:`legacy-unused-${n.name}`,name:`${i[i.length-1]}.ts`}),n.handlerLegacy?.({client:e,files:u,openApi:a,plugin:n})}z({files:u}),Object.entries(u).forEach(([e,t])=>{r.dryRun||(e===`index`?t.write(`
1
+ import{i as e,r as t,t as n}from"./chunk-C-EqMg7d.js";import{A as r,C as i,D as a,E as o,F as s,I as c,M as l,N as u,O as d,P as f,S as p,T as m,_ as h,a as g,b as _,c as v,d as y,f as b,g as x,h as S,i as C,j as ee,k as te,l as ne,m as re,n as ie,o as w,p as T,r as E,s as ae,t as oe,u as se,v as D,w as O,x as ce,y as k}from"./getSpec-Ci2amIoH.js";import"@hey-api/codegen-core";import A from"ansi-colors";import le from"color-support";import j from"node:fs";import M from"node:path";import{$RefParser as N}from"@hey-api/json-schema-ref-parser";import P from"handlebars";const F=()=>{if(typeof Bun<`u`){let[e]=Bun.version.split(`.`).map(Number);if(e<1)throw new a(`Unsupported Bun version ${Bun.version}. Please use Bun 1.0.0 or newer.`)}else if(typeof process<`u`&&process.versions?.node){let[e]=process.versions.node.split(`.`).map(Number);if(e<20)throw new a(`Unsupported Node version ${process.versions.node}. Please use Node 20 or newer.`)}},I=e=>{switch(e){case`legacy/angular`:return`AngularHttpRequest`;case`legacy/axios`:return`AxiosHttpRequest`;case`legacy/fetch`:return`FetchHttpRequest`;case`legacy/node`:return`NodeHttpRequest`;case`legacy/xhr`:return`XHRHttpRequest`;default:return``}},L=async(e,t,n,r)=>{let a=i(),s=o(a),c=r.client({$config:a,...n,httpRequest:I(s.name),models:b(n.models),services:b(n.services)});m(a)&&(f(t),j.writeFileSync(M.resolve(t,`${m(a)}.ts`),c))},R=async(e,t,n)=>{let r=i();if(r.exportCore){let i=o(r),a={httpRequest:I(i.name),server:r.base===void 0?t.server:r.base,version:t.version};if(j.rmSync(M.resolve(e),{force:!0,recursive:!0}),j.mkdirSync(M.resolve(e),{recursive:!0}),await j.writeFileSync(M.resolve(e,`OpenAPI.ts`),n.core.settings({$config:r,...a})),await j.writeFileSync(M.resolve(e,`ApiError.ts`),n.core.apiError({$config:r,...a})),await j.writeFileSync(M.resolve(e,`ApiRequestOptions.ts`),n.core.apiRequestOptions({$config:r,...a})),await j.writeFileSync(M.resolve(e,`ApiResult.ts`),n.core.apiResult({$config:r,...a})),i.name!==`legacy/angular`&&await j.writeFileSync(M.resolve(e,`CancelablePromise.ts`),n.core.cancelablePromise({$config:r,...a})),await j.writeFileSync(M.resolve(e,`request.ts`),n.core.request({$config:r,...a})),m(r)&&(await j.writeFileSync(M.resolve(e,`BaseHttpRequest.ts`),n.core.baseHttpRequest({$config:r,...a})),await j.writeFileSync(M.resolve(e,`${a.httpRequest}.ts`),n.core.httpRequest({$config:r,...a}))),r.request){let t=M.resolve(process.cwd(),r.request);if(!await j.existsSync(t))throw Error(`Custom request file "${t}" does not exists`);await j.copyFileSync(t,M.resolve(e,`request.ts`))}}},z=({files:e})=>{let t=i();e.index=new C({dir:t.output.path,id:`index`,name:`index.ts`}),m(t)&&e.index.add(D.exportNamedDeclaration({exports:m(t),module:`./${m(t)}`})),t.exportCore&&(e.index.add(D.exportNamedDeclaration({exports:`ApiError`,module:`./core/ApiError`})),t.plugins[`@hey-api/sdk`]?.config.response===`response`&&e.index.add(D.exportNamedDeclaration({exports:{asType:!0,name:`ApiResult`},module:`./core/ApiResult`})),m(t)&&e.index.add(D.exportNamedDeclaration({exports:`BaseHttpRequest`,module:`./core/BaseHttpRequest`})),o(t).name!==`legacy/angular`&&e.index.add(D.exportNamedDeclaration({exports:[`CancelablePromise`,`CancelError`],module:`./core/CancelablePromise`})),e.index.add(D.exportNamedDeclaration({exports:[`OpenAPI`,{asType:!0,name:`OpenAPIConfig`}],module:`./core/OpenAPI`}))),Object.keys(e).sort().forEach(t=>{let n=e[t];t===`index`||n.isEmpty()||n.exportFromIndex&&e.index.add(D.exportAllDeclaration({module:`./${n.nameWithoutExtension()}`}))})},B=async({client:e,openApi:t,templates:n})=>{let r=i(),a=t;if(e){if(r.plugins[`@hey-api/sdk`]?.config.include&&r.plugins[`@hey-api/sdk`].config.asClass){let t=new RegExp(r.plugins[`@hey-api/sdk`].config.include);e.services=e.services.filter(e=>t.test(e.name))}if(r.plugins[`@hey-api/typescript`]?.config.include){let t=new RegExp(r.plugins[`@hey-api/typescript`].config.include);e.models=e.models.filter(e=>t.test(e.name))}}let c=M.resolve(r.output.path);r.output.clean&&s(c);let l=o(r);!O(r)&&`bundle`in l.config&&l.config.bundle&&w({meta:{importFileExtension:r.output.importFileExtension},outputPath:c,plugin:l}),await L(a,c,e,n),await R(M.resolve(r.output.path,`core`),e,n);let u={};for(let t of r.pluginOrder){let n=r.plugins[t],i=(n.output??``).split(`/`),o=M.resolve(r.output.path,...i.slice(0,i.length-1));u[n.name]=new C({dir:o,id:`legacy-unused-${n.name}`,name:`${i[i.length-1]}.ts`}),n.handlerLegacy?.({client:e,files:u,openApi:a,plugin:n})}z({files:u}),Object.entries(u).forEach(([e,t])=>{r.dryRun||(e===`index`?t.write(`
2
2
  `,r.output.tsConfig):t.write(`
3
3
 
4
4
  `,r.output.tsConfig))})},V=async({context:e})=>{let t=M.resolve(e.config.output.path);e.config.output.clean&&s(t);let n={importFileExtension:e.config.output.importFileExtension},r=o(e.config);`bundle`in r.config&&r.config.bundle&&(e.config._FRAGILE_CLIENT_BUNDLE_RENAMED=w({meta:n,outputPath:t,plugin:r,project:e.gen}));for(let t of e.registerPlugins())await t.run();for(let r of e.gen.render(n)){let n=M.resolve(t,r.path),i=M.dirname(n);e.config.dryRun||(j.mkdirSync(i,{recursive:!0}),j.writeFileSync(n,r.content,{encoding:`utf8`}))}},H=({patchOptions:e,spec:t})=>{if(!e)return;let n=t;if(`swagger`in n){if(e.version&&n.swagger&&(n.swagger=typeof e.version==`string`?e.version:e.version(n.swagger)),e.meta&&n.info&&e.meta(n.info),e.schemas&&n.definitions)for(let t in e.schemas){let r=n.definitions[t];if(!r||typeof r!=`object`)continue;let i=e.schemas[t];i(r)}if(e.operations&&n.paths)for(let t in e.operations){let[r,i]=t.split(` `);if(!r||!i)continue;let a=n.paths[i];if(!a)continue;let o=a[r.toLocaleLowerCase()]||a[r.toLocaleUpperCase()];if(!o||typeof o!=`object`)continue;let s=e.operations[t];s(o)}return}if(e.version&&n.openapi&&(n.openapi=typeof e.version==`string`?e.version:e.version(n.openapi)),e.meta&&n.info&&e.meta(n.info),n.components){if(e.schemas&&n.components.schemas)for(let t in e.schemas){let r=n.components.schemas[t];if(!r||typeof r!=`object`)continue;let i=e.schemas[t];i(r)}if(e.parameters&&n.components.parameters)for(let t in e.parameters){let r=n.components.parameters[t];if(!r||typeof r!=`object`)continue;let i=e.parameters[t];i(r)}if(e.requestBodies&&n.components.requestBodies)for(let t in e.requestBodies){let r=n.components.requestBodies[t];if(!r||typeof r!=`object`)continue;let i=e.requestBodies[t];i(r)}if(e.responses&&n.components.responses)for(let t in e.responses){let r=n.components.responses[t];if(!r||typeof r!=`object`)continue;let i=e.responses[t];i(r)}}if(e.operations&&n.paths)for(let t in e.operations){let[r,i]=t.split(` `);if(!r||!i)continue;let a=n.paths[i];if(!a)continue;let o=a[r.toLocaleLowerCase()]||a[r.toLocaleUpperCase()];if(!o||typeof o!=`object`)continue;let s=e.operations[t];s(o)}};var U=n(((e,n)=>{n.exports=o,o.sync=s;var r=t(`fs`);function i(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function a(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:i(t,n)}function o(e,t,n){r.stat(e,function(r,i){n(r,r?!1:a(i,e,t))})}function s(e,t){return a(r.statSync(e),e,t)}})),W=n(((e,n)=>{n.exports=i,i.sync=a;var r=t(`fs`);function i(e,t,n){r.stat(e,function(e,r){n(e,e?!1:o(r,t))})}function a(e,t){return o(r.statSync(e),t)}function o(e,t){return e.isFile()&&s(e,t)}function s(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),ue=n(((e,n)=>{t(`fs`);var r=process.platform===`win32`||global.TESTING_WINDOWS?U():W();n.exports=i,i.sync=a;function i(e,t,n){if(typeof t==`function`&&(n=t,t={}),!n){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,r){i(e,t||{},function(e,t){e?r(e):n(t)})})}r(e,t||{},function(e,r){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,r=!1),n(e,r)})}function a(e,t){try{return r.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),de=n(((e,n)=>{let r=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,i=t(`path`),a=r?`;`:`:`,o=ue(),s=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),c=(e,t)=>{let n=t.colon||a,i=e.match(/\//)||r&&e.match(/\\/)?[``]:[...r?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(n)],o=r?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=r?o.split(n):[``];return r&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:i,pathExt:s,pathExtExe:o}},l=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:r,pathExt:a,pathExtExe:l}=c(e,t),u=[],d=n=>new Promise((a,o)=>{if(n===r.length)return t.all&&u.length?a(u):o(s(e));let c=r[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=i.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,s)=>{if(r===a.length)return i(d(n+1));let c=a[r];o(e+c,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+c);else return i(e+c);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};n.exports=l,l.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:r,pathExtExe:a}=c(e,t),l=[];for(let s=0;s<n.length;s++){let c=n[s],u=/^".*"$/.test(c)?c.slice(1,-1):c,d=i.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<r.length;e++){let n=f+r[e];try{if(o.sync(n,{pathExt:a}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw s(e)}})),fe=n(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),pe=n(((e,n)=>{let r=t(`path`),i=de(),a=fe();function o(e,t){let n=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=i.sync(e.command,{path:n[a({env:n})],pathExt:t?r.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=r.resolve(s?e.options.cwd:``,l),l}function s(e){return o(e)||o(e,!0)}n.exports=s})),me=n(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),he=n(((e,t)=>{t.exports=/^#!(.*)/})),ge=n(((e,t)=>{let n=he();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),_e=n(((e,n)=>{let r=t(`fs`),i=ge();function a(e){let t=Buffer.alloc(150),n;try{n=r.openSync(e,`r`),r.readSync(n,t,0,150,0),r.closeSync(n)}catch{}return i(t.toString())}n.exports=a})),ve=n(((e,n)=>{let r=t(`path`),i=pe(),a=me(),o=_e(),s=process.platform===`win32`,c=/\.(?:com|exe)$/i,l=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function u(e){e.file=i(e);let t=e.file&&o(e.file);return t?(e.args.unshift(e.file),e.command=t,i(e)):e.file}function d(e){if(!s)return e;let t=u(e),n=!c.test(t);if(e.options.forceShell||n){let n=l.test(t);e.command=r.normalize(e.command),e.command=a.command(e.command),e.args=e.args.map(e=>a.argument(e,n)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function f(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:d(r)}n.exports=f})),ye=n(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),G=e(n(((e,n)=>{let r=t(`child_process`),i=ve(),a=ye();function o(e,t,n){let o=i(e,t,n),s=r.spawn(o.command,o.args,o.options);return a.hookChildProcess(s,o),s}function s(e,t,n){let o=i(e,t,n),s=r.spawnSync(o.command,o.args,o.options);return s.error=s.error||a.verifyENOENTSync(s.status,o),s}n.exports=o,n.exports.spawn=o,n.exports.sync=s,n.exports._parse=i,n.exports._enoent=a}))(),1);const be={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`}},xe={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`}},Se=({config:e})=>{if(e.output.format){let t=be[e.output.format];console.log(`✨ Running ${t.name}`),(0,G.sync)(t.command,t.args(e.output.path))}if(e.output.lint){let t=xe[e.output.lint];console.log(`✨ Running ${t.name}`),(0,G.sync)(t.command,t.args(e.output.path))}};function Ce(e,t){return{...e,config:t,models:e.models.map(e=>we(e)),services:Te(e.operations).map(Ee),types:{}}}const we=e=>({...e,$refs:e.$refs.filter((e,t,n)=>T(e,t,n)),enum:e.enum.filter((e,t,n)=>n.findIndex(t=>t.value===e.value)===t),enums:e.enums.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t),imports:e.imports.filter((t,n,r)=>T(t,n,r)&&t!==e.name).sort(y)}),Te=e=>{let t=i(),n=new Map;return e.forEach(e=>{(e.tags?.length&&(t.plugins[`@hey-api/sdk`]?.config.asClass||m(t))?e.tags.filter(T):[`Default`]).forEach(t=>{let r={...e,service:ke(t)},i=n.get(r.service)||Oe(r);i.$refs=[...i.$refs,...r.$refs],i.imports=[...i.imports,...r.imports],i.operations=[...i.operations,r],n.set(r.service,i)})}),Array.from(n.values())},Ee=e=>{let t={...e};return t.operations=De(t),t.operations.forEach(e=>{t.imports.push(...e.imports)}),t.imports=t.imports.filter(T).sort(y),t},De=e=>{let t=new Map;return e.operations.map(e=>{let n={...e};n.imports.push(...n.parameters.flatMap(e=>e.imports));let r=n.responses.filter(e=>e.responseTypes.includes(`success`));n.imports.push(...r.flatMap(e=>e.imports));let i=n.name,a=t.get(i)||0;return a>0&&(n.name=`${i}${a}`),t.set(i,a+1),n})},Oe=e=>({$refs:[],imports:[],name:e.service,operations:[]}),ke=e=>k({case:`PascalCase`,value:x(e)}),Ae=e=>{let t={...e,path:``};if(e.path&&(typeof e.path!=`string`||e.registry!==`hey-api`))return t.path=e.path,t;let[n,r]=e.path.split(`?`),i=(r||``).split(`&`).map(e=>e.split(`=`)),a=n||``;a.endsWith(`/`)&&(a=a.slice(0,a.length-1));let[,o]=a.split(`://`),[s,c,l]=(o||``).split(`/`);t.organization=c||e.organization,t.project=l||e.project;let u=[],d=`api_key`;t.api_key=i.find(([e])=>e===d)?.[1]||e.api_key||process.env.HEY_API_TOKEN,t.api_key&&u.push(`${d}=${t.api_key}`);let f=`branch`;t.branch=i.find(([e])=>e===f)?.[1]||e.branch,t.branch&&u.push(`${f}=${t.branch}`);let p=`commit_sha`;t.commit_sha=i.find(([e])=>e===p)?.[1]||e.commit_sha,t.commit_sha&&u.push(`${p}=${t.commit_sha}`);let m=`tags`;t.tags=i.find(([e])=>e===m)?.[1]?.split(`,`)||e.tags,t.tags?.length&&u.push(`${m}=${t.tags.join(`,`)}`);let h=`version`;if(t.version=i.find(([e])=>e===h)?.[1]||e.version,t.version&&u.push(`${h}=${t.version}`),!t.organization)throw Error(`missing organization - from which Hey API Platform organization do you want to generate your output?`);if(!t.project)throw Error(`missing project - from which Hey API Platform project do you want to generate your output?`);let g=u.join(`&`),_=s||`get.heyapi.dev`,v=_.startsWith(`localhost`),y=[v?`http`:`https`,_].join(`://`),b=v?[y,`v1`,`get`,t.organization,t.project].join(`/`):[y,t.organization,t.project].join(`/`);return t.path=g?`${b}?${g}`:b,t},K=(e,t)=>{let n=[],r=A.gray(`[Job ${t+1}] `),i=e.length,a=A.cyan(`Generating from ${i} ${i===1?`input`:`inputs`}:`);n.push(`${r}⏳ ${a}`),e.forEach((e,t)=>{let i=` [${t+1}] `,a=A.cyan(i),o=` `.repeat(i.length);if(typeof e.path!=`string`){n.push(`${r}${a}raw OpenAPI specification`);return}switch(e.registry){case`hey-api`:{let t=[e.organization,e.project].filter(Boolean).join(`/`);n.push(`${r}${a}${t}`),e.branch&&n.push(`${r}${o}${A.gray(`branch:`)} ${A.green(e.branch)}`),e.commit_sha&&n.push(`${r}${o}${A.gray(`commit:`)} ${A.green(e.commit_sha)}`),e.tags?.length&&n.push(`${r}${o}${A.gray(`tags:`)} ${A.green(e.tags.join(`, `))}`),e.version&&n.push(`${r}${o}${A.gray(`version:`)} ${A.green(e.version)}`),n.push(`${r}${o}${A.gray(`registry:`)} ${A.green(`Hey API`)}`);break}case`readme`:{let t=[e.organization,e.project].filter(Boolean).join(`/`);t?n.push(`${r}${a}${t}`):n.push(`${r}${a}${e.path}`),e.uuid&&n.push(`${r}${o}${A.gray(`uuid:`)} ${A.green(e.uuid)}`),n.push(`${r}${o}${A.gray(`registry:`)} ${A.green(`ReadMe`)}`);break}case`scalar`:{let t=[e.organization,e.project].filter(Boolean).join(`/`);n.push(`${r}${a}${t}`),n.push(`${r}${o}${A.gray(`registry:`)} ${A.green(`Scalar`)}`);break}default:n.push(`${r}${a}${e.path}`);break}});for(let e of n)console.log(e)},q=async({config:e,dependencies:t,jobIndex:n,logger:r,templates:i,watches:a})=>{let o=a||Array.from({length:e.input.length},()=>({headers:new Headers})),s=e.input.map(e=>Ae(e));e.logs.level!==`silent`&&!a&&K(s,n);let c=async(e,t)=>{let n=r.timeEvent(`spec`),{arrayBuffer:i,error:c,resolvedInput:l,response:u}=await oe({fetchOptions:e.fetch,inputPath:s[t].path,timeout:e.watch.timeout,watch:o[t]});if(n.timeEnd(),c&&!a)throw Error(`Request failed with status ${u.status}: ${u.statusText}`);return{arrayBuffer:i,resolvedInput:l}},l=(await Promise.all(e.input.map((e,t)=>c(e,t)))).filter(e=>e.arrayBuffer||e.resolvedInput),u,d;if(l.length){let o=new N,c=l.length>1?await o.bundleMany({arrayBuffer:l.map(e=>e.arrayBuffer),pathOrUrlOrSchemas:[],resolvedInputs:l.map(e=>e.resolvedInput)}):await o.bundle({arrayBuffer:l[0].arrayBuffer,pathOrUrlOrSchema:void 0,resolvedInput:l[0].resolvedInput});e.logs.level!==`silent`&&a&&(console.clear(),K(s,n));let f=r.timeEvent(`input.patch`);H({patchOptions:e.parser.patch,spec:c}),f.timeEnd();let p=r.timeEvent(`parser`);e.experimentalParser&&!O(e)&&!m(e)&&(d=se({config:e,dependencies:t,logger:r,spec:c})),d?d.graph=S(d.ir,r).graph:u=Ce(ne({openApi:c}),e),p.timeEnd();let h=r.timeEvent(`generator`);d?await V({context:d}):u&&await B({client:u,openApi:c,templates:i}),h.timeEnd();let g=r.timeEvent(`postprocess`);if(!e.dryRun&&(Se({config:e}),e.logs.level!==`silent`)){let t=process.env.INIT_CWD?`./${M.relative(process.env.INIT_CWD,e.output.path)}`:e.output.path,r=A.gray(`[Job ${n+1}] `);console.log(`${r}${A.green(`✅ Done!`)} Your output is in ${A.cyanBright(t)}`)}g.timeEnd()}let f=e.input.find((e,t)=>e.watch.enabled&&typeof s[t].path==`string`);return f&&setTimeout(()=>{q({config:e,dependencies:t,jobIndex:n,logger:r,templates:i,watches:o})},f.watch.interval),d||u},je=(e,t)=>{let n=[],r=Array.from({length:t?.padding??0}).fill(``);n.push(...r);let i=0,a=``;for(let t of e)t===`