@hey-api/openapi-ts 0.85.2 → 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 +1 -1
- package/dist/chunk-BJUc-MpE.js +1 -0
- package/dist/clients/axios/client.ts +17 -8
- package/dist/clients/nuxt/utils.ts +12 -4
- package/dist/getSpec-CZ8YOkGf.js +24 -0
- package/dist/getSpec-CZ8YOkGf.js.map +1 -0
- package/dist/getSpec-_5jk-wUD.cjs +24 -0
- package/dist/getSpec-_5jk-wUD.cjs.map +1 -0
- package/dist/index.cjs +180 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +822 -1478
- package/dist/index.d.ts +822 -1478
- package/dist/index.js +171 -172
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +1 -25
- package/dist/internal.d.cts +36 -41
- package/dist/internal.d.ts +36 -41
- package/dist/internal.js +1 -2
- package/dist/{types.d-CGoxqmT9.d.cts → types-BesMf-H-.d.ts} +7948 -6907
- package/dist/{types.d-CGoxqmT9.d.ts → types-CFN6tBkJ.d.cts} +7948 -6907
- package/package.json +7 -7
- package/dist/chunk-F2CVRHGI.js +0 -47
- package/dist/chunk-F2CVRHGI.js.map +0 -1
- package/dist/internal.cjs.map +0 -1
- package/dist/internal.js.map +0 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
## Features
|
|
33
33
|
|
|
34
|
-
- runs in CLI, Node.js
|
|
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.)
|
|
@@ -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 {
|
|
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
|
|
107
|
+
throw error;
|
|
109
108
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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(
|
|
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)
|
|
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;
|