@hey-api/openapi-ts 0.80.5 → 0.80.7
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/chunk-PIMDA23B.js +39 -0
- package/dist/chunk-PIMDA23B.js.map +1 -0
- package/dist/clients/fetch/client.ts +6 -4
- package/dist/clients/fetch/index.ts +1 -0
- package/dist/clients/fetch/types.ts +9 -1
- package/dist/clients/next/client.ts +10 -5
- package/dist/clients/next/types.ts +8 -1
- package/dist/index.cjs +58 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +10 -10
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/{types.d-5Zt8gOQV.d.cts → types.d-Cpp7XW_3.d.cts} +668 -20
- package/dist/{types.d-5Zt8gOQV.d.ts → types.d-Cpp7XW_3.d.ts} +668 -20
- package/package.json +1 -1
- package/dist/chunk-OPOOONNX.js +0 -39
- package/dist/chunk-OPOOONNX.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Client, Config,
|
|
1
|
+
import type { Client, Config, ResolvedRequestOptions } from './types';
|
|
2
2
|
import {
|
|
3
3
|
buildUrl,
|
|
4
4
|
createConfig,
|
|
@@ -28,7 +28,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
28
28
|
Request,
|
|
29
29
|
Response,
|
|
30
30
|
unknown,
|
|
31
|
-
|
|
31
|
+
ResolvedRequestOptions
|
|
32
32
|
>();
|
|
33
33
|
|
|
34
34
|
const request: Client['request'] = async (options) => {
|
|
@@ -37,6 +37,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
37
37
|
...options,
|
|
38
38
|
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
39
39
|
headers: mergeHeaders(_config.headers, options.headers),
|
|
40
|
+
serializedBody: undefined,
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
if (opts.security) {
|
|
@@ -51,11 +52,11 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
if (opts.body && opts.bodySerializer) {
|
|
54
|
-
opts.
|
|
55
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
58
|
-
if (opts.
|
|
59
|
+
if (opts.serializedBody === undefined || opts.serializedBody === '') {
|
|
59
60
|
opts.headers.delete('Content-Type');
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -63,6 +64,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
63
64
|
const requestInit: ReqInit = {
|
|
64
65
|
redirect: 'follow',
|
|
65
66
|
...opts,
|
|
67
|
+
body: opts.serializedBody,
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
let request = new Request(url, requestInit);
|
|
@@ -81,6 +81,14 @@ export interface RequestOptions<
|
|
|
81
81
|
url: Url;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
export interface ResolvedRequestOptions<
|
|
85
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
86
|
+
ThrowOnError extends boolean = boolean,
|
|
87
|
+
Url extends string = string,
|
|
88
|
+
> extends RequestOptions<TResponseStyle, ThrowOnError, Url> {
|
|
89
|
+
serializedBody?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
export type RequestResult<
|
|
85
93
|
TData = unknown,
|
|
86
94
|
TError = unknown,
|
|
@@ -163,7 +171,7 @@ type BuildUrlFn = <
|
|
|
163
171
|
) => string;
|
|
164
172
|
|
|
165
173
|
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
|
166
|
-
interceptors: Middleware<Request, Response, unknown,
|
|
174
|
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
167
175
|
};
|
|
168
176
|
|
|
169
177
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Client, Config,
|
|
1
|
+
import type { Client, Config, ResolvedRequestOptions } from './types';
|
|
2
2
|
import {
|
|
3
3
|
buildUrl,
|
|
4
4
|
createConfig,
|
|
@@ -24,7 +24,11 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
24
24
|
return getConfig();
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const interceptors = createInterceptors<
|
|
27
|
+
const interceptors = createInterceptors<
|
|
28
|
+
Response,
|
|
29
|
+
unknown,
|
|
30
|
+
ResolvedRequestOptions
|
|
31
|
+
>();
|
|
28
32
|
|
|
29
33
|
// @ts-expect-error
|
|
30
34
|
const request: Client['request'] = async (options) => {
|
|
@@ -33,6 +37,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
33
37
|
...options,
|
|
34
38
|
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
35
39
|
headers: mergeHeaders(_config.headers, options.headers),
|
|
40
|
+
serializedBody: undefined,
|
|
36
41
|
};
|
|
37
42
|
|
|
38
43
|
if (opts.security) {
|
|
@@ -47,11 +52,11 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
if (opts.body && opts.bodySerializer) {
|
|
50
|
-
opts.
|
|
55
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
54
|
-
if (opts.
|
|
59
|
+
if (opts.serializedBody === undefined || opts.serializedBody === '') {
|
|
55
60
|
opts.headers.delete('Content-Type');
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -67,7 +72,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
67
72
|
const _fetch = opts.fetch!;
|
|
68
73
|
let response = await _fetch(url, {
|
|
69
74
|
...opts,
|
|
70
|
-
body: opts.
|
|
75
|
+
body: opts.serializedBody as ReqInit['body'],
|
|
71
76
|
});
|
|
72
77
|
|
|
73
78
|
for (const fn of interceptors.response._fns) {
|
|
@@ -64,6 +64,13 @@ export interface RequestOptions<
|
|
|
64
64
|
url: Url;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
export interface ResolvedRequestOptions<
|
|
68
|
+
ThrowOnError extends boolean = boolean,
|
|
69
|
+
Url extends string = string,
|
|
70
|
+
> extends RequestOptions<ThrowOnError, Url> {
|
|
71
|
+
serializedBody?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
67
74
|
export type RequestResult<
|
|
68
75
|
TData = unknown,
|
|
69
76
|
TError = unknown,
|
|
@@ -126,7 +133,7 @@ type BuildUrlFn = <
|
|
|
126
133
|
) => string;
|
|
127
134
|
|
|
128
135
|
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
|
129
|
-
interceptors: Middleware<Response, unknown,
|
|
136
|
+
interceptors: Middleware<Response, unknown, ResolvedRequestOptions>;
|
|
130
137
|
};
|
|
131
138
|
|
|
132
139
|
/**
|