@hey-api/openapi-ts 0.83.1 → 0.84.1
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 +2 -1
- package/dist/chunk-TA6X5D7W.js +54 -0
- package/dist/chunk-TA6X5D7W.js.map +1 -0
- package/dist/clients/axios/client.ts +1 -1
- package/dist/clients/axios/types.ts +1 -1
- package/dist/clients/axios/utils.ts +11 -3
- package/dist/clients/ofetch/client.ts +272 -0
- package/dist/clients/ofetch/index.ts +23 -0
- package/dist/clients/ofetch/types.ts +333 -0
- package/dist/clients/ofetch/utils.ts +540 -0
- package/dist/index.cjs +42 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +308 -113
- package/dist/index.d.ts +308 -113
- package/dist/index.js +30 -33
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +23 -26
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +1 -1
- package/dist/{types.d-CRtO-Prt.d.cts → types.d-DOXd97cA.d.cts} +2281 -2273
- package/dist/{types.d-CRtO-Prt.d.ts → types.d-DOXd97cA.d.ts} +2281 -2273
- package/package.json +12 -10
- package/dist/chunk-3AYBIZLR.js +0 -57
- package/dist/chunk-3AYBIZLR.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as typescript from 'typescript';
|
|
2
|
+
import typescript__default from 'typescript';
|
|
3
|
+
import { C as Comments, P as PluginHandler, a as Plugin, I as ImportExportItemObject, t as tsNodeToString, S as StringCase, U as UserConfig, L as Logger, b as Client$7, c as IR } from './types.d-DOXd97cA.js';
|
|
4
|
+
export { j as Client, D as DefinePlugin, E as ExpressionTransformer, k as LegacyIR, O as OpenApi, d as OpenApiMetaObject, e as OpenApiOperationObject, f as OpenApiParameterObject, g as OpenApiRequestBodyObject, h as OpenApiResponseObject, i as OpenApiSchemaObject, T as TypeTransformer } from './types.d-DOXd97cA.js';
|
|
3
5
|
import { HttpHeaders, HttpClient, HttpRequest, HttpResponse, HttpErrorResponse } from '@angular/common/http';
|
|
4
6
|
import { Injector } from '@angular/core';
|
|
5
7
|
import { CreateAxiosDefaults, AxiosStatic, AxiosInstance, AxiosRequestHeaders, AxiosResponse, AxiosError } from 'axios';
|
|
6
8
|
import { UseFetchOptions, AsyncDataOptions, useAsyncData, useFetch, useLazyAsyncData, useLazyFetch } from 'nuxt/app';
|
|
7
9
|
import { Ref } from 'vue';
|
|
8
|
-
import
|
|
9
|
-
import typescript__default from 'typescript';
|
|
10
|
+
import { FetchOptions as FetchOptions$1, ofetch, ResponseType } from 'ofetch';
|
|
10
11
|
import 'semver';
|
|
11
12
|
import '@hey-api/codegen-core';
|
|
12
13
|
import 'node:fs';
|
|
13
14
|
|
|
15
|
+
declare module '@hey-api/codegen-core' {
|
|
16
|
+
interface ProjectRenderMeta {
|
|
17
|
+
moduleResolution?: typescript__default.ModuleResolutionKind;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface SymbolMeta {
|
|
21
|
+
/**
|
|
22
|
+
* Name of the plugin that registered this symbol.
|
|
23
|
+
*/
|
|
24
|
+
pluginName?: string;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
type AccessLevel = 'private' | 'protected' | 'public';
|
|
15
29
|
type FunctionParameter = {
|
|
16
30
|
accessLevel?: AccessLevel;
|
|
@@ -78,7 +92,7 @@ interface QuerySerializerOptions {
|
|
|
78
92
|
}
|
|
79
93
|
|
|
80
94
|
type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
81
|
-
type Client$
|
|
95
|
+
type Client$6<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
82
96
|
/**
|
|
83
97
|
* Returns the final request URL.
|
|
84
98
|
*/
|
|
@@ -95,7 +109,7 @@ type Client$5<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn
|
|
|
95
109
|
[K in HttpMethod]: SseFn;
|
|
96
110
|
};
|
|
97
111
|
});
|
|
98
|
-
interface Config$
|
|
112
|
+
interface Config$6 {
|
|
99
113
|
/**
|
|
100
114
|
* Auth token or a function returning auth token. The resolved value will be
|
|
101
115
|
* added to the request payload as defined by its `security` array.
|
|
@@ -149,7 +163,7 @@ interface Config$5 {
|
|
|
149
163
|
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
150
164
|
}
|
|
151
165
|
|
|
152
|
-
type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$
|
|
166
|
+
type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$6, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
|
153
167
|
/**
|
|
154
168
|
* Fetch API implementation. You can use this option to provide a custom
|
|
155
169
|
* fetch instance.
|
|
@@ -219,10 +233,10 @@ type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> =
|
|
|
219
233
|
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
|
|
220
234
|
};
|
|
221
235
|
|
|
222
|
-
type ErrInterceptor$
|
|
223
|
-
type ReqInterceptor$
|
|
224
|
-
type ResInterceptor$
|
|
225
|
-
declare class Interceptors$
|
|
236
|
+
type ErrInterceptor$3<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
237
|
+
type ReqInterceptor$3<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
238
|
+
type ResInterceptor$3<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
239
|
+
declare class Interceptors$3<Interceptor> {
|
|
226
240
|
fns: Array<Interceptor | null>;
|
|
227
241
|
clear(): void;
|
|
228
242
|
eject(id: number | Interceptor): void;
|
|
@@ -231,14 +245,14 @@ declare class Interceptors$2<Interceptor> {
|
|
|
231
245
|
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
232
246
|
use(fn: Interceptor): number;
|
|
233
247
|
}
|
|
234
|
-
interface Middleware$
|
|
235
|
-
error: Interceptors$
|
|
236
|
-
request: Interceptors$
|
|
237
|
-
response: Interceptors$
|
|
248
|
+
interface Middleware$3<Req, Res, Err, Options> {
|
|
249
|
+
error: Interceptors$3<ErrInterceptor$3<Err, Res, Req, Options>>;
|
|
250
|
+
request: Interceptors$3<ReqInterceptor$3<Req, Options>>;
|
|
251
|
+
response: Interceptors$3<ResInterceptor$3<Res, Req, Options>>;
|
|
238
252
|
}
|
|
239
253
|
|
|
240
|
-
type ResponseStyle$
|
|
241
|
-
interface Config$
|
|
254
|
+
type ResponseStyle$2 = 'data' | 'fields';
|
|
255
|
+
interface Config$5<T extends ClientOptions$5 = ClientOptions$5> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Omit<Config$6, 'headers'> {
|
|
242
256
|
/**
|
|
243
257
|
* Base URL for all requests made by this client.
|
|
244
258
|
*/
|
|
@@ -259,7 +273,7 @@ interface Config$4<T extends ClientOptions$4 = ClientOptions$4> extends Omit<Req
|
|
|
259
273
|
*
|
|
260
274
|
* @default 'fields'
|
|
261
275
|
*/
|
|
262
|
-
responseStyle?: ResponseStyle$
|
|
276
|
+
responseStyle?: ResponseStyle$2;
|
|
263
277
|
/**
|
|
264
278
|
* Throw an error instead of returning it in the response?
|
|
265
279
|
*
|
|
@@ -267,7 +281,7 @@ interface Config$4<T extends ClientOptions$4 = ClientOptions$4> extends Omit<Req
|
|
|
267
281
|
*/
|
|
268
282
|
throwOnError?: T['throwOnError'];
|
|
269
283
|
}
|
|
270
|
-
interface RequestOptions$
|
|
284
|
+
interface RequestOptions$5<TData = unknown, TResponseStyle extends ResponseStyle$2 = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config$5<{
|
|
271
285
|
responseStyle: TResponseStyle;
|
|
272
286
|
throwOnError: ThrowOnError;
|
|
273
287
|
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
@@ -289,10 +303,10 @@ interface RequestOptions$4<TData = unknown, TResponseStyle extends ResponseStyle
|
|
|
289
303
|
security?: ReadonlyArray<Auth>;
|
|
290
304
|
url: Url;
|
|
291
305
|
}
|
|
292
|
-
interface ResolvedRequestOptions$
|
|
306
|
+
interface ResolvedRequestOptions$3<TResponseStyle extends ResponseStyle$2 = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions$5<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
293
307
|
serializedBody?: string;
|
|
294
308
|
}
|
|
295
|
-
type RequestResult$
|
|
309
|
+
type RequestResult$5<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle$2 = 'fields'> = Promise<ThrowOnError extends true ? TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
|
|
296
310
|
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
297
311
|
request: HttpRequest<unknown>;
|
|
298
312
|
response: HttpResponse<TData>;
|
|
@@ -309,36 +323,36 @@ type RequestResult$4<TData = unknown, TError = unknown, ThrowOnError extends boo
|
|
|
309
323
|
error: TError[keyof TError] | null;
|
|
310
324
|
};
|
|
311
325
|
}>;
|
|
312
|
-
interface ClientOptions$
|
|
326
|
+
interface ClientOptions$5 {
|
|
313
327
|
baseUrl?: string;
|
|
314
|
-
responseStyle?: ResponseStyle$
|
|
328
|
+
responseStyle?: ResponseStyle$2;
|
|
315
329
|
throwOnError?: boolean;
|
|
316
330
|
}
|
|
317
|
-
type MethodFn$
|
|
318
|
-
type SseFn$
|
|
319
|
-
type RequestFn$
|
|
320
|
-
type RequestOptionsFn = <ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$
|
|
321
|
-
type BuildUrlFn$
|
|
331
|
+
type MethodFn$5 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: Omit<RequestOptions$5<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult$5<TData, TError, ThrowOnError, TResponseStyle>;
|
|
332
|
+
type SseFn$5 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: Omit<RequestOptions$5<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
333
|
+
type RequestFn$5 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: Omit<RequestOptions$5<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions$5<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult$5<TData, TError, ThrowOnError, TResponseStyle>;
|
|
334
|
+
type RequestOptionsFn = <ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: RequestOptions$5<unknown, TResponseStyle, ThrowOnError>) => HttpRequest<unknown>;
|
|
335
|
+
type BuildUrlFn$5 = <TData extends {
|
|
322
336
|
body?: unknown;
|
|
323
337
|
path?: Record<string, unknown>;
|
|
324
338
|
query?: Record<string, unknown>;
|
|
325
339
|
url: string;
|
|
326
|
-
}>(options: Pick<TData, 'url'> & Options$
|
|
327
|
-
type Client$
|
|
328
|
-
interceptors: Middleware$
|
|
340
|
+
}>(options: Pick<TData, 'url'> & Options$5<TData>) => string;
|
|
341
|
+
type Client$5 = Client$6<RequestFn$5, Config$5, MethodFn$5, BuildUrlFn$5, SseFn$5> & {
|
|
342
|
+
interceptors: Middleware$3<HttpRequest<unknown>, HttpResponse<unknown>, unknown, ResolvedRequestOptions$3>;
|
|
329
343
|
requestOptions: RequestOptionsFn;
|
|
330
344
|
};
|
|
331
|
-
interface TDataShape$
|
|
345
|
+
interface TDataShape$5 {
|
|
332
346
|
body?: unknown;
|
|
333
347
|
headers?: unknown;
|
|
334
348
|
path?: unknown;
|
|
335
349
|
query?: unknown;
|
|
336
350
|
url: string;
|
|
337
351
|
}
|
|
338
|
-
type OmitKeys$
|
|
339
|
-
type Options$
|
|
352
|
+
type OmitKeys$5<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
353
|
+
type Options$5<TData extends TDataShape$5 = TDataShape$5, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle$2 = 'fields'> = OmitKeys$5<RequestOptions$5<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>;
|
|
340
354
|
|
|
341
|
-
interface Config$
|
|
355
|
+
interface Config$4<T extends ClientOptions$4 = ClientOptions$4> extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>, Config$6 {
|
|
342
356
|
/**
|
|
343
357
|
* Axios implementation. You can use this option to provide either an
|
|
344
358
|
* `AxiosStatic` or an `AxiosInstance`.
|
|
@@ -364,7 +378,7 @@ interface Config$3<T extends ClientOptions$3 = ClientOptions$3> extends Omit<Cre
|
|
|
364
378
|
*/
|
|
365
379
|
throwOnError?: T['throwOnError'];
|
|
366
380
|
}
|
|
367
|
-
interface RequestOptions$
|
|
381
|
+
interface RequestOptions$4<TData = unknown, ThrowOnError extends boolean = boolean, Url extends string = string> extends Config$4<{
|
|
368
382
|
throwOnError: ThrowOnError;
|
|
369
383
|
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
370
384
|
/**
|
|
@@ -381,42 +395,42 @@ interface RequestOptions$3<TData = unknown, ThrowOnError extends boolean = boole
|
|
|
381
395
|
security?: ReadonlyArray<Auth>;
|
|
382
396
|
url: Url;
|
|
383
397
|
}
|
|
384
|
-
interface ClientOptions$
|
|
398
|
+
interface ClientOptions$4 {
|
|
385
399
|
baseURL?: string;
|
|
386
400
|
throwOnError?: boolean;
|
|
387
401
|
}
|
|
388
|
-
type RequestResult$
|
|
402
|
+
type RequestResult$4<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<AxiosResponse<TData extends Record<string, unknown> ? TData[keyof TData] : TData>> : Promise<(AxiosResponse<TData extends Record<string, unknown> ? TData[keyof TData] : TData> & {
|
|
389
403
|
error: undefined;
|
|
390
404
|
}) | (AxiosError<TError extends Record<string, unknown> ? TError[keyof TError] : TError> & {
|
|
391
405
|
data: undefined;
|
|
392
406
|
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
393
407
|
})>;
|
|
394
|
-
type MethodFn$
|
|
395
|
-
type SseFn$
|
|
396
|
-
type RequestFn$
|
|
397
|
-
type BuildUrlFn$
|
|
408
|
+
type MethodFn$4 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions$4<TData, ThrowOnError>, 'method'>) => RequestResult$4<TData, TError, ThrowOnError>;
|
|
409
|
+
type SseFn$4 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions$4<TData, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
410
|
+
type RequestFn$4 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions$4<TData, ThrowOnError>, 'method'> & Pick<Required<RequestOptions$4<TData, ThrowOnError>>, 'method'>) => RequestResult$4<TData, TError, ThrowOnError>;
|
|
411
|
+
type BuildUrlFn$4 = <TData extends {
|
|
398
412
|
body?: unknown;
|
|
399
413
|
path?: Record<string, unknown>;
|
|
400
414
|
query?: Record<string, unknown>;
|
|
401
415
|
url: string;
|
|
402
|
-
}>(options: Pick<TData, 'url'> &
|
|
403
|
-
type Client$
|
|
416
|
+
}>(options: Pick<TData, 'url'> & Options$4<TData>) => string;
|
|
417
|
+
type Client$4 = Client$6<RequestFn$4, Config$4, MethodFn$4, BuildUrlFn$4, SseFn$4> & {
|
|
404
418
|
instance: AxiosInstance;
|
|
405
419
|
};
|
|
406
|
-
interface TDataShape$
|
|
420
|
+
interface TDataShape$4 {
|
|
407
421
|
body?: unknown;
|
|
408
422
|
headers?: unknown;
|
|
409
423
|
path?: unknown;
|
|
410
424
|
query?: unknown;
|
|
411
425
|
url: string;
|
|
412
426
|
}
|
|
413
|
-
type OmitKeys$
|
|
414
|
-
type Options$
|
|
427
|
+
type OmitKeys$4<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
428
|
+
type Options$4<TData extends TDataShape$4 = TDataShape$4, ThrowOnError extends boolean = boolean, TResponse = unknown> = OmitKeys$4<RequestOptions$4<TResponse, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>;
|
|
415
429
|
|
|
416
|
-
type ErrInterceptor$
|
|
417
|
-
type ReqInterceptor$
|
|
418
|
-
type ResInterceptor$
|
|
419
|
-
declare class Interceptors$
|
|
430
|
+
type ErrInterceptor$2<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
431
|
+
type ReqInterceptor$2<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
432
|
+
type ResInterceptor$2<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
433
|
+
declare class Interceptors$2<Interceptor> {
|
|
420
434
|
fns: Array<Interceptor | null>;
|
|
421
435
|
clear(): void;
|
|
422
436
|
eject(id: number | Interceptor): void;
|
|
@@ -425,14 +439,14 @@ declare class Interceptors$1<Interceptor> {
|
|
|
425
439
|
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
426
440
|
use(fn: Interceptor): number;
|
|
427
441
|
}
|
|
428
|
-
interface Middleware$
|
|
429
|
-
error: Interceptors$
|
|
430
|
-
request: Interceptors$
|
|
431
|
-
response: Interceptors$
|
|
442
|
+
interface Middleware$2<Req, Res, Err, Options> {
|
|
443
|
+
error: Interceptors$2<ErrInterceptor$2<Err, Res, Req, Options>>;
|
|
444
|
+
request: Interceptors$2<ReqInterceptor$2<Req, Options>>;
|
|
445
|
+
response: Interceptors$2<ResInterceptor$2<Res, Req, Options>>;
|
|
432
446
|
}
|
|
433
447
|
|
|
434
|
-
type ResponseStyle = 'data' | 'fields';
|
|
435
|
-
interface Config$
|
|
448
|
+
type ResponseStyle$1 = 'data' | 'fields';
|
|
449
|
+
interface Config$3<T extends ClientOptions$3 = ClientOptions$3> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$6 {
|
|
436
450
|
/**
|
|
437
451
|
* Base URL for all requests made by this client.
|
|
438
452
|
*/
|
|
@@ -465,7 +479,7 @@ interface Config$2<T extends ClientOptions$2 = ClientOptions$2> extends Omit<Req
|
|
|
465
479
|
*
|
|
466
480
|
* @default 'fields'
|
|
467
481
|
*/
|
|
468
|
-
responseStyle?: ResponseStyle;
|
|
482
|
+
responseStyle?: ResponseStyle$1;
|
|
469
483
|
/**
|
|
470
484
|
* Throw an error instead of returning it in the response?
|
|
471
485
|
*
|
|
@@ -473,7 +487,7 @@ interface Config$2<T extends ClientOptions$2 = ClientOptions$2> extends Omit<Req
|
|
|
473
487
|
*/
|
|
474
488
|
throwOnError?: T['throwOnError'];
|
|
475
489
|
}
|
|
476
|
-
interface RequestOptions$
|
|
490
|
+
interface RequestOptions$3<TData = unknown, TResponseStyle extends ResponseStyle$1 = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config$3<{
|
|
477
491
|
responseStyle: TResponseStyle;
|
|
478
492
|
throwOnError: ThrowOnError;
|
|
479
493
|
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
@@ -491,10 +505,10 @@ interface RequestOptions$2<TData = unknown, TResponseStyle extends ResponseStyle
|
|
|
491
505
|
security?: ReadonlyArray<Auth>;
|
|
492
506
|
url: Url;
|
|
493
507
|
}
|
|
494
|
-
interface ResolvedRequestOptions$
|
|
508
|
+
interface ResolvedRequestOptions$2<TResponseStyle extends ResponseStyle$1 = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions$3<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
495
509
|
serializedBody?: string;
|
|
496
510
|
}
|
|
497
|
-
type RequestResult$
|
|
511
|
+
type RequestResult$3<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle$1 = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
|
|
498
512
|
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
499
513
|
request: Request;
|
|
500
514
|
response: Response;
|
|
@@ -508,37 +522,37 @@ type RequestResult$2<TData = unknown, TError = unknown, ThrowOnError extends boo
|
|
|
508
522
|
request: Request;
|
|
509
523
|
response: Response;
|
|
510
524
|
}>;
|
|
511
|
-
interface ClientOptions$
|
|
525
|
+
interface ClientOptions$3 {
|
|
512
526
|
baseUrl?: string;
|
|
513
|
-
responseStyle?: ResponseStyle;
|
|
527
|
+
responseStyle?: ResponseStyle$1;
|
|
514
528
|
throwOnError?: boolean;
|
|
515
529
|
}
|
|
516
|
-
type MethodFn$
|
|
517
|
-
type SseFn$
|
|
518
|
-
type RequestFn$
|
|
519
|
-
type BuildUrlFn$
|
|
530
|
+
type MethodFn$3 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$1 = 'fields'>(options: Omit<RequestOptions$3<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult$3<TData, TError, ThrowOnError, TResponseStyle>;
|
|
531
|
+
type SseFn$3 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$1 = 'fields'>(options: Omit<RequestOptions$3<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
532
|
+
type RequestFn$3 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$1 = 'fields'>(options: Omit<RequestOptions$3<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions$3<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult$3<TData, TError, ThrowOnError, TResponseStyle>;
|
|
533
|
+
type BuildUrlFn$3 = <TData extends {
|
|
520
534
|
body?: unknown;
|
|
521
535
|
path?: Record<string, unknown>;
|
|
522
536
|
query?: Record<string, unknown>;
|
|
523
537
|
url: string;
|
|
524
|
-
}>(options: Pick<TData, 'url'> & Options$
|
|
525
|
-
type Client$
|
|
526
|
-
interceptors: Middleware$
|
|
538
|
+
}>(options: Pick<TData, 'url'> & Options$3<TData>) => string;
|
|
539
|
+
type Client$3 = Client$6<RequestFn$3, Config$3, MethodFn$3, BuildUrlFn$3, SseFn$3> & {
|
|
540
|
+
interceptors: Middleware$2<Request, Response, unknown, ResolvedRequestOptions$2>;
|
|
527
541
|
};
|
|
528
|
-
interface TDataShape$
|
|
542
|
+
interface TDataShape$3 {
|
|
529
543
|
body?: unknown;
|
|
530
544
|
headers?: unknown;
|
|
531
545
|
path?: unknown;
|
|
532
546
|
query?: unknown;
|
|
533
547
|
url: string;
|
|
534
548
|
}
|
|
535
|
-
type OmitKeys$
|
|
536
|
-
type Options$
|
|
549
|
+
type OmitKeys$3<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
550
|
+
type Options$3<TData extends TDataShape$3 = TDataShape$3, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle$1 = 'fields'> = OmitKeys$3<RequestOptions$3<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>;
|
|
537
551
|
|
|
538
|
-
type ErrInterceptor<Err, Res, Options> = (error: Err, response: Res, options: Options) => Err | Promise<Err>;
|
|
539
|
-
type ReqInterceptor<Options> = (options: Options) => void | Promise<void>;
|
|
540
|
-
type ResInterceptor<Res, Options> = (response: Res, options: Options) => Res | Promise<Res>;
|
|
541
|
-
declare class Interceptors<Interceptor> {
|
|
552
|
+
type ErrInterceptor$1<Err, Res, Options> = (error: Err, response: Res, options: Options) => Err | Promise<Err>;
|
|
553
|
+
type ReqInterceptor$1<Options> = (options: Options) => void | Promise<void>;
|
|
554
|
+
type ResInterceptor$1<Res, Options> = (response: Res, options: Options) => Res | Promise<Res>;
|
|
555
|
+
declare class Interceptors$1<Interceptor> {
|
|
542
556
|
fns: Array<Interceptor | null>;
|
|
543
557
|
clear(): void;
|
|
544
558
|
eject(id: number | Interceptor): void;
|
|
@@ -547,13 +561,13 @@ declare class Interceptors<Interceptor> {
|
|
|
547
561
|
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
548
562
|
use(fn: Interceptor): number;
|
|
549
563
|
}
|
|
550
|
-
interface Middleware<Res, Err, Options> {
|
|
551
|
-
error: Interceptors<ErrInterceptor<Err, Res, Options>>;
|
|
552
|
-
request: Interceptors<ReqInterceptor<Options>>;
|
|
553
|
-
response: Interceptors<ResInterceptor<Res, Options>>;
|
|
564
|
+
interface Middleware$1<Res, Err, Options> {
|
|
565
|
+
error: Interceptors$1<ErrInterceptor$1<Err, Res, Options>>;
|
|
566
|
+
request: Interceptors$1<ReqInterceptor$1<Options>>;
|
|
567
|
+
response: Interceptors$1<ResInterceptor$1<Res, Options>>;
|
|
554
568
|
}
|
|
555
569
|
|
|
556
|
-
interface Config$
|
|
570
|
+
interface Config$2<T extends ClientOptions$2 = ClientOptions$2> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$6 {
|
|
557
571
|
/**
|
|
558
572
|
* Base URL for all requests made by this client.
|
|
559
573
|
*/
|
|
@@ -581,7 +595,7 @@ interface Config$1<T extends ClientOptions$1 = ClientOptions$1> extends Omit<Req
|
|
|
581
595
|
*/
|
|
582
596
|
throwOnError?: T['throwOnError'];
|
|
583
597
|
}
|
|
584
|
-
interface RequestOptions$
|
|
598
|
+
interface RequestOptions$2<TData = unknown, ThrowOnError extends boolean = boolean, Url extends string = string> extends Config$2<{
|
|
585
599
|
throwOnError: ThrowOnError;
|
|
586
600
|
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
587
601
|
/**
|
|
@@ -598,10 +612,10 @@ interface RequestOptions$1<TData = unknown, ThrowOnError extends boolean = boole
|
|
|
598
612
|
security?: ReadonlyArray<Auth>;
|
|
599
613
|
url: Url;
|
|
600
614
|
}
|
|
601
|
-
interface ResolvedRequestOptions<ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions$
|
|
615
|
+
interface ResolvedRequestOptions$1<ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions$2<unknown, ThrowOnError, Url> {
|
|
602
616
|
serializedBody?: string;
|
|
603
617
|
}
|
|
604
|
-
type RequestResult$
|
|
618
|
+
type RequestResult$2<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<{
|
|
605
619
|
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
606
620
|
response: Response;
|
|
607
621
|
}> : Promise<({
|
|
@@ -613,38 +627,38 @@ type RequestResult$1<TData = unknown, TError = unknown, ThrowOnError extends boo
|
|
|
613
627
|
}) & {
|
|
614
628
|
response: Response;
|
|
615
629
|
}>;
|
|
616
|
-
interface ClientOptions$
|
|
630
|
+
interface ClientOptions$2 {
|
|
617
631
|
baseUrl?: string;
|
|
618
632
|
throwOnError?: boolean;
|
|
619
633
|
}
|
|
620
|
-
type MethodFn$
|
|
621
|
-
type SseFn$
|
|
622
|
-
type RequestFn$
|
|
623
|
-
type BuildUrlFn$
|
|
634
|
+
type MethodFn$2 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions$2<TData, ThrowOnError>, 'method'>) => RequestResult$2<TData, TError, ThrowOnError>;
|
|
635
|
+
type SseFn$2 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions$2<TData, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
636
|
+
type RequestFn$2 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions$2<TData, ThrowOnError>, 'method'> & Pick<Required<RequestOptions$2<TData, ThrowOnError>>, 'method'>) => RequestResult$2<TData, TError, ThrowOnError>;
|
|
637
|
+
type BuildUrlFn$2 = <TData extends {
|
|
624
638
|
body?: unknown;
|
|
625
639
|
path?: Record<string, unknown>;
|
|
626
640
|
query?: Record<string, unknown>;
|
|
627
641
|
url: string;
|
|
628
|
-
}>(options: Pick<TData, 'url'> & Options$
|
|
629
|
-
type Client$
|
|
630
|
-
interceptors: Middleware<Response, unknown, ResolvedRequestOptions>;
|
|
642
|
+
}>(options: Pick<TData, 'url'> & Options$2<TData>) => string;
|
|
643
|
+
type Client$2 = Client$6<RequestFn$2, Config$2, MethodFn$2, BuildUrlFn$2, SseFn$2> & {
|
|
644
|
+
interceptors: Middleware$1<Response, unknown, ResolvedRequestOptions$1>;
|
|
631
645
|
};
|
|
632
|
-
interface TDataShape$
|
|
646
|
+
interface TDataShape$2 {
|
|
633
647
|
body?: unknown;
|
|
634
648
|
headers?: unknown;
|
|
635
649
|
path?: unknown;
|
|
636
650
|
query?: unknown;
|
|
637
651
|
url: string;
|
|
638
652
|
}
|
|
639
|
-
type OmitKeys$
|
|
640
|
-
type Options$
|
|
653
|
+
type OmitKeys$2<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
654
|
+
type Options$2<TData extends TDataShape$2 = TDataShape$2, ThrowOnError extends boolean = boolean, TResponse = unknown> = OmitKeys$2<RequestOptions$2<TResponse, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>;
|
|
641
655
|
|
|
642
|
-
type QuerySerializer = (query: Parameters<Client['buildUrl']>[0]['query']) => string;
|
|
656
|
+
type QuerySerializer = (query: Parameters<Client$1['buildUrl']>[0]['query']) => string;
|
|
643
657
|
type WithRefs<TData> = {
|
|
644
658
|
[K in keyof TData]: NonNullable<TData[K]> extends object ? WithRefs<NonNullable<TData[K]>> | Ref<NonNullable<TData[K]>> : NonNullable<TData[K]> | Ref<NonNullable<TData[K]>>;
|
|
645
659
|
};
|
|
646
660
|
type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
|
|
647
|
-
interface Config<T extends ClientOptions = ClientOptions> extends Omit<FetchOptions<unknown>, 'baseURL' | 'body' | 'headers' | 'method' | 'query'>, WithRefs<Pick<FetchOptions<unknown>, 'query'>>, Omit<Config$
|
|
661
|
+
interface Config$1<T extends ClientOptions$1 = ClientOptions$1> extends Omit<FetchOptions<unknown>, 'baseURL' | 'body' | 'headers' | 'method' | 'query'>, WithRefs<Pick<FetchOptions<unknown>, 'query'>>, Omit<Config$6, 'querySerializer'> {
|
|
648
662
|
/**
|
|
649
663
|
* Base URL for all requests made by this client.
|
|
650
664
|
*/
|
|
@@ -658,7 +672,7 @@ interface Config<T extends ClientOptions = ClientOptions> extends Omit<FetchOpti
|
|
|
658
672
|
*/
|
|
659
673
|
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
660
674
|
}
|
|
661
|
-
interface RequestOptions<TComposable extends Composable = '$fetch', ResT = unknown, DefaultT = undefined, Url extends string = string> extends Config, WithRefs<{
|
|
675
|
+
interface RequestOptions$1<TComposable extends Composable = '$fetch', ResT = unknown, DefaultT = undefined, Url extends string = string> extends Config$1, WithRefs<{
|
|
662
676
|
/**
|
|
663
677
|
* Any body that you want to add to your request.
|
|
664
678
|
*
|
|
@@ -678,28 +692,210 @@ interface RequestOptions<TComposable extends Composable = '$fetch', ResT = unkno
|
|
|
678
692
|
security?: ReadonlyArray<Auth>;
|
|
679
693
|
url: Url;
|
|
680
694
|
}
|
|
681
|
-
type RequestResult<TComposable extends Composable, ResT, TError> = TComposable extends '$fetch' ? ReturnType<typeof $fetch<ResT>> : TComposable extends 'useAsyncData' ? ReturnType<typeof useAsyncData<ResT | null, TError>> : TComposable extends 'useFetch' ? ReturnType<typeof useFetch<ResT | null, TError>> : TComposable extends 'useLazyAsyncData' ? ReturnType<typeof useLazyAsyncData<ResT | null, TError>> : TComposable extends 'useLazyFetch' ? ReturnType<typeof useLazyFetch<ResT | null, TError>> : never;
|
|
682
|
-
interface ClientOptions {
|
|
695
|
+
type RequestResult$1<TComposable extends Composable, ResT, TError> = TComposable extends '$fetch' ? ReturnType<typeof $fetch<ResT>> : TComposable extends 'useAsyncData' ? ReturnType<typeof useAsyncData<ResT | null, TError>> : TComposable extends 'useFetch' ? ReturnType<typeof useFetch<ResT | null, TError>> : TComposable extends 'useLazyAsyncData' ? ReturnType<typeof useLazyAsyncData<ResT | null, TError>> : TComposable extends 'useLazyFetch' ? ReturnType<typeof useLazyFetch<ResT | null, TError>> : never;
|
|
696
|
+
interface ClientOptions$1 {
|
|
683
697
|
baseURL?: string;
|
|
684
698
|
}
|
|
685
|
-
type MethodFn = <TComposable extends Composable = '$fetch', ResT = unknown, TError = unknown, DefaultT = undefined>(options: Omit<RequestOptions<TComposable, ResT, DefaultT>, 'method'>) => RequestResult<TComposable, ResT, TError>;
|
|
686
|
-
type SseFn = <TComposable extends Composable = '$fetch', ResT = unknown, TError = unknown, DefaultT = undefined>(options: Omit<RequestOptions<TComposable, ResT, DefaultT>, 'method'>) => Promise<ServerSentEventsResult<RequestResult<TComposable, ResT, TError>>>;
|
|
687
|
-
type RequestFn = <TComposable extends Composable = '$fetch', ResT = unknown, TError = unknown, DefaultT = undefined>(options: Omit<RequestOptions<TComposable, ResT, DefaultT>, 'method'> & Pick<Required<RequestOptions<TComposable, ResT, DefaultT>>, 'method'>) => RequestResult<TComposable, ResT, TError>;
|
|
688
|
-
interface TDataShape {
|
|
699
|
+
type MethodFn$1 = <TComposable extends Composable = '$fetch', ResT = unknown, TError = unknown, DefaultT = undefined>(options: Omit<RequestOptions$1<TComposable, ResT, DefaultT>, 'method'>) => RequestResult$1<TComposable, ResT, TError>;
|
|
700
|
+
type SseFn$1 = <TComposable extends Composable = '$fetch', ResT = unknown, TError = unknown, DefaultT = undefined>(options: Omit<RequestOptions$1<TComposable, ResT, DefaultT>, 'method'>) => Promise<ServerSentEventsResult<RequestResult$1<TComposable, ResT, TError>>>;
|
|
701
|
+
type RequestFn$1 = <TComposable extends Composable = '$fetch', ResT = unknown, TError = unknown, DefaultT = undefined>(options: Omit<RequestOptions$1<TComposable, ResT, DefaultT>, 'method'> & Pick<Required<RequestOptions$1<TComposable, ResT, DefaultT>>, 'method'>) => RequestResult$1<TComposable, ResT, TError>;
|
|
702
|
+
interface TDataShape$1 {
|
|
689
703
|
body?: unknown;
|
|
690
704
|
headers?: unknown;
|
|
691
705
|
path?: FetchOptions<unknown>['query'];
|
|
692
706
|
query?: FetchOptions<unknown>['query'];
|
|
693
707
|
url: string;
|
|
694
708
|
}
|
|
695
|
-
type BuildUrlOptions<TData extends Omit<TDataShape, 'headers'> = Omit<TDataShape, 'headers'>> = Pick<WithRefs<TData>, 'path' | 'query'> & Pick<TData, 'url'> & Pick<Options<'$fetch', TData>, 'baseURL' | 'querySerializer'>;
|
|
696
|
-
type BuildUrlFn = <TData extends Omit<TDataShape, 'headers'>>(options: BuildUrlOptions<TData>) => string;
|
|
697
|
-
type Client = Client$
|
|
698
|
-
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
699
|
-
type Options<TComposable extends Composable = '$fetch', TData extends TDataShape = TDataShape, ResT = unknown, DefaultT = undefined> = OmitKeys<RequestOptions<TComposable, ResT, DefaultT>, 'body' | 'path' | 'query' | 'url'> & WithRefs<Omit<TData, 'url'>>;
|
|
709
|
+
type BuildUrlOptions<TData extends Omit<TDataShape$1, 'headers'> = Omit<TDataShape$1, 'headers'>> = Pick<WithRefs<TData>, 'path' | 'query'> & Pick<TData, 'url'> & Pick<Options$1<'$fetch', TData>, 'baseURL' | 'querySerializer'>;
|
|
710
|
+
type BuildUrlFn$1 = <TData extends Omit<TDataShape$1, 'headers'>>(options: BuildUrlOptions<TData>) => string;
|
|
711
|
+
type Client$1 = Client$6<RequestFn$1, Config$1, MethodFn$1, BuildUrlFn$1, SseFn$1>;
|
|
712
|
+
type OmitKeys$1<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
713
|
+
type Options$1<TComposable extends Composable = '$fetch', TData extends TDataShape$1 = TDataShape$1, ResT = unknown, DefaultT = undefined> = OmitKeys$1<RequestOptions$1<TComposable, ResT, DefaultT>, 'body' | 'path' | 'query' | 'url'> & WithRefs<Omit<TData, 'url'>>;
|
|
700
714
|
type FetchOptions<TData> = Omit<UseFetchOptions<TData, TData>, keyof AsyncDataOptions<TData>>;
|
|
701
715
|
type Composable = '$fetch' | 'useAsyncData' | 'useFetch' | 'useLazyAsyncData' | 'useLazyFetch';
|
|
702
716
|
|
|
717
|
+
type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
718
|
+
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
719
|
+
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
720
|
+
declare class Interceptors<Interceptor> {
|
|
721
|
+
fns: Array<Interceptor | null>;
|
|
722
|
+
clear(): void;
|
|
723
|
+
eject(id: number | Interceptor): void;
|
|
724
|
+
exists(id: number | Interceptor): boolean;
|
|
725
|
+
getInterceptorIndex(id: number | Interceptor): number;
|
|
726
|
+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
727
|
+
use(fn: Interceptor): number;
|
|
728
|
+
}
|
|
729
|
+
interface Middleware<Req, Res, Err, Options> {
|
|
730
|
+
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
731
|
+
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
732
|
+
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
type ResponseStyle = 'data' | 'fields';
|
|
736
|
+
interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$6 {
|
|
737
|
+
/**
|
|
738
|
+
* HTTP(S) agent configuration (Node.js only). Passed through to ofetch.
|
|
739
|
+
*/
|
|
740
|
+
agent?: FetchOptions$1['agent'];
|
|
741
|
+
/**
|
|
742
|
+
* Base URL for all requests made by this client.
|
|
743
|
+
*/
|
|
744
|
+
baseUrl?: T['baseUrl'];
|
|
745
|
+
/**
|
|
746
|
+
* Node-only proxy/agent options.
|
|
747
|
+
*/
|
|
748
|
+
dispatcher?: FetchOptions$1['dispatcher'];
|
|
749
|
+
/**
|
|
750
|
+
* Fetch API implementation. Used for SSE streaming. You can use this option
|
|
751
|
+
* to provide a custom fetch instance.
|
|
752
|
+
*
|
|
753
|
+
* @default globalThis.fetch
|
|
754
|
+
*/
|
|
755
|
+
fetch?: typeof fetch;
|
|
756
|
+
/**
|
|
757
|
+
* Controls the native ofetch behaviour that throws `FetchError` when
|
|
758
|
+
* `response.ok === false`. We default to suppressing it to match the fetch
|
|
759
|
+
* client semantics and let `throwOnError` drive the outcome.
|
|
760
|
+
*/
|
|
761
|
+
ignoreResponseError?: FetchOptions$1['ignoreResponseError'];
|
|
762
|
+
/**
|
|
763
|
+
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
764
|
+
* options won't have any effect.
|
|
765
|
+
*
|
|
766
|
+
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
767
|
+
*/
|
|
768
|
+
next?: never;
|
|
769
|
+
/**
|
|
770
|
+
* Custom ofetch instance created via `ofetch.create()`. If provided, it will
|
|
771
|
+
* be used for requests instead of the default `ofetch` export.
|
|
772
|
+
*/
|
|
773
|
+
ofetch?: typeof ofetch;
|
|
774
|
+
/**
|
|
775
|
+
* ofetch hook called before a request is sent.
|
|
776
|
+
*/
|
|
777
|
+
onRequest?: FetchOptions$1['onRequest'];
|
|
778
|
+
/**
|
|
779
|
+
* ofetch hook called when a request fails before receiving a response
|
|
780
|
+
* (e.g., network errors or aborted requests).
|
|
781
|
+
*/
|
|
782
|
+
onRequestError?: FetchOptions$1['onRequestError'];
|
|
783
|
+
/**
|
|
784
|
+
* ofetch hook called after a successful response is received and parsed.
|
|
785
|
+
*/
|
|
786
|
+
onResponse?: FetchOptions$1['onResponse'];
|
|
787
|
+
/**
|
|
788
|
+
* ofetch hook called when the response indicates an error (non-ok status)
|
|
789
|
+
* or when response parsing fails.
|
|
790
|
+
*/
|
|
791
|
+
onResponseError?: FetchOptions$1['onResponseError'];
|
|
792
|
+
/**
|
|
793
|
+
* Return the response data parsed in a specified format. By default, `auto`
|
|
794
|
+
* will infer the appropriate method from the `Content-Type` response header.
|
|
795
|
+
* You can override this behavior with any of the {@link Body} methods.
|
|
796
|
+
* Select `stream` if you don't want to parse response data at all.
|
|
797
|
+
*
|
|
798
|
+
* @default 'auto'
|
|
799
|
+
*/
|
|
800
|
+
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
|
801
|
+
/** Custom response parser (ofetch). */
|
|
802
|
+
parseResponse?: FetchOptions$1['parseResponse'];
|
|
803
|
+
/**
|
|
804
|
+
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
805
|
+
*
|
|
806
|
+
* @default 'fields'
|
|
807
|
+
*/
|
|
808
|
+
responseStyle?: ResponseStyle;
|
|
809
|
+
/**
|
|
810
|
+
* ofetch responseType override. If provided, it will be passed directly to
|
|
811
|
+
* ofetch and take precedence over `parseAs`.
|
|
812
|
+
*/
|
|
813
|
+
responseType?: ResponseType;
|
|
814
|
+
/**
|
|
815
|
+
* Automatically retry failed requests.
|
|
816
|
+
*/
|
|
817
|
+
retry?: FetchOptions$1['retry'];
|
|
818
|
+
/**
|
|
819
|
+
* Delay (in ms) between retry attempts.
|
|
820
|
+
*/
|
|
821
|
+
retryDelay?: FetchOptions$1['retryDelay'];
|
|
822
|
+
/**
|
|
823
|
+
* HTTP status codes that should trigger a retry.
|
|
824
|
+
*/
|
|
825
|
+
retryStatusCodes?: FetchOptions$1['retryStatusCodes'];
|
|
826
|
+
/**
|
|
827
|
+
* Throw an error instead of returning it in the response?
|
|
828
|
+
*
|
|
829
|
+
* @default false
|
|
830
|
+
*/
|
|
831
|
+
throwOnError?: T['throwOnError'];
|
|
832
|
+
/**
|
|
833
|
+
* Abort the request after the given milliseconds.
|
|
834
|
+
*/
|
|
835
|
+
timeout?: number;
|
|
836
|
+
}
|
|
837
|
+
interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
838
|
+
responseStyle: TResponseStyle;
|
|
839
|
+
throwOnError: ThrowOnError;
|
|
840
|
+
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
841
|
+
/**
|
|
842
|
+
* Any body that you want to add to your request.
|
|
843
|
+
*
|
|
844
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
845
|
+
*/
|
|
846
|
+
body?: unknown;
|
|
847
|
+
path?: Record<string, unknown>;
|
|
848
|
+
query?: Record<string, unknown>;
|
|
849
|
+
/**
|
|
850
|
+
* Security mechanism(s) to use for the request.
|
|
851
|
+
*/
|
|
852
|
+
security?: ReadonlyArray<Auth>;
|
|
853
|
+
url: Url;
|
|
854
|
+
}
|
|
855
|
+
interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
856
|
+
serializedBody?: string;
|
|
857
|
+
}
|
|
858
|
+
type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
|
|
859
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
860
|
+
request: Request;
|
|
861
|
+
response: Response;
|
|
862
|
+
}> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
|
|
863
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
864
|
+
error: undefined;
|
|
865
|
+
} | {
|
|
866
|
+
data: undefined;
|
|
867
|
+
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
868
|
+
}) & {
|
|
869
|
+
request: Request;
|
|
870
|
+
response: Response;
|
|
871
|
+
}>;
|
|
872
|
+
interface ClientOptions {
|
|
873
|
+
baseUrl?: string;
|
|
874
|
+
responseStyle?: ResponseStyle;
|
|
875
|
+
throwOnError?: boolean;
|
|
876
|
+
}
|
|
877
|
+
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
878
|
+
type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
879
|
+
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
880
|
+
type BuildUrlFn = <TData extends {
|
|
881
|
+
body?: unknown;
|
|
882
|
+
path?: Record<string, unknown>;
|
|
883
|
+
query?: Record<string, unknown>;
|
|
884
|
+
url: string;
|
|
885
|
+
}>(options: Pick<TData, 'url'> & Options<TData>) => string;
|
|
886
|
+
type Client = Client$6<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
887
|
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
888
|
+
};
|
|
889
|
+
interface TDataShape {
|
|
890
|
+
body?: unknown;
|
|
891
|
+
headers?: unknown;
|
|
892
|
+
path?: unknown;
|
|
893
|
+
query?: unknown;
|
|
894
|
+
url: string;
|
|
895
|
+
}
|
|
896
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
897
|
+
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>;
|
|
898
|
+
|
|
703
899
|
declare const defaultPaginationKeywords: readonly ["after", "before", "cursor", "offset", "page", "start"];
|
|
704
900
|
|
|
705
901
|
/**
|
|
@@ -714,7 +910,6 @@ declare const clientDefaultConfig: {
|
|
|
714
910
|
};
|
|
715
911
|
declare const clientDefaultMeta: {
|
|
716
912
|
readonly dependencies: readonly ["@hey-api/typescript"];
|
|
717
|
-
readonly output: "client";
|
|
718
913
|
readonly tags: readonly ["client"];
|
|
719
914
|
};
|
|
720
915
|
|
|
@@ -1366,10 +1561,10 @@ type Configs = UserConfig | (() => UserConfig) | (() => Promise<UserConfig>);
|
|
|
1366
1561
|
*
|
|
1367
1562
|
* @param userConfig User provided {@link UserConfig} configuration.
|
|
1368
1563
|
*/
|
|
1369
|
-
declare const createClient: (userConfig?: Configs, logger?: Logger) => Promise<ReadonlyArray<Client$
|
|
1564
|
+
declare const createClient: (userConfig?: Configs, logger?: Logger) => Promise<ReadonlyArray<Client$7 | IR.Context>>;
|
|
1370
1565
|
/**
|
|
1371
1566
|
* Type helper for openapi-ts.config.ts, returns {@link UserConfig} object
|
|
1372
1567
|
*/
|
|
1373
1568
|
declare const defineConfig: (config: Configs) => Promise<UserConfig>;
|
|
1374
1569
|
|
|
1375
|
-
export { type Client$
|
|
1570
|
+
export { type Client$5 as AngularClient, type Client$4 as AxiosClient, type Client$3 as FetchClient, IR, Logger, type Client$2 as NextClient, type Client$1 as NuxtClient, type Client as OfetchClient, Plugin, UserConfig, clientDefaultConfig, clientDefaultMeta, clientPluginHandler, compiler, createClient, defaultPaginationKeywords, defaultPlugins, defineConfig, definePluginConfig, tsc, utils };
|