@hey-api/openapi-ts 0.92.3 → 0.93.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.
@@ -53,10 +53,11 @@ export const createClient = (config: Config = {}): Client => {
53
53
  >();
54
54
 
55
55
  const requestOptions = <
56
+ TData = unknown,
56
57
  ThrowOnError extends boolean = false,
57
58
  TResponseStyle extends ResponseStyle = 'fields',
58
59
  >(
59
- options: RequestOptions<unknown, TResponseStyle, ThrowOnError>,
60
+ options: RequestOptions<TData, TResponseStyle, ThrowOnError>,
60
61
  ) => {
61
62
  const opts = {
62
63
  ..._config,
@@ -67,6 +67,7 @@ export interface RequestOptions<
67
67
  }>,
68
68
  Pick<
69
69
  ServerSentEventsOptions<TData>,
70
+ | 'onRequest'
70
71
  | 'onSseError'
71
72
  | 'onSseEvent'
72
73
  | 'sseDefaultRetryDelay'
@@ -170,11 +171,12 @@ type RequestFn = <
170
171
  ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
171
172
 
172
173
  type RequestOptionsFn = <
174
+ T,
173
175
  ThrowOnError extends boolean = false,
174
176
  TResponseStyle extends ResponseStyle = 'fields',
175
177
  >(
176
- options: RequestOptions<unknown, TResponseStyle, ThrowOnError>,
177
- ) => HttpRequest<unknown>;
178
+ options: RequestOptions<T, TResponseStyle, ThrowOnError>,
179
+ ) => HttpRequest<T>;
178
180
 
179
181
  type BuildUrlFn = <
180
182
  TData extends {
@@ -58,6 +58,7 @@ export interface RequestOptions<
58
58
  }>,
59
59
  Pick<
60
60
  ServerSentEventsOptions<TData>,
61
+ | 'onRequest'
61
62
  | 'onSseError'
62
63
  | 'onSseEvent'
63
64
  | 'sseDefaultRetryDelay'
@@ -64,6 +64,7 @@ export interface RequestOptions<
64
64
  }>,
65
65
  Pick<
66
66
  ServerSentEventsOptions<TData>,
67
+ | 'onRequest'
67
68
  | 'onSseError'
68
69
  | 'onSseEvent'
69
70
  | 'sseDefaultRetryDelay'
@@ -96,6 +96,7 @@ export interface RequestOptions<
96
96
  }>,
97
97
  Pick<
98
98
  ServerSentEventsOptions<TData>,
99
+ | 'onRequest'
99
100
  | 'onSseError'
100
101
  | 'onSseEvent'
101
102
  | 'sseDefaultRetryDelay'
@@ -47,6 +47,7 @@ export interface RequestOptions<
47
47
  }>,
48
48
  Pick<
49
49
  ServerSentEventsOptions<TData>,
50
+ | 'onRequest'
50
51
  | 'onSseError'
51
52
  | 'onSseEvent'
52
53
  | 'sseDefaultRetryDelay'
@@ -1,5 +1,5 @@
1
1
  import { useAsyncData, useFetch, useLazyAsyncData, useLazyFetch } from 'nuxt/app';
2
- import { reactive, ref, watch } from 'vue';
2
+ import { reactive, ref, toValue, watch } from 'vue';
3
3
 
4
4
  import { createSseClient } from '../core/serverSentEvents';
5
5
  import type { HttpMethod } from '../core/types';
@@ -136,14 +136,14 @@ export const createClient = (config: Config = {}): Client => {
136
136
  body: opts.body,
137
137
  bodySerializer: opts.bodySerializer,
138
138
  });
139
- const body = ref(serializeBody(opts));
139
+ const body = ref(serializeBody({ ...opts, body: toValue(opts.body) }));
140
140
  opts.body = body;
141
141
  watch(bodyParams, (changed) => {
142
142
  body.value = serializeBody(changed);
143
143
  });
144
144
  return composable === 'useLazyFetch'
145
- ? useLazyFetch(() => buildUrl(opts), opts)
146
- : useFetch(() => buildUrl(opts), opts);
145
+ ? useLazyFetch(() => buildUrl(opts), { ...opts, ...asyncDataOptions })
146
+ : useFetch(() => buildUrl(opts), { ...opts, ...asyncDataOptions });
147
147
  }
148
148
 
149
149
  const handler: any = () =>