@ahoo-wang/fetcher-react 2.6.15 → 2.6.18
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 +15 -15
- package/README.zh-CN.md +11 -11
- package/dist/core/useLatest.d.ts +2 -1
- package/dist/core/useLatest.d.ts.map +1 -1
- package/dist/index.es.js +157 -2112
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/wow/index.d.ts +1 -0
- package/dist/wow/index.d.ts.map +1 -1
- package/dist/wow/useCountQuery.d.ts +23 -38
- package/dist/wow/useCountQuery.d.ts.map +1 -1
- package/dist/wow/useListQuery.d.ts +31 -57
- package/dist/wow/useListQuery.d.ts.map +1 -1
- package/dist/wow/useListStreamQuery.d.ts +31 -64
- package/dist/wow/useListStreamQuery.d.ts.map +1 -1
- package/dist/wow/usePagedQuery.d.ts +32 -57
- package/dist/wow/usePagedQuery.d.ts.map +1 -1
- package/dist/wow/useQuery.d.ts +80 -0
- package/dist/wow/useQuery.d.ts.map +1 -0
- package/dist/wow/useSingleQuery.d.ts +31 -52
- package/dist/wow/useSingleQuery.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/wow/useListQueryState.d.ts +0 -66
- package/dist/wow/useListQueryState.d.ts.map +0 -1
|
@@ -1,66 +1,45 @@
|
|
|
1
|
-
import { SingleQuery
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AutoExecuteCapable } from './types';
|
|
1
|
+
import { SingleQuery } from '@ahoo-wang/fetcher-wow';
|
|
2
|
+
import { FetcherError } from '@ahoo-wang/fetcher';
|
|
3
|
+
import { UseQueryOptions, UseQueryReturn } from './useQuery';
|
|
5
4
|
/**
|
|
6
5
|
* Options for the useSingleQuery hook.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @template
|
|
6
|
+
* Extends UseQueryOptions with SingleQuery as query key and custom result type.
|
|
7
|
+
*
|
|
8
|
+
* @template R - The result type of the query
|
|
9
|
+
* @template FIELDS - The fields type for the single query
|
|
10
|
+
* @template E - The error type, defaults to FetcherError
|
|
10
11
|
*/
|
|
11
|
-
export interface UseSingleQueryOptions<R, FIELDS extends string = string, E = FetcherError> extends
|
|
12
|
-
/**
|
|
13
|
-
* The initial single query configuration.
|
|
14
|
-
*/
|
|
15
|
-
initialQuery: SingleQuery<FIELDS>;
|
|
16
|
-
/**
|
|
17
|
-
* The function to execute the single query.
|
|
18
|
-
* @param singleQuery - The single query object.
|
|
19
|
-
* @param attributes - Optional additional attributes.
|
|
20
|
-
* @returns A promise that resolves to the result.
|
|
21
|
-
*/
|
|
22
|
-
query: (singleQuery: SingleQuery<FIELDS>, attributes?: Record<string, any>) => Promise<R>;
|
|
12
|
+
export interface UseSingleQueryOptions<R, FIELDS extends string = string, E = FetcherError> extends UseQueryOptions<SingleQuery<FIELDS>, R, E> {
|
|
23
13
|
}
|
|
24
14
|
/**
|
|
25
15
|
* Return type for the useSingleQuery hook.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @template
|
|
16
|
+
* Extends UseQueryReturn with SingleQuery as query key and custom result type.
|
|
17
|
+
*
|
|
18
|
+
* @template R - The result type of the query
|
|
19
|
+
* @template FIELDS - The fields type for the single query
|
|
20
|
+
* @template E - The error type, defaults to FetcherError
|
|
29
21
|
*/
|
|
30
|
-
export interface UseSingleQueryReturn<R, FIELDS extends string = string, E = FetcherError> extends
|
|
31
|
-
/**
|
|
32
|
-
* Executes the single query.
|
|
33
|
-
* @returns A promise that resolves to the result or an error.
|
|
34
|
-
*/
|
|
35
|
-
execute: () => Promise<E | R>;
|
|
36
|
-
/**
|
|
37
|
-
* Sets the condition for the query.
|
|
38
|
-
* @param condition - The new condition.
|
|
39
|
-
*/
|
|
40
|
-
setCondition: (condition: Condition<FIELDS>) => void;
|
|
41
|
-
/**
|
|
42
|
-
* Sets the projection for the query.
|
|
43
|
-
* @param projection - The new projection.
|
|
44
|
-
*/
|
|
45
|
-
setProjection: (projection: Projection<FIELDS>) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Sets the sort order for the query.
|
|
48
|
-
* @param sort - The new sort array.
|
|
49
|
-
*/
|
|
50
|
-
setSort: (sort: FieldSort<FIELDS>[]) => void;
|
|
22
|
+
export interface UseSingleQueryReturn<R, FIELDS extends string = string, E = FetcherError> extends UseQueryReturn<SingleQuery<FIELDS>, R, E> {
|
|
51
23
|
}
|
|
52
24
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @template
|
|
57
|
-
* @
|
|
58
|
-
* @
|
|
25
|
+
* Hook for querying a single item with conditions, projection, and sorting.
|
|
26
|
+
* Wraps useQuery to provide type-safe single item queries.
|
|
27
|
+
*
|
|
28
|
+
* @template R - The result type of the query
|
|
29
|
+
* @template FIELDS - The fields type for the single query
|
|
30
|
+
* @template E - The error type, defaults to FetcherError
|
|
31
|
+
* @param options - The query options including single query configuration
|
|
32
|
+
* @returns The query result with single item data
|
|
33
|
+
*
|
|
59
34
|
* @example
|
|
60
35
|
* ```typescript
|
|
61
|
-
* const { data,
|
|
62
|
-
* initialQuery: {
|
|
63
|
-
*
|
|
36
|
+
* const { data, isLoading } = useSingleQuery<{ id: number; name: string }, 'id' | 'name'>({
|
|
37
|
+
* initialQuery: {
|
|
38
|
+
* condition: all(),
|
|
39
|
+
* projection: { include: ['id', 'name'] },
|
|
40
|
+
* sort: [{ field: 'id', direction: SortDirection.ASC }],
|
|
41
|
+
* },
|
|
42
|
+
* execute: async (query) => fetchSingleItem(query),
|
|
64
43
|
* });
|
|
65
44
|
* ```
|
|
66
45
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSingleQuery.d.ts","sourceRoot":"","sources":["../../src/wow/useSingleQuery.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"useSingleQuery.d.ts","sourceRoot":"","sources":["../../src/wow/useSingleQuery.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAY,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB,CACpC,CAAC,EACD,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,CAAC,GAAG,YAAY,CAChB,SAAQ,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB,CACnC,CAAC,EACD,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,CAAC,GAAG,YAAY,CAChB,SAAQ,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EACD,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,CAAC,GAAG,YAAY,EAEhB,OAAO,EAAE,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,GAC3C,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAEpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/fetcher-react",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.18",
|
|
4
4
|
"description": "React integration for Fetcher HTTP client. Provides React Hooks and components for seamless data fetching with automatic re-rendering and loading states.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fetch",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"globals": "^16.4.0",
|
|
56
56
|
"prettier": "^3.6.2",
|
|
57
57
|
"typescript": "^5.9.3",
|
|
58
|
-
"typescript-eslint": "^8.
|
|
58
|
+
"typescript-eslint": "^8.46.0",
|
|
59
59
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
60
60
|
"unplugin-dts": "1.0.0-beta.6",
|
|
61
61
|
"vite": "^7.1.9",
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ListQuery, Condition, Projection, FieldSort } from '@ahoo-wang/fetcher-wow';
|
|
2
|
-
/**
|
|
3
|
-
* Options for the useListQueryState hook.
|
|
4
|
-
* @template FIELDS - The type of the fields used in conditions and projections.
|
|
5
|
-
*/
|
|
6
|
-
export interface UseListQueryStateOptions<FIELDS extends string = string> {
|
|
7
|
-
/**
|
|
8
|
-
* The initial list query configuration.
|
|
9
|
-
*/
|
|
10
|
-
initialQuery: ListQuery<FIELDS>;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Return type for the useListQueryState hook.
|
|
14
|
-
* @template FIELDS - The type of the fields used in conditions and projections.
|
|
15
|
-
*/
|
|
16
|
-
export interface UseListQueryStateReturn<FIELDS extends string = string> {
|
|
17
|
-
/**
|
|
18
|
-
* The current condition.
|
|
19
|
-
*/
|
|
20
|
-
condition: Condition<FIELDS>;
|
|
21
|
-
/**
|
|
22
|
-
* The current projection.
|
|
23
|
-
*/
|
|
24
|
-
projection?: Projection<FIELDS>;
|
|
25
|
-
/**
|
|
26
|
-
* The current sort order.
|
|
27
|
-
*/
|
|
28
|
-
sort?: FieldSort<FIELDS>[];
|
|
29
|
-
/**
|
|
30
|
-
* The current limit.
|
|
31
|
-
*/
|
|
32
|
-
limit?: number;
|
|
33
|
-
/**
|
|
34
|
-
* Sets the condition for the query.
|
|
35
|
-
* @param condition - The new condition.
|
|
36
|
-
*/
|
|
37
|
-
setCondition: (condition: Condition<FIELDS>) => void;
|
|
38
|
-
/**
|
|
39
|
-
* Sets the projection for the query.
|
|
40
|
-
* @param projection - The new projection.
|
|
41
|
-
*/
|
|
42
|
-
setProjection: (projection: Projection<FIELDS>) => void;
|
|
43
|
-
/**
|
|
44
|
-
* Sets the sort order for the query.
|
|
45
|
-
* @param sort - The new sort array.
|
|
46
|
-
*/
|
|
47
|
-
setSort: (sort: FieldSort<FIELDS>[]) => void;
|
|
48
|
-
/**
|
|
49
|
-
* Sets the limit for the query.
|
|
50
|
-
* @param limit - The new limit.
|
|
51
|
-
*/
|
|
52
|
-
setLimit: (limit: number) => void;
|
|
53
|
-
/**
|
|
54
|
-
* Builds the list query object from current state.
|
|
55
|
-
* @returns The list query object.
|
|
56
|
-
*/
|
|
57
|
-
buildQuery: () => ListQuery<FIELDS>;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A React hook for managing query state (condition, projection, sort, limit).
|
|
61
|
-
* @template FIELDS - The type of the fields used in conditions and projections.
|
|
62
|
-
* @param options - The options for the hook.
|
|
63
|
-
* @returns An object containing the query state and methods to update it.
|
|
64
|
-
*/
|
|
65
|
-
export declare function useListQueryState<FIELDS extends string = string>(options: UseListQueryStateOptions<FIELDS>): UseListQueryStateReturn<FIELDS>;
|
|
66
|
-
//# sourceMappingURL=useListQueryState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useListQueryState.d.ts","sourceRoot":"","sources":["../../src/wow/useListQueryState.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,SAAS,EACT,SAAS,EACT,KAAK,UAAU,EAEf,SAAS,EACV,MAAM,wBAAwB,CAAC;AAGhC;;;GAGG;AACH,MAAM,WAAW,wBAAwB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM;IACtE;;OAEG;IACH,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM;IACrE;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAChC;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACrD;;;OAGG;IACH,aAAa,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACxD;;;OAGG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,UAAU,EAAE,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9D,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,GACxC,uBAAuB,CAAC,MAAM,CAAC,CAwCjC"}
|