@hey-api/openapi-ts 0.90.10 → 0.91.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.
Files changed (61) hide show
  1. package/dist/clients/angular/client.ts +23 -49
  2. package/dist/clients/angular/types.ts +11 -34
  3. package/dist/clients/angular/utils.ts +6 -22
  4. package/dist/clients/axios/client.ts +16 -27
  5. package/dist/clients/axios/types.ts +17 -54
  6. package/dist/clients/axios/utils.ts +3 -8
  7. package/dist/clients/core/auth.ts +1 -2
  8. package/dist/clients/core/bodySerializer.ts +5 -21
  9. package/dist/clients/core/params.ts +3 -10
  10. package/dist/clients/core/pathSerializer.ts +4 -14
  11. package/dist/clients/core/queryKeySerializer.ts +6 -25
  12. package/dist/clients/core/serverSentEvents.ts +8 -31
  13. package/dist/clients/core/types.ts +4 -18
  14. package/dist/clients/core/utils.ts +1 -4
  15. package/dist/clients/fetch/client.ts +25 -48
  16. package/dist/clients/fetch/types.ts +12 -40
  17. package/dist/clients/fetch/utils.ts +6 -22
  18. package/dist/clients/ky/client.ts +27 -58
  19. package/dist/clients/ky/types.ts +19 -47
  20. package/dist/clients/ky/utils.ts +6 -22
  21. package/dist/clients/next/client.ts +30 -47
  22. package/dist/clients/next/types.ts +13 -47
  23. package/dist/clients/next/utils.ts +8 -31
  24. package/dist/clients/nuxt/client.ts +18 -37
  25. package/dist/clients/nuxt/types.ts +12 -31
  26. package/dist/clients/nuxt/utils.ts +5 -17
  27. package/dist/clients/ofetch/client.ts +34 -60
  28. package/dist/clients/ofetch/types.ts +13 -44
  29. package/dist/clients/ofetch/utils.ts +20 -58
  30. package/dist/index.d.mts +8731 -54
  31. package/dist/index.d.mts.map +1 -0
  32. package/dist/index.mjs +2 -3
  33. package/dist/{openApi-Gs-XGatv.mjs → init-CvGgSlz8.mjs} +134 -8346
  34. package/dist/init-CvGgSlz8.mjs.map +1 -0
  35. package/dist/internal.d.mts +2 -68
  36. package/dist/internal.d.mts.map +1 -0
  37. package/dist/internal.mjs +2 -2
  38. package/dist/run.d.mts +0 -1
  39. package/dist/run.mjs +5 -7
  40. package/dist/run.mjs.map +1 -1
  41. package/dist/src-Dgh53q8K.mjs +228 -0
  42. package/dist/src-Dgh53q8K.mjs.map +1 -0
  43. package/dist/types-Ba27ofyy.d.mts +157 -0
  44. package/dist/types-Ba27ofyy.d.mts.map +1 -0
  45. package/package.json +39 -58
  46. package/dist/index.cjs +0 -30
  47. package/dist/index.d.cts +0 -990
  48. package/dist/internal.cjs +0 -6
  49. package/dist/internal.d.cts +0 -99
  50. package/dist/openApi-Dy5wknYZ.cjs +0 -22032
  51. package/dist/openApi-Dy5wknYZ.cjs.map +0 -1
  52. package/dist/openApi-Gs-XGatv.mjs.map +0 -1
  53. package/dist/run.cjs +0 -61
  54. package/dist/run.cjs.map +0 -1
  55. package/dist/run.d.cts +0 -2
  56. package/dist/src-DMQOp4DI.cjs +0 -476
  57. package/dist/src-DMQOp4DI.cjs.map +0 -1
  58. package/dist/src-YIQMkx2V.mjs +0 -455
  59. package/dist/src-YIQMkx2V.mjs.map +0 -1
  60. package/dist/types-BcLsQaJ_.d.cts +0 -15600
  61. package/dist/types-CLcjoomL.d.mts +0 -16472
@@ -1,12 +1,12 @@
1
+ import type { Options as KyOptions } from 'ky';
2
+ import type ky from 'ky';
3
+
1
4
  import type { Auth } from '../core/auth';
2
5
  import type {
3
6
  ServerSentEventsOptions,
4
7
  ServerSentEventsResult,
5
8
  } from '../core/serverSentEvents';
6
- import type {
7
- Client as CoreClient,
8
- Config as CoreConfig,
9
- } from '../core/types';
9
+ import type { Client as CoreClient, Config as CoreConfig } from '../core/types';
10
10
  import type { Middleware } from './utils';
11
11
 
12
12
  export type ResponseStyle = 'data' | 'fields';
@@ -23,9 +23,7 @@ export interface RetryOptions {
23
23
  *
24
24
  * @default ['get', 'put', 'head', 'delete', 'options', 'trace']
25
25
  */
26
- methods?: Array<
27
- 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace'
28
- >;
26
+ methods?: Array<'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace'>;
29
27
  /**
30
28
  * HTTP status codes to retry
31
29
  *
@@ -35,10 +33,8 @@ export interface RetryOptions {
35
33
  }
36
34
 
37
35
  export interface Config<T extends ClientOptions = ClientOptions>
38
- extends Omit<
39
- import('ky').Options,
40
- 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
41
- >,
36
+ extends
37
+ Omit<KyOptions, 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'>,
42
38
  CoreConfig {
43
39
  /**
44
40
  * Base URL for all requests made by this client.
@@ -48,12 +44,12 @@ export interface Config<T extends ClientOptions = ClientOptions>
48
44
  * Ky instance to use. You can use this option to provide a custom
49
45
  * ky instance.
50
46
  */
51
- ky?: typeof import('ky').default;
47
+ ky?: typeof ky;
52
48
  /**
53
49
  * Additional ky-specific options that will be passed directly to ky.
54
50
  * This allows you to use any ky option not explicitly exposed in the config.
55
51
  */
56
- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
52
+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
57
53
  /**
58
54
  * Return the response data parsed in a specified format. By default, `auto`
59
55
  * will infer the appropriate method from the `Content-Type` response header.
@@ -62,14 +58,7 @@ export interface Config<T extends ClientOptions = ClientOptions>
62
58
  *
63
59
  * @default 'auto'
64
60
  */
65
- parseAs?:
66
- | 'arrayBuffer'
67
- | 'auto'
68
- | 'blob'
69
- | 'formData'
70
- | 'json'
71
- | 'stream'
72
- | 'text';
61
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
73
62
  /**
74
63
  * Should we return only data or multiple fields (data, error, response, etc.)?
75
64
  *
@@ -99,7 +88,9 @@ export interface RequestOptions<
99
88
  TResponseStyle extends ResponseStyle = 'fields',
100
89
  ThrowOnError extends boolean = boolean,
101
90
  Url extends string = string,
102
- > extends Config<{
91
+ >
92
+ extends
93
+ Config<{
103
94
  responseStyle: TResponseStyle;
104
95
  throwOnError: ThrowOnError;
105
96
  }>,
@@ -146,32 +137,22 @@ export type RequestResult<
146
137
  ? TData[keyof TData]
147
138
  : TData
148
139
  : {
149
- data: TData extends Record<string, unknown>
150
- ? TData[keyof TData]
151
- : TData;
140
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
152
141
  request: Request;
153
142
  response: Response;
154
143
  }
155
144
  >
156
145
  : Promise<
157
146
  TResponseStyle extends 'data'
158
- ?
159
- | (TData extends Record<string, unknown>
160
- ? TData[keyof TData]
161
- : TData)
162
- | undefined
147
+ ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
163
148
  : (
164
149
  | {
165
- data: TData extends Record<string, unknown>
166
- ? TData[keyof TData]
167
- : TData;
150
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
168
151
  error: undefined;
169
152
  }
170
153
  | {
171
154
  data: undefined;
172
- error: TError extends Record<string, unknown>
173
- ? TError[keyof TError]
174
- : TError;
155
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
175
156
  }
176
157
  ) & {
177
158
  request: Request;
@@ -210,10 +191,7 @@ type RequestFn = <
210
191
  TResponseStyle extends ResponseStyle = 'fields',
211
192
  >(
212
193
  options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
213
- Pick<
214
- Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
215
- 'method'
216
- >,
194
+ Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>,
217
195
  ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
218
196
 
219
197
  type BuildUrlFn = <
@@ -227,13 +205,7 @@ type BuildUrlFn = <
227
205
  options: TData & Options<TData>,
228
206
  ) => string;
229
207
 
230
- export type Client = CoreClient<
231
- RequestFn,
232
- Config,
233
- MethodFn,
234
- BuildUrlFn,
235
- SseFn
236
- > & {
208
+ export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
237
209
  interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
238
210
  };
239
211
 
@@ -63,9 +63,7 @@ export const createQuerySerializer = <T = unknown>({
63
63
  /**
64
64
  * Infers parseAs value from provided Content-Type header.
65
65
  */
66
- export const getParseAs = (
67
- contentType: string | null,
68
- ): Exclude<Config['parseAs'], 'auto'> => {
66
+ export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => {
69
67
  if (!contentType) {
70
68
  return 'stream';
71
69
  }
@@ -76,10 +74,7 @@ export const getParseAs = (
76
74
  return;
77
75
  }
78
76
 
79
- if (
80
- cleanContent.startsWith('application/json') ||
81
- cleanContent.endsWith('+json')
82
- ) {
77
+ if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
83
78
  return 'json';
84
79
  }
85
80
 
@@ -88,9 +83,7 @@ export const getParseAs = (
88
83
  }
89
84
 
90
85
  if (
91
- ['application/', 'audio/', 'image/', 'video/'].some((type) =>
92
- cleanContent.startsWith(type),
93
- )
86
+ ['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))
94
87
  ) {
95
88
  return 'blob';
96
89
  }
@@ -197,10 +190,7 @@ export const mergeHeaders = (
197
190
  continue;
198
191
  }
199
192
 
200
- const iterator =
201
- header instanceof Headers
202
- ? headersEntries(header)
203
- : Object.entries(header);
193
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
204
194
 
205
195
  for (const [key, value] of iterator) {
206
196
  if (value === null) {
@@ -227,10 +217,7 @@ type ErrInterceptor<Err, Res, Req, Options> = (
227
217
  options: Options,
228
218
  ) => Err | Promise<Err>;
229
219
 
230
- type ReqInterceptor<Req, Options> = (
231
- request: Req,
232
- options: Options,
233
- ) => Req | Promise<Req>;
220
+ type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
234
221
 
235
222
  type ResInterceptor<Res, Req, Options> = (
236
223
  response: Res,
@@ -264,10 +251,7 @@ class Interceptors<Interceptor> {
264
251
  return this.fns.indexOf(id);
265
252
  }
266
253
 
267
- update(
268
- id: number | Interceptor,
269
- fn: Interceptor,
270
- ): number | Interceptor | false {
254
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false {
271
255
  const index = this.getInterceptorIndex(id);
272
256
  if (this.fns[index]) {
273
257
  this.fns[index] = fn;
@@ -1,12 +1,7 @@
1
1
  import { createSseClient } from '../core/serverSentEvents';
2
2
  import type { HttpMethod } from '../core/types';
3
3
  import { getValidRequestBody } from '../core/utils';
4
- import type {
5
- Client,
6
- Config,
7
- RequestOptions,
8
- ResolvedRequestOptions,
9
- } from './types';
4
+ import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types';
10
5
  import {
11
6
  buildUrl,
12
7
  createConfig,
@@ -32,11 +27,7 @@ export const createClient = (config: Config = {}): Client => {
32
27
  return getConfig();
33
28
  };
34
29
 
35
- const interceptors = createInterceptors<
36
- Response,
37
- unknown,
38
- ResolvedRequestOptions
39
- >();
30
+ const interceptors = createInterceptors<Response, unknown, ResolvedRequestOptions>();
40
31
 
41
32
  const beforeRequest = async (options: RequestOptions) => {
42
33
  const opts = {
@@ -109,10 +100,7 @@ export const createClient = (config: Config = {}): Client => {
109
100
  ? getParseAs(response.headers.get('Content-Type'))
110
101
  : opts.parseAs) ?? 'json';
111
102
 
112
- if (
113
- response.status === 204 ||
114
- response.headers.get('Content-Length') === '0'
115
- ) {
103
+ if (response.status === 204 || response.headers.get('Content-Length') === '0') {
116
104
  let emptyData: any;
117
105
  switch (parseAs) {
118
106
  case 'arrayBuffer':
@@ -205,40 +193,35 @@ export const createClient = (config: Config = {}): Client => {
205
193
  };
206
194
  };
207
195
 
208
- const makeMethodFn =
209
- (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
210
- request({ ...options, method });
196
+ const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
197
+ request({ ...options, method });
211
198
 
212
- const makeSseFn =
213
- (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
214
- const { opts, url } = await beforeRequest(options);
215
- return createSseClient({
216
- ...opts,
217
- body: opts.body as BodyInit | null | undefined,
218
- headers: opts.headers as unknown as Record<string, string>,
219
- method,
220
- onRequest: async (url, init) => {
221
- let request = new Request(url, init);
222
- const requestInit = {
223
- ...init,
224
- method: init.method as Config['method'],
225
- url,
226
- };
227
- for (const fn of interceptors.request.fns) {
228
- if (fn) {
229
- await fn(requestInit);
230
- request = new Request(requestInit.url, requestInit);
231
- }
199
+ const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
200
+ const { opts, url } = await beforeRequest(options);
201
+ return createSseClient({
202
+ ...opts,
203
+ body: opts.body as BodyInit | null | undefined,
204
+ headers: opts.headers as unknown as Record<string, string>,
205
+ method,
206
+ onRequest: async (url, init) => {
207
+ let request = new Request(url, init);
208
+ const requestInit = {
209
+ ...init,
210
+ method: init.method as Config['method'],
211
+ url,
212
+ };
213
+ for (const fn of interceptors.request.fns) {
214
+ if (fn) {
215
+ await fn(requestInit);
216
+ request = new Request(requestInit.url, requestInit);
232
217
  }
233
- return request;
234
- },
235
- serializedBody: getValidRequestBody(opts) as
236
- | BodyInit
237
- | null
238
- | undefined,
239
- url,
240
- });
241
- };
218
+ }
219
+ return request;
220
+ },
221
+ serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
222
+ url,
223
+ });
224
+ };
242
225
 
243
226
  return {
244
227
  buildUrl,
@@ -3,15 +3,11 @@ import type {
3
3
  ServerSentEventsOptions,
4
4
  ServerSentEventsResult,
5
5
  } from '../core/serverSentEvents';
6
- import type {
7
- Client as CoreClient,
8
- Config as CoreConfig,
9
- } from '../core/types';
6
+ import type { Client as CoreClient, Config as CoreConfig } from '../core/types';
10
7
  import type { Middleware } from './utils';
11
8
 
12
9
  export interface Config<T extends ClientOptions = ClientOptions>
13
- extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
14
- CoreConfig {
10
+ extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
15
11
  /**
16
12
  * Base URL for all requests made by this client.
17
13
  */
@@ -31,14 +27,7 @@ export interface Config<T extends ClientOptions = ClientOptions>
31
27
  *
32
28
  * @default 'auto'
33
29
  */
34
- parseAs?:
35
- | 'arrayBuffer'
36
- | 'auto'
37
- | 'blob'
38
- | 'formData'
39
- | 'json'
40
- | 'stream'
41
- | 'text';
30
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
42
31
  /**
43
32
  * Throw an error instead of returning it in the response?
44
33
  *
@@ -51,7 +40,9 @@ export interface RequestOptions<
51
40
  TData = unknown,
52
41
  ThrowOnError extends boolean = boolean,
53
42
  Url extends string = string,
54
- > extends Config<{
43
+ >
44
+ extends
45
+ Config<{
55
46
  throwOnError: ThrowOnError;
56
47
  }>,
57
48
  Pick<
@@ -96,16 +87,12 @@ export type RequestResult<
96
87
  : Promise<
97
88
  (
98
89
  | {
99
- data: TData extends Record<string, unknown>
100
- ? TData[keyof TData]
101
- : TData;
90
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
102
91
  error: undefined;
103
92
  }
104
93
  | {
105
94
  data: undefined;
106
- error: TError extends Record<string, unknown>
107
- ? TError[keyof TError]
108
- : TError;
95
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
109
96
  }
110
97
  ) & {
111
98
  response: Response;
@@ -117,27 +104,15 @@ export interface ClientOptions {
117
104
  throwOnError?: boolean;
118
105
  }
119
106
 
120
- type MethodFn = <
121
- TData = unknown,
122
- TError = unknown,
123
- ThrowOnError extends boolean = false,
124
- >(
107
+ type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(
125
108
  options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>,
126
109
  ) => RequestResult<TData, TError, ThrowOnError>;
127
110
 
128
- type SseFn = <
129
- TData = unknown,
130
- TError = unknown,
131
- ThrowOnError extends boolean = false,
132
- >(
111
+ type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(
133
112
  options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>,
134
113
  ) => Promise<ServerSentEventsResult<TData, TError>>;
135
114
 
136
- type RequestFn = <
137
- TData = unknown,
138
- TError = unknown,
139
- ThrowOnError extends boolean = false,
140
- >(
115
+ type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(
141
116
  options: Omit<RequestOptions<TData, ThrowOnError>, 'method'> &
142
117
  Pick<Required<RequestOptions<TData, ThrowOnError>>, 'method'>,
143
118
  ) => RequestResult<TData, TError, ThrowOnError>;
@@ -153,13 +128,7 @@ type BuildUrlFn = <
153
128
  options: TData & Options<TData>,
154
129
  ) => string;
155
130
 
156
- export type Client = CoreClient<
157
- RequestFn,
158
- Config,
159
- MethodFn,
160
- BuildUrlFn,
161
- SseFn
162
- > & {
131
+ export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
163
132
  interceptors: Middleware<Response, unknown, ResolvedRequestOptions>;
164
133
  };
165
134
 
@@ -189,8 +158,5 @@ export type Options<
189
158
  TData extends TDataShape = TDataShape,
190
159
  ThrowOnError extends boolean = boolean,
191
160
  TResponse = unknown,
192
- > = OmitKeys<
193
- RequestOptions<TResponse, ThrowOnError>,
194
- 'body' | 'path' | 'query' | 'url'
195
- > &
161
+ > = OmitKeys<RequestOptions<TResponse, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> &
196
162
  ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
@@ -51,10 +51,7 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
51
51
  }
52
52
 
53
53
  if (Array.isArray(value)) {
54
- url = url.replace(
55
- match,
56
- serializeArrayParam({ explode, name, style, value }),
57
- );
54
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
58
55
  continue;
59
56
  }
60
57
 
@@ -146,9 +143,7 @@ export const createQuerySerializer = <T = unknown>({
146
143
  /**
147
144
  * Infers parseAs value from provided Content-Type header.
148
145
  */
149
- export const getParseAs = (
150
- contentType: string | null,
151
- ): Exclude<Config['parseAs'], 'auto'> => {
146
+ export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => {
152
147
  if (!contentType) {
153
148
  // If no Content-Type header is provided, the best we can do is return the raw response body,
154
149
  // which is effectively the same as the 'stream' option.
@@ -161,10 +156,7 @@ export const getParseAs = (
161
156
  return;
162
157
  }
163
158
 
164
- if (
165
- cleanContent.startsWith('application/json') ||
166
- cleanContent.endsWith('+json')
167
- ) {
159
+ if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
168
160
  return 'json';
169
161
  }
170
162
 
@@ -173,9 +165,7 @@ export const getParseAs = (
173
165
  }
174
166
 
175
167
  if (
176
- ['application/', 'audio/', 'image/', 'video/'].some((type) =>
177
- cleanContent.startsWith(type),
178
- )
168
+ ['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))
179
169
  ) {
180
170
  return 'blob';
181
171
  }
@@ -311,10 +301,7 @@ export const mergeHeaders = (
311
301
  continue;
312
302
  }
313
303
 
314
- const iterator =
315
- header instanceof Headers
316
- ? headersEntries(header)
317
- : Object.entries(header);
304
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
318
305
 
319
306
  for (const [key, value] of iterator) {
320
307
  if (value === null) {
@@ -344,10 +331,7 @@ type ErrInterceptor<Err, Res, Options> = (
344
331
 
345
332
  type ReqInterceptor<Options> = (options: Options) => void | Promise<void>;
346
333
 
347
- type ResInterceptor<Res, Options> = (
348
- response: Res,
349
- options: Options,
350
- ) => Res | Promise<Res>;
334
+ type ResInterceptor<Res, Options> = (response: Res, options: Options) => Res | Promise<Res>;
351
335
 
352
336
  class Interceptors<Interceptor> {
353
337
  fns: Array<Interceptor | null> = [];
@@ -375,10 +359,7 @@ class Interceptors<Interceptor> {
375
359
  return this.fns.indexOf(id);
376
360
  }
377
361
 
378
- update(
379
- id: number | Interceptor,
380
- fn: Interceptor,
381
- ): number | Interceptor | false {
362
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false {
382
363
  const index = this.getInterceptorIndex(id);
383
364
  if (this.fns[index]) {
384
365
  this.fns[index] = fn;
@@ -399,11 +380,7 @@ export interface Middleware<Res, Err, Options> {
399
380
  response: Interceptors<ResInterceptor<Res, Options>>;
400
381
  }
401
382
 
402
- export const createInterceptors = <Res, Err, Options>(): Middleware<
403
- Res,
404
- Err,
405
- Options
406
- > => ({
383
+ export const createInterceptors = <Res, Err, Options>(): Middleware<Res, Err, Options> => ({
407
384
  error: new Interceptors<ErrInterceptor<Err, Res, Options>>(),
408
385
  request: new Interceptors<ReqInterceptor<Options>>(),
409
386
  response: new Interceptors<ResInterceptor<Res, Options>>(),
@@ -1,9 +1,4 @@
1
- import {
2
- useAsyncData,
3
- useFetch,
4
- useLazyAsyncData,
5
- useLazyFetch,
6
- } from 'nuxt/app';
1
+ import { useAsyncData, useFetch, useLazyAsyncData, useLazyFetch } from 'nuxt/app';
7
2
  import { reactive, ref, watch } from 'vue';
8
3
 
9
4
  import { createSseClient } from '../core/serverSentEvents';
@@ -58,11 +53,7 @@ export const createClient = (config: Config = {}): Client => {
58
53
  return { opts, url };
59
54
  };
60
55
 
61
- const request: Client['request'] = ({
62
- asyncDataOptions,
63
- composable = '$fetch',
64
- ...options
65
- }) => {
56
+ const request: Client['request'] = ({ asyncDataOptions, composable = '$fetch', ...options }) => {
66
57
  const key = options.key;
67
58
  const opts = {
68
59
  ..._config,
@@ -73,12 +64,7 @@ export const createClient = (config: Config = {}): Client => {
73
64
  onResponse: mergeInterceptors(_config.onResponse, options.onResponse),
74
65
  };
75
66
 
76
- const {
77
- requestValidator,
78
- responseTransformer,
79
- responseValidator,
80
- security,
81
- } = opts;
67
+ const { requestValidator, responseTransformer, responseValidator, security } = opts;
82
68
  if (requestValidator || security) {
83
69
  // auth must happen in interceptors otherwise we'd need to require
84
70
  // asyncContext enabled
@@ -182,26 +168,21 @@ export const createClient = (config: Config = {}): Client => {
182
168
  return undefined as any;
183
169
  };
184
170
 
185
- const makeMethodFn =
186
- (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
187
- request({ ...options, method });
188
-
189
- const makeSseFn =
190
- (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
191
- const { opts, url } = await beforeRequest(options);
192
- return createSseClient({
193
- ...unwrapRefs(opts),
194
- body: opts.body as BodyInit | null | undefined,
195
- method,
196
- onRequest: undefined,
197
- serializedBody: getValidRequestBody(opts) as
198
- | BodyInit
199
- | null
200
- | undefined,
201
- signal: unwrapRefs(opts.signal) as AbortSignal,
202
- url,
203
- });
204
- };
171
+ const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
172
+ request({ ...options, method });
173
+
174
+ const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
175
+ const { opts, url } = await beforeRequest(options);
176
+ return createSseClient({
177
+ ...unwrapRefs(opts),
178
+ body: opts.body as BodyInit | null | undefined,
179
+ method,
180
+ onRequest: undefined,
181
+ serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
182
+ signal: unwrapRefs(opts.signal) as AbortSignal,
183
+ url,
184
+ });
185
+ };
205
186
 
206
187
  return {
207
188
  buildUrl,