@hey-api/openapi-ts 0.85.1 → 0.86.0

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
@@ -31,7 +31,7 @@
31
31
 
32
32
  ## Features
33
33
 
34
- - runs in CLI, Node.js 18+, or npx
34
+ - runs in CLI, Node.js 20+, or npx
35
35
  - works with OpenAPI 2.0, 3.0, and 3.1
36
36
  - core plugins for types, SDKs, and schemas
37
37
  - clients for your runtime (Fetch API, Angular, Axios, Next.js, Nuxt, etc.)
package/bin/index.cjs CHANGED
@@ -134,8 +134,9 @@ async function start() {
134
134
  !context[0] ||
135
135
  !context[0].config ||
136
136
  !context[0].config.input ||
137
- !context[0].config.input.watch ||
138
- !context[0].config.input.watch.enabled
137
+ !context[0].config.input.some(
138
+ (input) => input.watch && input.watch.enabled,
139
+ )
139
140
  ) {
140
141
  process.exit(0);
141
142
  }
@@ -0,0 +1 @@
1
+ import{createRequire as e}from"node:module";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=e=>{let t={};for(var r in e)n(t,r,{get:e[r],enumerable:!0});return t},l=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},u=(e,r,i)=>(i=e==null?{}:t(a(e)),l(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),d=e(import.meta.url);export{s as __commonJSMin,c as __export,d as __require,u as __toESM};
@@ -1,5 +1,5 @@
1
- import type { AxiosError, AxiosInstance, RawAxiosRequestHeaders } from 'axios';
2
- import axios from 'axios';
1
+ import type { AxiosInstance, RawAxiosRequestHeaders } from 'axios';
2
+ import axios, { AxiosError } from 'axios';
3
3
 
4
4
  import { createSseClient } from '../core/serverSentEvents';
5
5
  import type { HttpMethod } from '../core/types';
@@ -67,7 +67,6 @@ export const createClient = (config: Config = {}): Client => {
67
67
  return { opts, url };
68
68
  };
69
69
 
70
- // @ts-expect-error
71
70
  const request: Client['request'] = async (options) => {
72
71
  // @ts-expect-error
73
72
  const { opts, url } = await beforeRequest(options);
@@ -85,6 +84,7 @@ export const createClient = (config: Config = {}): Client => {
85
84
  params: opts.paramsSerializer ? opts.query : undefined,
86
85
  url,
87
86
  });
87
+ if (response instanceof Error) throw response;
88
88
 
89
89
  let { data } = response;
90
90
 
@@ -103,13 +103,22 @@ export const createClient = (config: Config = {}): Client => {
103
103
  data: data ?? {},
104
104
  };
105
105
  } catch (error) {
106
- const e = error as AxiosError;
107
106
  if (opts.throwOnError) {
108
- throw e;
107
+ throw error;
109
108
  }
110
- // @ts-expect-error
111
- e.error = e.response?.data ?? {};
112
- return e;
109
+
110
+ if (error instanceof AxiosError) {
111
+ // @ts-expect-error
112
+ error.error = error.response?.data ?? {};
113
+ return error;
114
+ }
115
+
116
+ if (typeof error === 'object' && error !== null) {
117
+ error.error = {};
118
+ return error;
119
+ }
120
+
121
+ return { error: {} };
113
122
  }
114
123
  };
115
124
 
@@ -47,7 +47,9 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
47
47
  style = 'matrix';
48
48
  }
49
49
 
50
- const value = toValue(toValue(path)[name]);
50
+ const value = toValue(
51
+ (toValue(path) as Record<string, unknown> | undefined)?.[name],
52
+ );
51
53
 
52
54
  if (value === undefined || value === null) {
53
55
  continue;
@@ -157,7 +159,7 @@ const checkForExistence = (
157
159
  }
158
160
  if (
159
161
  options.headers.has(name) ||
160
- toValue(options.query)?.[name] ||
162
+ (toValue(options.query) as Record<string, unknown> | undefined)?.[name] ||
161
163
  options.headers.get('Cookie')?.includes(`${name}=`)
162
164
  ) {
163
165
  return true;
@@ -185,12 +187,18 @@ export const setAuthParams = async ({
185
187
  const name = auth.name ?? 'Authorization';
186
188
 
187
189
  switch (auth.in) {
188
- case 'query':
190
+ case 'query': {
189
191
  if (!options.query) {
190
192
  options.query = {};
191
193
  }
192
- toValue(options.query)[name] = token;
194
+ const queryValue = toValue(options.query) as
195
+ | Record<string, unknown>
196
+ | undefined;
197
+ if (queryValue) {
198
+ queryValue[name] = token;
199
+ }
193
200
  break;
201
+ }
194
202
  case 'cookie':
195
203
  options.headers.append('Cookie', `${name}=${token}`);
196
204
  break;