@refinedev/core 5.0.1 → 5.0.3
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/CHANGELOG.md +68 -0
- package/dist/contexts/refine/types.d.cts +0 -3
- package/dist/contexts/refine/types.d.cts.map +1 -1
- package/dist/contexts/refine/types.d.mts +0 -3
- package/dist/contexts/refine/types.d.mts.map +0 -3
- package/dist/contexts/refine/types.d.ts +0 -3
- package/dist/contexts/refine/types.d.ts.map +1 -1
- package/dist/contexts/router/types.d.cts +1 -1
- package/dist/contexts/router/types.d.cts.map +1 -1
- package/dist/contexts/router/types.d.mts +1 -1
- package/dist/contexts/router/types.d.mts.map +1 -1
- package/dist/contexts/router/types.d.ts +1 -1
- package/dist/contexts/router/types.d.ts.map +1 -1
- package/dist/definitions/table/index.d.cts +2 -2
- package/dist/definitions/table/index.d.mts +2 -2
- package/dist/definitions/table/index.d.mts.map +2 -2
- package/dist/definitions/table/index.d.ts +2 -2
- package/dist/hooks/accessControl/useCan/index.d.cts +1 -1
- package/dist/hooks/accessControl/useCan/index.d.mts +1 -1
- package/dist/hooks/accessControl/useCan/index.d.mts.map +1 -1
- package/dist/hooks/accessControl/useCan/index.d.ts +1 -1
- package/dist/hooks/data/useCreate.d.cts +1 -1
- package/dist/hooks/data/useCreate.d.mts +1 -1
- package/dist/hooks/data/useCreate.d.mts.map +1 -1
- package/dist/hooks/data/useCreate.d.ts +1 -1
- package/dist/hooks/data/useCreateMany.d.cts +1 -1
- package/dist/hooks/data/useCreateMany.d.mts +1 -1
- package/dist/hooks/data/useCreateMany.d.mts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.ts +1 -1
- package/dist/hooks/data/useCustom.d.cts +2 -2
- package/dist/hooks/data/useCustom.d.cts.map +1 -1
- package/dist/hooks/data/useCustom.d.mts +2 -2
- package/dist/hooks/data/useCustom.d.mts.map +2 -2
- package/dist/hooks/data/useCustom.d.ts +2 -2
- package/dist/hooks/data/useCustom.d.ts.map +1 -1
- package/dist/hooks/data/useCustomMutation.d.cts +1 -1
- package/dist/hooks/data/useCustomMutation.d.mts +1 -1
- package/dist/hooks/data/useCustomMutation.d.mts.map +1 -1
- package/dist/hooks/data/useCustomMutation.d.ts +1 -1
- package/dist/hooks/data/useDelete.d.cts +1 -1
- package/dist/hooks/data/useDelete.d.mts +1 -1
- package/dist/hooks/data/useDelete.d.mts.map +1 -1
- package/dist/hooks/data/useDelete.d.ts +1 -1
- package/dist/hooks/data/useDeleteMany.d.cts +1 -1
- package/dist/hooks/data/useDeleteMany.d.mts +1 -1
- package/dist/hooks/data/useDeleteMany.d.mts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts +1 -1
- package/dist/hooks/data/useInfiniteList.d.cts +1 -1
- package/dist/hooks/data/useInfiniteList.d.mts +1 -1
- package/dist/hooks/data/useInfiniteList.d.mts.map +1 -1
- package/dist/hooks/data/useInfiniteList.d.ts +1 -1
- package/dist/hooks/data/useList.d.cts +2 -2
- package/dist/hooks/data/useList.d.cts.map +1 -1
- package/dist/hooks/data/useList.d.mts +2 -2
- package/dist/hooks/data/useList.d.mts.map +2 -2
- package/dist/hooks/data/useList.d.ts +2 -2
- package/dist/hooks/data/useList.d.ts.map +1 -1
- package/dist/hooks/data/useMany.d.cts +2 -2
- package/dist/hooks/data/useMany.d.cts.map +1 -1
- package/dist/hooks/data/useMany.d.mts +2 -2
- package/dist/hooks/data/useMany.d.mts.map +2 -2
- package/dist/hooks/data/useMany.d.ts +2 -2
- package/dist/hooks/data/useMany.d.ts.map +1 -1
- package/dist/hooks/data/useOne.d.cts +2 -2
- package/dist/hooks/data/useOne.d.mts +2 -2
- package/dist/hooks/data/useOne.d.mts.map +2 -2
- package/dist/hooks/data/useOne.d.ts +2 -2
- package/dist/hooks/data/useUpdate.d.cts +1 -1
- package/dist/hooks/data/useUpdate.d.mts +1 -1
- package/dist/hooks/data/useUpdate.d.mts.map +1 -1
- package/dist/hooks/data/useUpdate.d.ts +1 -1
- package/dist/hooks/data/useUpdateMany.d.cts +1 -1
- package/dist/hooks/data/useUpdateMany.d.mts +1 -1
- package/dist/hooks/data/useUpdateMany.d.mts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts +1 -1
- package/dist/hooks/form/types.d.cts +3 -3
- package/dist/hooks/form/types.d.mts +3 -3
- package/dist/hooks/form/types.d.mts.map +3 -3
- package/dist/hooks/form/types.d.ts +3 -3
- package/dist/hooks/show/types.d.cts +1 -1
- package/dist/hooks/show/types.d.mts +1 -1
- package/dist/hooks/show/types.d.mts.map +1 -1
- package/dist/hooks/show/types.d.ts +1 -1
- package/dist/hooks/useTable/index.d.cts +1 -1
- package/dist/hooks/useTable/index.d.cts.map +1 -1
- package/dist/hooks/useTable/index.d.mts +1 -1
- package/dist/hooks/useTable/index.d.mts.map +1 -1
- package/dist/hooks/useTable/index.d.ts +1 -1
- package/dist/hooks/useTable/index.d.ts.map +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -8
- package/src/contexts/refine/types.ts +0 -3
- package/src/contexts/router/types.ts +1 -1
- package/src/definitions/table/__snapshots__/index.spec.ts.snap +4 -4
- package/src/definitions/table/index.ts +2 -2
- package/src/hooks/accessControl/useCan/index.ts +1 -1
- package/src/hooks/data/useCreate.ts +1 -1
- package/src/hooks/data/useCreateMany.ts +1 -1
- package/src/hooks/data/useCustom.ts +5 -3
- package/src/hooks/data/useCustomMutation.ts +1 -1
- package/src/hooks/data/useDelete.ts +1 -1
- package/src/hooks/data/useDeleteMany.ts +1 -1
- package/src/hooks/data/useInfiniteList.ts +1 -1
- package/src/hooks/data/useList.ts +5 -3
- package/src/hooks/data/useMany.ts +5 -3
- package/src/hooks/data/useOne.ts +2 -2
- package/src/hooks/data/useUpdate.ts +1 -1
- package/src/hooks/data/useUpdateMany.ts +1 -1
- package/src/hooks/form/types.ts +3 -3
- package/src/hooks/show/types.ts +1 -1
- package/src/hooks/useTable/index.ts +6 -5
- package/vitest.config.mts +43 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refinedev/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Refine is a React meta-framework for building enterprise-level, data-intensive applications rapidly with support for modern UI libraries and headless integrations.",
|
|
6
6
|
"repository": {
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@testing-library/react": "^16.3.0",
|
|
45
45
|
"@testing-library/react-hooks": "^8.0.1",
|
|
46
46
|
"@testing-library/user-event": "^14.6.1",
|
|
47
|
-
"@types/jest": "^29.2.4",
|
|
48
47
|
"@types/lodash": "^4.14.171",
|
|
49
48
|
"@types/node": "^20",
|
|
50
49
|
"@types/papaparse": "^5.2.5",
|
|
@@ -53,13 +52,12 @@
|
|
|
53
52
|
"@types/react": "^19.1.0",
|
|
54
53
|
"@types/react-dom": "^19.1.0",
|
|
55
54
|
"@types/react-router-dom": "^5.1.8",
|
|
55
|
+
"@vitest/ui": "^2.1.8",
|
|
56
56
|
"graphql": "^15.6.1",
|
|
57
57
|
"identity-obj-proxy": "^3.0.0",
|
|
58
|
-
"jest": "^30.0.5",
|
|
59
|
-
"jest-environment-jsdom": "^30.0.5",
|
|
60
|
-
"ts-jest": "^29.1.2",
|
|
61
58
|
"tsup": "^6.7.0",
|
|
62
|
-
"typescript": "^5.8.3"
|
|
59
|
+
"typescript": "^5.8.3",
|
|
60
|
+
"vitest": "^2.1.8"
|
|
63
61
|
},
|
|
64
62
|
"peerDependencies": {
|
|
65
63
|
"@tanstack/react-query": "^5.81.5",
|
|
@@ -79,8 +77,9 @@
|
|
|
79
77
|
"build": "tsup && node ../shared/generate-declarations.js",
|
|
80
78
|
"dev": "tsup --watch",
|
|
81
79
|
"publint": "publint --strict=true --level=suggestion",
|
|
82
|
-
"test": "
|
|
83
|
-
"test:
|
|
80
|
+
"test": "vitest run",
|
|
81
|
+
"test:ui": "vitest --ui",
|
|
82
|
+
"test:watch": "vitest",
|
|
84
83
|
"types": "node ../shared/generate-declarations.js"
|
|
85
84
|
}
|
|
86
85
|
}
|
|
@@ -128,9 +128,6 @@ export interface IRefineContextOptions {
|
|
|
128
128
|
export interface IRefineContext {
|
|
129
129
|
__initialized?: boolean;
|
|
130
130
|
mutationMode: MutationMode;
|
|
131
|
-
/**
|
|
132
|
-
* @deprecated Please use `UnsavedChangesNotifier` components from router packages instead.
|
|
133
|
-
*/
|
|
134
131
|
warnWhenUnsavedChanges: boolean;
|
|
135
132
|
syncWithLocation: boolean;
|
|
136
133
|
undoableTimeout: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`definitions/table sorters should be prioritized over sorter 1`] = `"currentPage=1&pageSize=10&sorters[0][field]=id&sorters[0][order]=desc"`;
|
|
3
|
+
exports[`definitions/table > sorters should be prioritized over sorter 1`] = `"currentPage=1&pageSize=10&sorters[0][field]=id&sorters[0][order]=desc"`;
|
|
4
4
|
|
|
5
|
-
exports[`definitions/table stringify table params correctly 1`] = `"foo=bar¤tPage=1&pageSize=10&sorters[0][field]=id&sorters[0][order]=desc&sorters[1][field]=title&sorters[1][order]=desc&filters[0][field]=categoryId&filters[0][operator]=in&filters[0][value][0]=1&filters[0][value][1]=2"`;
|
|
5
|
+
exports[`definitions/table > stringify table params correctly 1`] = `"foo=bar¤tPage=1&pageSize=10&sorters[0][field]=id&sorters[0][order]=desc&sorters[1][field]=title&sorters[1][order]=desc&filters[0][field]=categoryId&filters[0][operator]=in&filters[0][value][0]=1&filters[0][value][1]=2"`;
|
|
6
6
|
|
|
7
|
-
exports[`definitions/table stringify table single sort params correctly 1`] = `"currentPage=1&pageSize=10&sorters[0][field]=id&sorters[0][order]=desc&filters[0][field]=categoryId&filters[0][operator]=in&filters[0][value][0]=1&filters[0][value][1]=2"`;
|
|
7
|
+
exports[`definitions/table > stringify table single sort params correctly 1`] = `"currentPage=1&pageSize=10&sorters[0][field]=id&sorters[0][order]=desc&filters[0][field]=categoryId&filters[0][operator]=in&filters[0][value][0]=1&filters[0][value][1]=2"`;
|
|
@@ -16,7 +16,7 @@ export const parseTableParams = (url: string) => {
|
|
|
16
16
|
);
|
|
17
17
|
|
|
18
18
|
return {
|
|
19
|
-
|
|
19
|
+
parsedCurrentPage: currentPage && Number(currentPage),
|
|
20
20
|
parsedPageSize: pageSize && Number(pageSize),
|
|
21
21
|
parsedSorter: (sorters as CrudSort[]) || (sorter as CrudSort[]) || [],
|
|
22
22
|
parsedFilters: (filters as CrudFilter[]) ?? [],
|
|
@@ -27,7 +27,7 @@ export const parseTableParamsFromQuery = (params: any) => {
|
|
|
27
27
|
const { currentPage, pageSize, sorters, sorter, filters } = params;
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
|
-
|
|
30
|
+
parsedCurrentPage: currentPage && Number(currentPage),
|
|
31
31
|
parsedPageSize: pageSize && Number(pageSize),
|
|
32
32
|
parsedSorter: (sorters as CrudSort[]) || (sorter as CrudSort[]) || [],
|
|
33
33
|
parsedFilters: (filters as CrudFilter[]) ?? [],
|
|
@@ -26,7 +26,7 @@ export type UseCanProps = CanParams & {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* `useCan` uses the `can` as the query function for `react-query`'s {@link https://tanstack.com/query/
|
|
29
|
+
* `useCan` uses the `can` as the query function for `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`}. It takes the parameters that `can` takes. It can also be configured with `queryOptions` for `useQuery`. Returns the result of `useQuery`.
|
|
30
30
|
* @see {@link https://refine.dev/docs/api-reference/core/hooks/accessControl/useCan} for more details.
|
|
31
31
|
*
|
|
32
32
|
* @typeParam CanParams {@link https://refine.dev/docs/core/interfaceReferences#canparams}
|
|
@@ -89,7 +89,7 @@ export type UseCreateProps<
|
|
|
89
89
|
UseCreateParams<TData, TError, TVariables>;
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* `useCreate` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
92
|
+
* `useCreate` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation `useMutation`} for create mutations.
|
|
93
93
|
*
|
|
94
94
|
* It uses `create` method as mutation function from the `dataProvider` which is passed to `<Refine>`.
|
|
95
95
|
*
|
|
@@ -70,7 +70,7 @@ export type UseCreateManyProps<
|
|
|
70
70
|
UseCreateManyParams<TData, TError, TVariables>;
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* `useCreateMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
73
|
+
* `useCreateMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation `useMutation`} for multiple create mutations.
|
|
74
74
|
*
|
|
75
75
|
* It uses `createMany` method as mutation function from the `dataProvider` which is passed to `<Refine>`.
|
|
76
76
|
*
|
|
@@ -72,7 +72,7 @@ export type UseCustomProps<TQueryFnData, TError, TQuery, TPayload, TData> = {
|
|
|
72
72
|
*/
|
|
73
73
|
config?: UseCustomConfig<TQuery, TPayload>;
|
|
74
74
|
/**
|
|
75
|
-
* react-query's [useQuery](https://tanstack.com/query/
|
|
75
|
+
* react-query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options
|
|
76
76
|
*/
|
|
77
77
|
queryOptions?: UseCustomQueryOptions<TQueryFnData, TError, TData>;
|
|
78
78
|
/**
|
|
@@ -93,7 +93,7 @@ export type UseCustomProps<TQueryFnData, TError, TQuery, TPayload, TData> = {
|
|
|
93
93
|
UseLoadingOvertimeOptionsProps;
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
* `useCustom` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
96
|
+
* `useCustom` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for custom requests.
|
|
97
97
|
*
|
|
98
98
|
* It uses the `custom` method from the `dataProvider` which is passed to `<Refine>`.
|
|
99
99
|
*
|
|
@@ -114,6 +114,8 @@ export type UseCustomReturnType<TData, TError> = {
|
|
|
114
114
|
};
|
|
115
115
|
} & UseLoadingOvertimeReturnType;
|
|
116
116
|
|
|
117
|
+
const EMPTY_OBJECT = Object.freeze({}) as any;
|
|
118
|
+
|
|
117
119
|
export const useCustom = <
|
|
118
120
|
TQueryFnData extends BaseRecord = BaseRecord,
|
|
119
121
|
TError extends HttpError = HttpError,
|
|
@@ -231,7 +233,7 @@ export const useCustom = <
|
|
|
231
233
|
return {
|
|
232
234
|
query: queryResponse,
|
|
233
235
|
result: {
|
|
234
|
-
data: queryResponse.data?.data ||
|
|
236
|
+
data: queryResponse.data?.data || EMPTY_OBJECT,
|
|
235
237
|
},
|
|
236
238
|
overtime: { elapsedTime },
|
|
237
239
|
};
|
|
@@ -96,7 +96,7 @@ export type UseCustomMutationProps<
|
|
|
96
96
|
} & UseLoadingOvertimeOptionsProps;
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* `useCustomMutation` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
99
|
+
* `useCustomMutation` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation `useMutation`} for create mutations.
|
|
100
100
|
*
|
|
101
101
|
* It uses the `custom` method from the `dataProvider` which is passed to `<Refine>`.
|
|
102
102
|
*
|
|
@@ -126,7 +126,7 @@ export type UseDeleteProps<
|
|
|
126
126
|
} & UseLoadingOvertimeOptionsProps;
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
* `useDelete` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
129
|
+
* `useDelete` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation `useMutation`} for delete mutations.
|
|
130
130
|
*
|
|
131
131
|
* It uses `deleteOne` method as mutation function from the `dataProvider` which is passed to `<Refine>`.
|
|
132
132
|
*
|
|
@@ -126,7 +126,7 @@ export type UseDeleteManyProps<
|
|
|
126
126
|
} & UseLoadingOvertimeOptionsProps;
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
* `useDeleteMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
129
|
+
* `useDeleteMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation `useMutation`} for multiple delete mutations.
|
|
130
130
|
*
|
|
131
131
|
* It uses `deleteMany` method as mutation function from the `dataProvider` which is passed to `<Refine>`.
|
|
132
132
|
*
|
|
@@ -91,7 +91,7 @@ export type UseInfiniteListProps<TQueryFnData, TError, TData> = {
|
|
|
91
91
|
*/
|
|
92
92
|
resource: string;
|
|
93
93
|
/**
|
|
94
|
-
* Tanstack Query's [useInfiniteQuery](https://tanstack.com/query/
|
|
94
|
+
* Tanstack Query's [useInfiniteQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useInfiniteQuery) options
|
|
95
95
|
*/
|
|
96
96
|
queryOptions?: Omit<
|
|
97
97
|
UseInfiniteListQueryOptions<TQueryFnData, TError, TData>,
|
|
@@ -81,7 +81,7 @@ export type UseListProps<TQueryFnData, TError, TData> = {
|
|
|
81
81
|
resource?: string;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* Tanstack Query's [useQuery](https://tanstack.com/query/
|
|
84
|
+
* Tanstack Query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options
|
|
85
85
|
*/
|
|
86
86
|
queryOptions?: UseListQueryOptions<TQueryFnData, TError, TData>;
|
|
87
87
|
} & BaseListProps &
|
|
@@ -101,8 +101,10 @@ export type UseListReturnType<TData, TError> = {
|
|
|
101
101
|
};
|
|
102
102
|
} & UseLoadingOvertimeReturnType;
|
|
103
103
|
|
|
104
|
+
const EMPTY_ARRAY = Object.freeze([]) as [];
|
|
105
|
+
|
|
104
106
|
/**
|
|
105
|
-
* `useList` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
107
|
+
* `useList` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for retrieving items from a `resource` with pagination, sort, and filter configurations.
|
|
106
108
|
*
|
|
107
109
|
* It uses the `getList` method as the query function from the `dataProvider` which is passed to `<Refine>`.
|
|
108
110
|
*
|
|
@@ -315,7 +317,7 @@ export const useList = <
|
|
|
315
317
|
return {
|
|
316
318
|
query: queryResponse,
|
|
317
319
|
result: {
|
|
318
|
-
data: queryResponse?.data?.data ||
|
|
320
|
+
data: queryResponse?.data?.data || EMPTY_ARRAY,
|
|
319
321
|
total: queryResponse?.data?.total,
|
|
320
322
|
},
|
|
321
323
|
overtime: { elapsedTime },
|
|
@@ -69,7 +69,7 @@ export type UseManyProps<TQueryFnData, TError, TData> = {
|
|
|
69
69
|
*/
|
|
70
70
|
ids: BaseKey[];
|
|
71
71
|
/**
|
|
72
|
-
* react-query's [useQuery](https://tanstack.com/query/
|
|
72
|
+
* react-query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options
|
|
73
73
|
*/
|
|
74
74
|
queryOptions?: UseManyQueryOptions<TQueryFnData, TError, TData>;
|
|
75
75
|
/**
|
|
@@ -85,8 +85,10 @@ export type UseManyProps<TQueryFnData, TError, TData> = {
|
|
|
85
85
|
LiveModeProps &
|
|
86
86
|
UseLoadingOvertimeOptionsProps;
|
|
87
87
|
|
|
88
|
+
const EMPTY_ARRAY = Object.freeze([]) as [];
|
|
89
|
+
|
|
88
90
|
/**
|
|
89
|
-
* `useMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
91
|
+
* `useMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for retrieving multiple items from a `resource`.
|
|
90
92
|
*
|
|
91
93
|
* It uses `getMany` method as query function from the `dataProvider` which is passed to `<Refine>`.
|
|
92
94
|
*
|
|
@@ -259,7 +261,7 @@ export const useMany = <
|
|
|
259
261
|
return {
|
|
260
262
|
query: queryResponse,
|
|
261
263
|
result: {
|
|
262
|
-
data: queryResponse?.data?.data ||
|
|
264
|
+
data: queryResponse?.data?.data || EMPTY_ARRAY,
|
|
263
265
|
},
|
|
264
266
|
overtime: { elapsedTime },
|
|
265
267
|
};
|
package/src/hooks/data/useOne.ts
CHANGED
|
@@ -45,7 +45,7 @@ export type UseOneProps<TQueryFnData, TError, TData> = {
|
|
|
45
45
|
*/
|
|
46
46
|
id?: BaseKey;
|
|
47
47
|
/**
|
|
48
|
-
* react-query's [useQuery](https://tanstack.com/query/
|
|
48
|
+
* react-query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options
|
|
49
49
|
*/
|
|
50
50
|
queryOptions?: Omit<
|
|
51
51
|
UseQueryOptions<
|
|
@@ -90,7 +90,7 @@ export type UseOneReturnType<TData, TError> = {
|
|
|
90
90
|
} & UseLoadingOvertimeReturnType;
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* `useOne` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
93
|
+
* `useOne` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for retrieving single items from a `resource`.
|
|
94
94
|
*
|
|
95
95
|
* It uses `getOne` method as query function from the `dataProvider` which is passed to `<Refine>`.
|
|
96
96
|
*
|
|
@@ -155,7 +155,7 @@ export type UseUpdateProps<
|
|
|
155
155
|
UpdateParams<TData, TError, TVariables>;
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
|
-
* `useUpdate` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
158
|
+
* `useUpdate` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation `useMutation`} for update mutations.
|
|
159
159
|
*
|
|
160
160
|
* It uses `update` method as mutation function from the `dataProvider` which is passed to `<Refine>`.
|
|
161
161
|
*
|
|
@@ -156,7 +156,7 @@ export type UseUpdateManyProps<
|
|
|
156
156
|
UpdateManyParams<TData, TError, TVariables>;
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
* `useUpdateMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/
|
|
159
|
+
* `useUpdateMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation `useMutation`} for multiple update mutations.
|
|
160
160
|
*
|
|
161
161
|
* It uses `updateMany` method as mutation function from the `dataProvider` which is passed to `<Refine>`.
|
|
162
162
|
*
|
package/src/hooks/form/types.ts
CHANGED
|
@@ -147,7 +147,7 @@ type ActionFormProps<
|
|
|
147
147
|
*/
|
|
148
148
|
invalidates?: Array<keyof IQueryKeys>;
|
|
149
149
|
/**
|
|
150
|
-
* react-query's [useQuery](https://tanstack.com/query/
|
|
150
|
+
* react-query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options of useOne hook used while in edit mode.
|
|
151
151
|
*/
|
|
152
152
|
queryOptions?: MakeOptional<
|
|
153
153
|
UseQueryOptions<
|
|
@@ -158,7 +158,7 @@ type ActionFormProps<
|
|
|
158
158
|
"queryFn" | "queryKey"
|
|
159
159
|
>;
|
|
160
160
|
/**
|
|
161
|
-
* react-query's [useMutation](https://tanstack.com/query/
|
|
161
|
+
* react-query's [useMutation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation) options of useCreate hook used while submitting in create and clone modes.
|
|
162
162
|
*/
|
|
163
163
|
createMutationOptions?: UseCreateProps<
|
|
164
164
|
TResponse,
|
|
@@ -166,7 +166,7 @@ type ActionFormProps<
|
|
|
166
166
|
TVariables
|
|
167
167
|
>["mutationOptions"];
|
|
168
168
|
/**
|
|
169
|
-
* react-query's [useMutation](https://tanstack.com/query/
|
|
169
|
+
* react-query's [useMutation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation) options of useUpdate hook used while submitting in edit mode.
|
|
170
170
|
*/
|
|
171
171
|
updateMutationOptions?: UseUpdateProps<
|
|
172
172
|
TResponse,
|
package/src/hooks/show/types.ts
CHANGED
|
@@ -47,7 +47,7 @@ export type UseShowProps<
|
|
|
47
47
|
*/
|
|
48
48
|
id?: BaseKey;
|
|
49
49
|
/**
|
|
50
|
-
* react-query's [useQuery](https://tanstack.com/query/
|
|
50
|
+
* react-query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options
|
|
51
51
|
*/
|
|
52
52
|
queryOptions?: MakeOptional<
|
|
53
53
|
UseQueryOptions<
|
|
@@ -105,7 +105,7 @@ export type useTableProps<TQueryFnData, TError, TData> = {
|
|
|
105
105
|
*/
|
|
106
106
|
syncWithLocation?: boolean;
|
|
107
107
|
/**
|
|
108
|
-
* react-query's [useQuery](https://tanstack.com/query/
|
|
108
|
+
* react-query's [useQuery](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery) options
|
|
109
109
|
*/
|
|
110
110
|
queryOptions?: MakeOptional<
|
|
111
111
|
UseQueryOptions<
|
|
@@ -176,6 +176,7 @@ export type useTableReturnType<
|
|
|
176
176
|
|
|
177
177
|
const defaultPermanentFilter: CrudFilter[] = [];
|
|
178
178
|
const defaultPermanentSorter: CrudSort[] = [];
|
|
179
|
+
const EMPTY_ARRAY = Object.freeze([]) as [];
|
|
179
180
|
|
|
180
181
|
export function useTable<
|
|
181
182
|
TQueryFnData extends BaseRecord = BaseRecord,
|
|
@@ -219,7 +220,7 @@ export function useTable<
|
|
|
219
220
|
const preferredMeta = meta;
|
|
220
221
|
|
|
221
222
|
// Parse table params from URL if available
|
|
222
|
-
const {
|
|
223
|
+
const { parsedCurrentPage, parsedPageSize, parsedSorter, parsedFilters } =
|
|
223
224
|
parseTableParams(parsedParams.params?.search ?? "?");
|
|
224
225
|
|
|
225
226
|
const preferredInitialFilters = filtersFromProp?.initial;
|
|
@@ -239,8 +240,8 @@ export function useTable<
|
|
|
239
240
|
|
|
240
241
|
if (syncWithLocation) {
|
|
241
242
|
defaultCurrentPage =
|
|
242
|
-
parsedParams?.params?.
|
|
243
|
-
|
|
243
|
+
parsedParams?.params?.currentPage ||
|
|
244
|
+
parsedCurrentPage ||
|
|
244
245
|
prefferedCurrentPage ||
|
|
245
246
|
1;
|
|
246
247
|
defaultPageSize =
|
|
@@ -434,7 +435,7 @@ export function useTable<
|
|
|
434
435
|
createLinkForSyncWithLocation,
|
|
435
436
|
overtime: queryResult.overtime,
|
|
436
437
|
result: {
|
|
437
|
-
data: queryResult.result?.data ||
|
|
438
|
+
data: queryResult.result?.data || EMPTY_ARRAY,
|
|
438
439
|
total: queryResult.result?.total,
|
|
439
440
|
},
|
|
440
441
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
environment: "jsdom",
|
|
7
|
+
setupFiles: ["./test/vitest.setup.ts"],
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: "v8",
|
|
10
|
+
reporter: ["text", "json", "html"],
|
|
11
|
+
reportsDirectory: "./coverage",
|
|
12
|
+
exclude: ["src/index.ts"],
|
|
13
|
+
},
|
|
14
|
+
globals: true,
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
alias: {
|
|
18
|
+
// Path mappings from tsconfig.json
|
|
19
|
+
"@components": path.resolve(__dirname, "./src/components"),
|
|
20
|
+
"@components/*": path.resolve(__dirname, "./src/components/*"),
|
|
21
|
+
"@containers": path.resolve(__dirname, "./src/containers"),
|
|
22
|
+
"@containers/*": path.resolve(__dirname, "./src/containers/*"),
|
|
23
|
+
"@pages": path.resolve(__dirname, "./src/pages"),
|
|
24
|
+
"@pages/*": path.resolve(__dirname, "./src/pages/*"),
|
|
25
|
+
"@contexts": path.resolve(__dirname, "./src/contexts"),
|
|
26
|
+
"@contexts/*": path.resolve(__dirname, "./src/contexts/*"),
|
|
27
|
+
"@dataProviders": path.resolve(__dirname, "./src/dataProviders"),
|
|
28
|
+
"@dataProviders/*": path.resolve(__dirname, "./src/dataProviders/*"),
|
|
29
|
+
"@hooks": path.resolve(__dirname, "./src/hooks"),
|
|
30
|
+
"@hooks/*": path.resolve(__dirname, "./src/hooks/*"),
|
|
31
|
+
"@test": path.resolve(__dirname, "./test"),
|
|
32
|
+
"@test/*": path.resolve(__dirname, "./test/*"),
|
|
33
|
+
"@definitions": path.resolve(__dirname, "./src/definitions"),
|
|
34
|
+
"@definitions/*": path.resolve(__dirname, "./src/definitions/*"),
|
|
35
|
+
// Handle .js extension mapping
|
|
36
|
+
"^(..?/.+)\\.js?$": "$1",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
assetsInclude: ["**/*.svg"],
|
|
40
|
+
esbuild: {
|
|
41
|
+
target: "node22",
|
|
42
|
+
},
|
|
43
|
+
});
|