soda-tanstack-query 0.0.1 → 0.0.2
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, UndefinedInitialDataOptions, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import { StrictPartial } from "soda-type";
|
|
2
3
|
/** 判断函数的参数是否为必需的 */
|
|
3
4
|
export type IsParamRequired<TFn extends (params: any) => any> = Parameters<TFn> extends [param: any] ? true : false;
|
|
4
5
|
/** 参数必须的 useQuery */
|
|
@@ -30,13 +31,13 @@ export interface CreateUseQueryDefinedInitialDataParams<TFn extends (param: any)
|
|
|
30
31
|
}
|
|
31
32
|
/** 传递了初始化参数的参数必需的 useQuery */
|
|
32
33
|
interface _UseQueryDefinedInitialDataWithParams<TFn extends (params: any) => any, TParams = Parameters<TFn>[0], TResponse = Awaited<ReturnType<TFn>>> {
|
|
33
|
-
<TData = TResponse>(params: TParams, options?: Omit<DefinedInitialDataOptions<TResponse, Error, TData, [string, TParams]>, "queryKey" | "queryFn">, client?: QueryClient): DefinedUseQueryResult<NoInfer<TData>, Error>;
|
|
34
|
+
<TData = TResponse>(params: TParams, options?: StrictPartial<Omit<DefinedInitialDataOptions<TResponse, Error, TData, [string, TParams]>, "queryKey" | "queryFn">, "initialData">, client?: QueryClient): DefinedUseQueryResult<NoInfer<TData>, Error>;
|
|
34
35
|
}
|
|
35
36
|
export interface UseQueryDefinedInitialDataWithParams<TFn extends (params: any) => any> extends _UseQueryDefinedInitialDataWithParams<TFn> {
|
|
36
37
|
}
|
|
37
38
|
/** 传递了初始化参数的参数可选的 useQuery */
|
|
38
39
|
interface _UseQueryDefinedInitialDataWithOptionalParams<TFn extends (params?: any) => any, TParams = Parameters<TFn>[0], TResponse = Awaited<ReturnType<TFn>>> {
|
|
39
|
-
<TData = TResponse>(params?: TParams, options?: Omit<DefinedInitialDataOptions<TResponse, Error, TData, [string, TParams]>, "queryKey" | "queryFn">, client?: QueryClient): DefinedUseQueryResult<NoInfer<TData>, Error>;
|
|
40
|
+
<TData = TResponse>(params?: TParams, options?: StrictPartial<Omit<DefinedInitialDataOptions<TResponse, Error, TData, [string, TParams]>, "queryKey" | "queryFn">, "initialData">, client?: QueryClient): DefinedUseQueryResult<NoInfer<TData>, Error>;
|
|
40
41
|
}
|
|
41
42
|
export interface UseQueryDefinedInitialDataWithOptionalParams<TFn extends (params?: any) => any> extends _UseQueryDefinedInitialDataWithOptionalParams<TFn> {
|
|
42
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soda-tanstack-query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"@tanstack/react-query": "^5.90.19"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"typescript": ">=5.8.3"
|
|
41
|
+
"typescript": ">=5.8.3",
|
|
42
|
+
"soda-type": ""
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@types/react": ">=19.2.7",
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
UseQueryOptions,
|
|
8
8
|
UseQueryResult,
|
|
9
9
|
} from "@tanstack/react-query"
|
|
10
|
+
import { StrictPartial } from "soda-type"
|
|
10
11
|
|
|
11
12
|
/** 判断函数的参数是否为必需的 */
|
|
12
13
|
export type IsParamRequired<TFn extends (params: any) => any> = Parameters<TFn> extends [param: any] ? true : false
|
|
@@ -76,7 +77,7 @@ export interface CreateUseQueryDefinedInitialDataParams<TFn extends (param: any)
|
|
|
76
77
|
interface _UseQueryDefinedInitialDataWithParams<TFn extends (params: any) => any, TParams = Parameters<TFn>[0], TResponse = Awaited<ReturnType<TFn>>> {
|
|
77
78
|
<TData = TResponse>(
|
|
78
79
|
params: TParams,
|
|
79
|
-
options?: Omit<DefinedInitialDataOptions<TResponse, Error, TData, [string, TParams]>, "queryKey" | "queryFn">,
|
|
80
|
+
options?: StrictPartial<Omit<DefinedInitialDataOptions<TResponse, Error, TData, [string, TParams]>, "queryKey" | "queryFn">, "initialData">,
|
|
80
81
|
client?: QueryClient,
|
|
81
82
|
): DefinedUseQueryResult<NoInfer<TData>, Error>
|
|
82
83
|
}
|
|
@@ -87,7 +88,7 @@ export interface UseQueryDefinedInitialDataWithParams<TFn extends (params: any)
|
|
|
87
88
|
interface _UseQueryDefinedInitialDataWithOptionalParams<TFn extends (params?: any) => any, TParams = Parameters<TFn>[0], TResponse = Awaited<ReturnType<TFn>>> {
|
|
88
89
|
<TData = TResponse>(
|
|
89
90
|
params?: TParams,
|
|
90
|
-
options?: Omit<DefinedInitialDataOptions<TResponse, Error, TData, [string, TParams]>, "queryKey" | "queryFn">,
|
|
91
|
+
options?: StrictPartial<Omit<DefinedInitialDataOptions<TResponse, Error, TData, [string, TParams]>, "queryKey" | "queryFn">, "initialData">,
|
|
91
92
|
client?: QueryClient,
|
|
92
93
|
): DefinedUseQueryResult<NoInfer<TData>, Error>
|
|
93
94
|
}
|