nuxt-openapi-hyperfetch 0.1.5-alpha.1 → 0.1.6-alpha.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/dist/generators/use-async-data/runtime/useApiAsyncData.d.ts +9 -22
- package/dist/generators/use-async-data/runtime/useApiAsyncDataRaw.d.ts +7 -20
- package/dist/generators/use-fetch/runtime/useApiRequest.d.ts +5 -6
- package/package.json +1 -1
- package/src/generators/use-async-data/runtime/useApiAsyncData.ts +13 -29
- package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +14 -30
- package/src/generators/use-fetch/runtime/useApiRequest.ts +5 -6
|
@@ -1,31 +1,18 @@
|
|
|
1
|
+
import type { UseFetchOptions } from '#app';
|
|
1
2
|
import { type ApiRequestOptions as BaseApiRequestOptions } from '../../shared/runtime/apiHelpers.js';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Options for useAsyncData API requests with lifecycle callbacks.
|
|
5
|
+
* Extends all native Nuxt useFetch options plus our custom callbacks, transform, and pick.
|
|
6
|
+
* Native options like baseURL, method, body, headers, query, lazy, server, immediate, dedupe, etc. are all available.
|
|
7
|
+
* watch: boolean (true = auto-watch reactive params, false = disable auto-refresh)
|
|
4
8
|
*/
|
|
5
|
-
export
|
|
9
|
+
export type ApiAsyncDataOptions<T> = BaseApiRequestOptions<T> & Omit<UseFetchOptions<T>, 'transform' | 'pick' | 'watch'> & {
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
immediate?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Lazy mode: don't block navigation (default: false)
|
|
12
|
-
*/
|
|
13
|
-
lazy?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Server-side rendering mode (default: true)
|
|
16
|
-
*/
|
|
17
|
-
server?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Deduplicate requests with the same key (default: 'cancel')
|
|
20
|
-
*/
|
|
21
|
-
dedupe?: 'cancel' | 'defer';
|
|
22
|
-
/**
|
|
23
|
-
* Disable automatic refresh when reactive params change.
|
|
24
|
-
* Set to false to prevent re-fetching when params/url refs update.
|
|
25
|
-
* @default true
|
|
11
|
+
* Enable automatic refresh when reactive params/url change (default: true).
|
|
12
|
+
* Set to false to disable auto-refresh entirely.
|
|
26
13
|
*/
|
|
27
14
|
watch?: boolean;
|
|
28
|
-
}
|
|
15
|
+
};
|
|
29
16
|
/**
|
|
30
17
|
* Generic wrapper for API calls using Nuxt's useAsyncData
|
|
31
18
|
* Supports:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UseFetchOptions } from '#app';
|
|
1
2
|
import { type ApiRequestOptions as BaseApiRequestOptions } from '../../shared/runtime/apiHelpers.js';
|
|
2
3
|
/**
|
|
3
4
|
* Response structure for Raw version
|
|
@@ -10,11 +11,13 @@ export interface RawResponse<T> {
|
|
|
10
11
|
statusText: string;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
+
* Options for useAsyncData Raw API requests.
|
|
15
|
+
* Extends all native Nuxt useFetch options plus our custom callbacks, transform, and pick.
|
|
16
|
+
* onSuccess receives data AND the full response (headers, status, statusText).
|
|
14
17
|
*/
|
|
15
|
-
export
|
|
18
|
+
export type ApiAsyncDataRawOptions<T> = Omit<BaseApiRequestOptions<T>, 'onSuccess'> & Omit<UseFetchOptions<T>, 'transform' | 'pick' | 'onSuccess'> & {
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* Called when the request succeeds — receives both data and the full response object.
|
|
18
21
|
*/
|
|
19
22
|
onSuccess?: (data: T, response: {
|
|
20
23
|
headers: Headers;
|
|
@@ -22,23 +25,7 @@ export interface ApiAsyncDataRawOptions<T> extends Omit<BaseApiRequestOptions<T>
|
|
|
22
25
|
statusText: string;
|
|
23
26
|
url: string;
|
|
24
27
|
}) => void | Promise<void>;
|
|
25
|
-
|
|
26
|
-
* Whether to fetch data immediately on mount (default: true)
|
|
27
|
-
*/
|
|
28
|
-
immediate?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Lazy mode: don't block navigation (default: false)
|
|
31
|
-
*/
|
|
32
|
-
lazy?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Server-side rendering mode (default: true)
|
|
35
|
-
*/
|
|
36
|
-
server?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Deduplicate requests with the same key (default: 'cancel')
|
|
39
|
-
*/
|
|
40
|
-
dedupe?: 'cancel' | 'defer';
|
|
41
|
-
}
|
|
28
|
+
};
|
|
42
29
|
/**
|
|
43
30
|
* Generic wrapper for API calls using Nuxt's useAsyncData - RAW VERSION
|
|
44
31
|
* Returns full response with headers and status information
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import type { UseFetchOptions } from '#app';
|
|
1
2
|
import { type ApiRequestOptions as BaseApiRequestOptions } from '../../shared/runtime/apiHelpers.js';
|
|
2
3
|
/**
|
|
3
|
-
* Options for useFetch API requests with lifecycle callbacks
|
|
4
|
-
* Extends
|
|
4
|
+
* Options for useFetch API requests with lifecycle callbacks.
|
|
5
|
+
* Extends all native Nuxt useFetch options plus our custom callbacks, transform, and pick.
|
|
6
|
+
* Native options like baseURL, method, body, headers, query, lazy, server, immediate, etc. are all available.
|
|
5
7
|
*/
|
|
6
|
-
export
|
|
7
|
-
/** All standard useFetch options */
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}
|
|
8
|
+
export type ApiRequestOptions<T = any> = BaseApiRequestOptions<T> & Omit<UseFetchOptions<T>, 'transform' | 'pick'>;
|
|
10
9
|
/**
|
|
11
10
|
* Enhanced useFetch wrapper with lifecycle callbacks and request interception
|
|
12
11
|
*
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* It requires Nuxt 3 to be installed in the target project
|
|
5
5
|
*/
|
|
6
6
|
import { watch } from 'vue';
|
|
7
|
+
import type { UseFetchOptions } from '#app';
|
|
7
8
|
import {
|
|
8
9
|
getGlobalHeaders,
|
|
9
10
|
getGlobalBaseUrl,
|
|
@@ -29,36 +30,19 @@ type MaybeTransformed<T, Options> = Options extends { transform: (...args: any)
|
|
|
29
30
|
: T;
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
+
* Options for useAsyncData API requests with lifecycle callbacks.
|
|
34
|
+
* Extends all native Nuxt useFetch options plus our custom callbacks, transform, and pick.
|
|
35
|
+
* Native options like baseURL, method, body, headers, query, lazy, server, immediate, dedupe, etc. are all available.
|
|
36
|
+
* watch: boolean (true = auto-watch reactive params, false = disable auto-refresh)
|
|
33
37
|
*/
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*/
|
|
43
|
-
lazy?: boolean;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Server-side rendering mode (default: true)
|
|
47
|
-
*/
|
|
48
|
-
server?: boolean;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Deduplicate requests with the same key (default: 'cancel')
|
|
52
|
-
*/
|
|
53
|
-
dedupe?: 'cancel' | 'defer';
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Disable automatic refresh when reactive params change.
|
|
57
|
-
* Set to false to prevent re-fetching when params/url refs update.
|
|
58
|
-
* @default true
|
|
59
|
-
*/
|
|
60
|
-
watch?: boolean;
|
|
61
|
-
}
|
|
38
|
+
export type ApiAsyncDataOptions<T> = BaseApiRequestOptions<T> &
|
|
39
|
+
Omit<UseFetchOptions<T>, 'transform' | 'pick' | 'watch'> & {
|
|
40
|
+
/**
|
|
41
|
+
* Enable automatic refresh when reactive params/url change (default: true).
|
|
42
|
+
* Set to false to disable auto-refresh entirely.
|
|
43
|
+
*/
|
|
44
|
+
watch?: boolean;
|
|
45
|
+
};
|
|
62
46
|
|
|
63
47
|
/**
|
|
64
48
|
* Generic wrapper for API calls using Nuxt's useAsyncData
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* RAW VERSION: Returns full response including headers, status, and statusText
|
|
7
7
|
*/
|
|
8
8
|
import { watch } from 'vue';
|
|
9
|
+
import type { UseFetchOptions } from '#app';
|
|
9
10
|
import {
|
|
10
11
|
getGlobalHeaders,
|
|
11
12
|
getGlobalBaseUrl,
|
|
@@ -40,37 +41,20 @@ type MaybeTransformedRaw<T, Options> = Options extends { transform: (...args: an
|
|
|
40
41
|
: RawResponse<T>;
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
|
-
*
|
|
44
|
+
* Options for useAsyncData Raw API requests.
|
|
45
|
+
* Extends all native Nuxt useFetch options plus our custom callbacks, transform, and pick.
|
|
46
|
+
* onSuccess receives data AND the full response (headers, status, statusText).
|
|
44
47
|
*/
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* Whether to fetch data immediately on mount (default: true)
|
|
56
|
-
*/
|
|
57
|
-
immediate?: boolean;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Lazy mode: don't block navigation (default: false)
|
|
61
|
-
*/
|
|
62
|
-
lazy?: boolean;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Server-side rendering mode (default: true)
|
|
66
|
-
*/
|
|
67
|
-
server?: boolean;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Deduplicate requests with the same key (default: 'cancel')
|
|
71
|
-
*/
|
|
72
|
-
dedupe?: 'cancel' | 'defer';
|
|
73
|
-
}
|
|
48
|
+
export type ApiAsyncDataRawOptions<T> = Omit<BaseApiRequestOptions<T>, 'onSuccess'> &
|
|
49
|
+
Omit<UseFetchOptions<T>, 'transform' | 'pick' | 'onSuccess'> & {
|
|
50
|
+
/**
|
|
51
|
+
* Called when the request succeeds — receives both data and the full response object.
|
|
52
|
+
*/
|
|
53
|
+
onSuccess?: (
|
|
54
|
+
data: T,
|
|
55
|
+
response: { headers: Headers; status: number; statusText: string; url: string }
|
|
56
|
+
) => void | Promise<void>;
|
|
57
|
+
};
|
|
74
58
|
|
|
75
59
|
/**
|
|
76
60
|
* Generic wrapper for API calls using Nuxt's useAsyncData - RAW VERSION
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* It requires Nuxt 3 to be installed in the target project
|
|
5
5
|
*/
|
|
6
6
|
import { watch } from 'vue';
|
|
7
|
+
import type { UseFetchOptions } from '#app';
|
|
7
8
|
import {
|
|
8
9
|
getGlobalHeaders,
|
|
9
10
|
getGlobalBaseUrl,
|
|
@@ -29,13 +30,11 @@ type MaybeTransformed<T, Options> = Options extends { transform: (...args: any)
|
|
|
29
30
|
: T;
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
* Options for useFetch API requests with lifecycle callbacks
|
|
33
|
-
* Extends
|
|
33
|
+
* Options for useFetch API requests with lifecycle callbacks.
|
|
34
|
+
* Extends all native Nuxt useFetch options plus our custom callbacks, transform, and pick.
|
|
35
|
+
* Native options like baseURL, method, body, headers, query, lazy, server, immediate, etc. are all available.
|
|
34
36
|
*/
|
|
35
|
-
export
|
|
36
|
-
/** All standard useFetch options */
|
|
37
|
-
[key: string]: any;
|
|
38
|
-
}
|
|
37
|
+
export type ApiRequestOptions<T = any> = BaseApiRequestOptions<T> & Omit<UseFetchOptions<T>, 'transform' | 'pick'>;
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
40
|
* Enhanced useFetch wrapper with lifecycle callbacks and request interception
|