@hey-api/openapi-ts 0.81.0 → 0.82.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 +6 -6
- package/dist/chunk-LKJWUBMN.js +43 -0
- package/dist/chunk-LKJWUBMN.js.map +1 -0
- package/dist/clients/angular/client.ts +27 -14
- package/dist/clients/angular/types.ts +9 -7
- package/dist/clients/axios/client.ts +27 -14
- package/dist/clients/axios/types.ts +9 -7
- package/dist/clients/core/serverSentEvents.ts +28 -1
- package/dist/clients/core/types.ts +20 -22
- package/dist/clients/fetch/client.ts +61 -21
- package/dist/clients/fetch/types.ts +10 -8
- package/dist/clients/next/client.ts +66 -20
- package/dist/clients/next/types.ts +9 -7
- package/dist/clients/nuxt/client.ts +28 -14
- package/dist/clients/nuxt/types.ts +3 -7
- package/dist/index.cjs +68 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +671 -4
- package/dist/index.d.ts +671 -4
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +13 -13
- 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-CFCN8diW.d.cts → types.d-kCNGz4sv.d.cts} +3208 -2407
- package/dist/{types.d-CFCN8diW.d.ts → types.d-kCNGz4sv.d.ts} +3208 -2407
- package/package.json +2 -2
- package/dist/chunk-Z7FL5BGA.js +0 -43
- package/dist/chunk-Z7FL5BGA.js.map +0 -1
|
@@ -117,7 +117,7 @@ export interface ClientOptions {
|
|
|
117
117
|
throwOnError?: boolean;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
type
|
|
120
|
+
type MethodFn = <
|
|
121
121
|
TData = unknown,
|
|
122
122
|
TError = unknown,
|
|
123
123
|
ThrowOnError extends boolean = false,
|
|
@@ -125,7 +125,7 @@ type MethodFnBase = <
|
|
|
125
125
|
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>,
|
|
126
126
|
) => RequestResult<TData, TError, ThrowOnError>;
|
|
127
127
|
|
|
128
|
-
type
|
|
128
|
+
type SseFn = <
|
|
129
129
|
TData = unknown,
|
|
130
130
|
TError = unknown,
|
|
131
131
|
ThrowOnError extends boolean = false,
|
|
@@ -133,10 +133,6 @@ type MethodFnServerSentEvents = <
|
|
|
133
133
|
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>,
|
|
134
134
|
) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
135
135
|
|
|
136
|
-
type MethodFn = MethodFnBase & {
|
|
137
|
-
sse: MethodFnServerSentEvents;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
136
|
type RequestFn = <
|
|
141
137
|
TData = unknown,
|
|
142
138
|
TError = unknown,
|
|
@@ -157,7 +153,13 @@ type BuildUrlFn = <
|
|
|
157
153
|
options: Pick<TData, 'url'> & Options<TData>,
|
|
158
154
|
) => string;
|
|
159
155
|
|
|
160
|
-
export type Client = CoreClient<
|
|
156
|
+
export type Client = CoreClient<
|
|
157
|
+
RequestFn,
|
|
158
|
+
Config,
|
|
159
|
+
MethodFn,
|
|
160
|
+
BuildUrlFn,
|
|
161
|
+
SseFn
|
|
162
|
+
> & {
|
|
161
163
|
interceptors: Middleware<Response, unknown, ResolvedRequestOptions>;
|
|
162
164
|
};
|
|
163
165
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { reactive, ref, watch } from 'vue';
|
|
8
8
|
|
|
9
9
|
import { createSseClient } from '../core/serverSentEvents';
|
|
10
|
+
import type { HttpMethod } from '../core/types';
|
|
10
11
|
import type { Client, Config, RequestOptions } from './types';
|
|
11
12
|
import {
|
|
12
13
|
buildUrl,
|
|
@@ -180,34 +181,47 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
180
181
|
return undefined as any;
|
|
181
182
|
};
|
|
182
183
|
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
const makeMethodFn =
|
|
185
|
+
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
186
|
+
request({ ...options, method });
|
|
187
|
+
|
|
188
|
+
const makeSseFn =
|
|
189
|
+
(method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
|
|
186
190
|
const { opts, url } = await beforeRequest(options);
|
|
187
191
|
return createSseClient({
|
|
188
192
|
...unwrapRefs(opts),
|
|
189
193
|
body: opts.body as BodyInit | null | undefined,
|
|
190
194
|
method,
|
|
195
|
+
onRequest: undefined,
|
|
191
196
|
signal: unwrapRefs(opts.signal) as AbortSignal,
|
|
192
197
|
url,
|
|
193
198
|
});
|
|
194
199
|
};
|
|
195
|
-
return fn;
|
|
196
|
-
};
|
|
197
200
|
|
|
198
201
|
return {
|
|
199
202
|
buildUrl,
|
|
200
|
-
connect:
|
|
201
|
-
delete:
|
|
202
|
-
get:
|
|
203
|
+
connect: makeMethodFn('CONNECT'),
|
|
204
|
+
delete: makeMethodFn('DELETE'),
|
|
205
|
+
get: makeMethodFn('GET'),
|
|
203
206
|
getConfig,
|
|
204
|
-
head:
|
|
205
|
-
options:
|
|
206
|
-
patch:
|
|
207
|
-
post:
|
|
208
|
-
put:
|
|
207
|
+
head: makeMethodFn('HEAD'),
|
|
208
|
+
options: makeMethodFn('OPTIONS'),
|
|
209
|
+
patch: makeMethodFn('PATCH'),
|
|
210
|
+
post: makeMethodFn('POST'),
|
|
211
|
+
put: makeMethodFn('PUT'),
|
|
209
212
|
request,
|
|
210
213
|
setConfig,
|
|
211
|
-
|
|
214
|
+
sse: {
|
|
215
|
+
connect: makeSseFn('CONNECT'),
|
|
216
|
+
delete: makeSseFn('DELETE'),
|
|
217
|
+
get: makeSseFn('GET'),
|
|
218
|
+
head: makeSseFn('HEAD'),
|
|
219
|
+
options: makeSseFn('OPTIONS'),
|
|
220
|
+
patch: makeSseFn('PATCH'),
|
|
221
|
+
post: makeSseFn('POST'),
|
|
222
|
+
put: makeSseFn('PUT'),
|
|
223
|
+
trace: makeSseFn('TRACE'),
|
|
224
|
+
},
|
|
225
|
+
trace: makeMethodFn('TRACE'),
|
|
212
226
|
} as Client;
|
|
213
227
|
};
|
|
@@ -116,7 +116,7 @@ export interface ClientOptions {
|
|
|
116
116
|
baseURL?: string;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
type
|
|
119
|
+
type MethodFn = <
|
|
120
120
|
TComposable extends Composable,
|
|
121
121
|
ResT = unknown,
|
|
122
122
|
TError = unknown,
|
|
@@ -125,7 +125,7 @@ type MethodFnBase = <
|
|
|
125
125
|
options: Omit<RequestOptions<TComposable, ResT, DefaultT>, 'method'>,
|
|
126
126
|
) => RequestResult<TComposable, ResT, TError>;
|
|
127
127
|
|
|
128
|
-
type
|
|
128
|
+
type SseFn = <
|
|
129
129
|
TComposable extends Composable,
|
|
130
130
|
ResT = unknown,
|
|
131
131
|
TError = unknown,
|
|
@@ -134,10 +134,6 @@ type MethodFnServerSentEvents = <
|
|
|
134
134
|
options: Omit<RequestOptions<TComposable, ResT, DefaultT>, 'method'>,
|
|
135
135
|
) => Promise<ServerSentEventsResult<RequestResult<TComposable, ResT, TError>>>;
|
|
136
136
|
|
|
137
|
-
type MethodFn = MethodFnBase & {
|
|
138
|
-
sse: MethodFnServerSentEvents;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
137
|
type RequestFn = <
|
|
142
138
|
TComposable extends Composable,
|
|
143
139
|
ResT = unknown,
|
|
@@ -178,7 +174,7 @@ type BuildUrlFn = <TData extends Omit<TDataShape, 'headers'>>(
|
|
|
178
174
|
options: BuildUrlOptions<TData>,
|
|
179
175
|
) => string;
|
|
180
176
|
|
|
181
|
-
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn>;
|
|
177
|
+
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn>;
|
|
182
178
|
|
|
183
179
|
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
184
180
|
|