@tanstack/preact-query 5.94.3 → 5.94.4
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/package.json +4 -4
- package/build/codemods/src/utils/index.cjs +0 -208
- package/build/codemods/src/utils/transformers/query-cache-transformer.cjs +0 -124
- package/build/codemods/src/utils/transformers/query-client-transformer.cjs +0 -53
- package/build/codemods/src/utils/transformers/use-query-like-transformer.cjs +0 -38
- package/build/codemods/src/v4/key-transformation.cjs +0 -181
- package/build/codemods/src/v4/replace-import-specifier.cjs +0 -25
- package/build/codemods/src/v4/utils/replacers/key-replacer.cjs +0 -164
- package/build/codemods/src/v5/is-loading/is-loading.cjs +0 -244
- package/build/codemods/src/v5/keep-previous-data/README.md +0 -32
- package/build/codemods/src/v5/keep-previous-data/keep-previous-data.cjs +0 -271
- package/build/codemods/src/v5/keep-previous-data/utils/already-has-placeholder-data-property.cjs +0 -26
- package/build/codemods/src/v5/remove-overloads/remove-overloads.cjs +0 -58
- package/build/codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs +0 -271
- package/build/codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs +0 -185
- package/build/codemods/src/v5/remove-overloads/utils/index.cjs +0 -123
- package/build/codemods/src/v5/remove-overloads/utils/unknown-usage-error.cjs +0 -27
- package/build/codemods/src/v5/rename-hydrate/rename-hydrate.cjs +0 -55
- package/build/codemods/src/v5/rename-properties/rename-properties.cjs +0 -41
- package/build/legacy/HydrationBoundary.cjs +0 -82
- package/build/legacy/HydrationBoundary.cjs.map +0 -1
- package/build/legacy/HydrationBoundary.d.cts +0 -2
- package/build/legacy/HydrationBoundary.d.ts +0 -2
- package/build/legacy/HydrationBoundary.js +0 -57
- package/build/legacy/HydrationBoundary.js.map +0 -1
- package/build/legacy/IsRestoringProvider.cjs +0 -37
- package/build/legacy/IsRestoringProvider.cjs.map +0 -1
- package/build/legacy/IsRestoringProvider.d.cts +0 -2
- package/build/legacy/IsRestoringProvider.d.ts +0 -2
- package/build/legacy/IsRestoringProvider.js +0 -11
- package/build/legacy/IsRestoringProvider.js.map +0 -1
- package/build/legacy/QueryClientProvider.cjs +0 -62
- package/build/legacy/QueryClientProvider.cjs.map +0 -1
- package/build/legacy/QueryClientProvider.d.cts +0 -4
- package/build/legacy/QueryClientProvider.d.ts +0 -4
- package/build/legacy/QueryClientProvider.js +0 -35
- package/build/legacy/QueryClientProvider.js.map +0 -1
- package/build/legacy/QueryErrorResetBoundary.cjs +0 -57
- package/build/legacy/QueryErrorResetBoundary.cjs.map +0 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +0 -8
- package/build/legacy/QueryErrorResetBoundary.d.ts +0 -8
- package/build/legacy/QueryErrorResetBoundary.js +0 -31
- package/build/legacy/QueryErrorResetBoundary.js.map +0 -1
- package/build/legacy/_tsup-dts-rollup.d.cts +0 -985
- package/build/legacy/_tsup-dts-rollup.d.ts +0 -985
- package/build/legacy/errorBoundaryUtils.cjs +0 -57
- package/build/legacy/errorBoundaryUtils.cjs.map +0 -1
- package/build/legacy/errorBoundaryUtils.d.cts +0 -3
- package/build/legacy/errorBoundaryUtils.d.ts +0 -3
- package/build/legacy/errorBoundaryUtils.js +0 -30
- package/build/legacy/errorBoundaryUtils.js.map +0 -1
- package/build/legacy/index.cjs +0 -97
- package/build/legacy/index.cjs.map +0 -1
- package/build/legacy/index.d.cts +0 -206
- package/build/legacy/index.d.ts +0 -206
- package/build/legacy/index.js +0 -54
- package/build/legacy/index.js.map +0 -1
- package/build/legacy/infiniteQueryOptions.cjs +0 -33
- package/build/legacy/infiniteQueryOptions.cjs.map +0 -1
- package/build/legacy/infiniteQueryOptions.d.cts +0 -4
- package/build/legacy/infiniteQueryOptions.d.ts +0 -4
- package/build/legacy/infiniteQueryOptions.js +0 -8
- package/build/legacy/infiniteQueryOptions.js.map +0 -1
- package/build/legacy/mutationOptions.cjs +0 -33
- package/build/legacy/mutationOptions.cjs.map +0 -1
- package/build/legacy/mutationOptions.d.cts +0 -1
- package/build/legacy/mutationOptions.d.ts +0 -1
- package/build/legacy/mutationOptions.js +0 -8
- package/build/legacy/mutationOptions.js.map +0 -1
- package/build/legacy/queryOptions.cjs +0 -33
- package/build/legacy/queryOptions.cjs.map +0 -1
- package/build/legacy/queryOptions.d.cts +0 -4
- package/build/legacy/queryOptions.d.ts +0 -4
- package/build/legacy/queryOptions.js +0 -8
- package/build/legacy/queryOptions.js.map +0 -1
- package/build/legacy/suspense.cjs +0 -58
- package/build/legacy/suspense.cjs.map +0 -1
- package/build/legacy/suspense.d.cts +0 -5
- package/build/legacy/suspense.d.ts +0 -5
- package/build/legacy/suspense.js +0 -29
- package/build/legacy/suspense.js.map +0 -1
- package/build/legacy/types.cjs +0 -19
- package/build/legacy/types.cjs.map +0 -1
- package/build/legacy/types.d.cts +0 -24
- package/build/legacy/types.d.ts +0 -24
- package/build/legacy/types.js +0 -1
- package/build/legacy/types.js.map +0 -1
- package/build/legacy/useBaseQuery.cjs +0 -121
- package/build/legacy/useBaseQuery.cjs.map +0 -1
- package/build/legacy/useBaseQuery.d.cts +0 -1
- package/build/legacy/useBaseQuery.d.ts +0 -1
- package/build/legacy/useBaseQuery.js +0 -105
- package/build/legacy/useBaseQuery.js.map +0 -1
- package/build/legacy/useInfiniteQuery.cjs +0 -39
- package/build/legacy/useInfiniteQuery.cjs.map +0 -1
- package/build/legacy/useInfiniteQuery.d.cts +0 -1
- package/build/legacy/useInfiniteQuery.d.ts +0 -1
- package/build/legacy/useInfiniteQuery.js +0 -14
- package/build/legacy/useInfiniteQuery.js.map +0 -1
- package/build/legacy/useIsFetching.cjs +0 -45
- package/build/legacy/useIsFetching.cjs.map +0 -1
- package/build/legacy/useIsFetching.d.cts +0 -1
- package/build/legacy/useIsFetching.d.ts +0 -1
- package/build/legacy/useIsFetching.js +0 -20
- package/build/legacy/useIsFetching.js.map +0 -1
- package/build/legacy/useMutation.cjs +0 -63
- package/build/legacy/useMutation.cjs.map +0 -1
- package/build/legacy/useMutation.d.cts +0 -1
- package/build/legacy/useMutation.d.ts +0 -1
- package/build/legacy/useMutation.js +0 -43
- package/build/legacy/useMutation.js.map +0 -1
- package/build/legacy/useMutationState.cjs +0 -75
- package/build/legacy/useMutationState.cjs.map +0 -1
- package/build/legacy/useMutationState.d.cts +0 -2
- package/build/legacy/useMutationState.d.ts +0 -2
- package/build/legacy/useMutationState.js +0 -49
- package/build/legacy/useMutationState.js.map +0 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +0 -37
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +0 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +0 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +0 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +0 -12
- package/build/legacy/usePrefetchInfiniteQuery.js.map +0 -1
- package/build/legacy/usePrefetchQuery.cjs +0 -37
- package/build/legacy/usePrefetchQuery.cjs.map +0 -1
- package/build/legacy/usePrefetchQuery.d.cts +0 -1
- package/build/legacy/usePrefetchQuery.d.ts +0 -1
- package/build/legacy/usePrefetchQuery.js +0 -12
- package/build/legacy/usePrefetchQuery.js.map +0 -1
- package/build/legacy/useQueries.cjs +0 -116
- package/build/legacy/useQueries.cjs.map +0 -1
- package/build/legacy/useQueries.d.cts +0 -3
- package/build/legacy/useQueries.d.ts +0 -3
- package/build/legacy/useQueries.js +0 -104
- package/build/legacy/useQueries.js.map +0 -1
- package/build/legacy/useQuery.cjs +0 -35
- package/build/legacy/useQuery.cjs.map +0 -1
- package/build/legacy/useQuery.d.cts +0 -1
- package/build/legacy/useQuery.d.ts +0 -1
- package/build/legacy/useQuery.js +0 -10
- package/build/legacy/useQuery.js.map +0 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +0 -50
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +0 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +0 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +0 -1
- package/build/legacy/useSuspenseInfiniteQuery.js +0 -25
- package/build/legacy/useSuspenseInfiniteQuery.js.map +0 -1
- package/build/legacy/useSuspenseQueries.cjs +0 -55
- package/build/legacy/useSuspenseQueries.cjs.map +0 -1
- package/build/legacy/useSuspenseQueries.d.cts +0 -3
- package/build/legacy/useSuspenseQueries.d.ts +0 -3
- package/build/legacy/useSuspenseQueries.js +0 -30
- package/build/legacy/useSuspenseQueries.js.map +0 -1
- package/build/legacy/useSuspenseQuery.cjs +0 -51
- package/build/legacy/useSuspenseQuery.cjs.map +0 -1
- package/build/legacy/useSuspenseQuery.d.cts +0 -1
- package/build/legacy/useSuspenseQuery.d.ts +0 -1
- package/build/legacy/useSuspenseQuery.js +0 -26
- package/build/legacy/useSuspenseQuery.js.map +0 -1
- package/build/legacy/utils.cjs +0 -79
- package/build/legacy/utils.cjs.map +0 -1
- package/build/legacy/utils.d.cts +0 -2
- package/build/legacy/utils.d.ts +0 -2
- package/build/legacy/utils.js +0 -53
- package/build/legacy/utils.js.map +0 -1
- package/build/modern/HydrationBoundary.cjs +0 -82
- package/build/modern/HydrationBoundary.cjs.map +0 -1
- package/build/modern/HydrationBoundary.d.cts +0 -2
- package/build/modern/HydrationBoundary.d.ts +0 -2
- package/build/modern/HydrationBoundary.js +0 -57
- package/build/modern/HydrationBoundary.js.map +0 -1
- package/build/modern/IsRestoringProvider.cjs +0 -37
- package/build/modern/IsRestoringProvider.cjs.map +0 -1
- package/build/modern/IsRestoringProvider.d.cts +0 -2
- package/build/modern/IsRestoringProvider.d.ts +0 -2
- package/build/modern/IsRestoringProvider.js +0 -11
- package/build/modern/IsRestoringProvider.js.map +0 -1
- package/build/modern/QueryClientProvider.cjs +0 -62
- package/build/modern/QueryClientProvider.cjs.map +0 -1
- package/build/modern/QueryClientProvider.d.cts +0 -4
- package/build/modern/QueryClientProvider.d.ts +0 -4
- package/build/modern/QueryClientProvider.js +0 -35
- package/build/modern/QueryClientProvider.js.map +0 -1
- package/build/modern/QueryErrorResetBoundary.cjs +0 -57
- package/build/modern/QueryErrorResetBoundary.cjs.map +0 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +0 -8
- package/build/modern/QueryErrorResetBoundary.d.ts +0 -8
- package/build/modern/QueryErrorResetBoundary.js +0 -31
- package/build/modern/QueryErrorResetBoundary.js.map +0 -1
- package/build/modern/_tsup-dts-rollup.d.cts +0 -985
- package/build/modern/_tsup-dts-rollup.d.ts +0 -985
- package/build/modern/errorBoundaryUtils.cjs +0 -57
- package/build/modern/errorBoundaryUtils.cjs.map +0 -1
- package/build/modern/errorBoundaryUtils.d.cts +0 -3
- package/build/modern/errorBoundaryUtils.d.ts +0 -3
- package/build/modern/errorBoundaryUtils.js +0 -30
- package/build/modern/errorBoundaryUtils.js.map +0 -1
- package/build/modern/index.cjs +0 -97
- package/build/modern/index.cjs.map +0 -1
- package/build/modern/index.d.cts +0 -206
- package/build/modern/index.d.ts +0 -206
- package/build/modern/index.js +0 -54
- package/build/modern/index.js.map +0 -1
- package/build/modern/infiniteQueryOptions.cjs +0 -33
- package/build/modern/infiniteQueryOptions.cjs.map +0 -1
- package/build/modern/infiniteQueryOptions.d.cts +0 -4
- package/build/modern/infiniteQueryOptions.d.ts +0 -4
- package/build/modern/infiniteQueryOptions.js +0 -8
- package/build/modern/infiniteQueryOptions.js.map +0 -1
- package/build/modern/mutationOptions.cjs +0 -33
- package/build/modern/mutationOptions.cjs.map +0 -1
- package/build/modern/mutationOptions.d.cts +0 -1
- package/build/modern/mutationOptions.d.ts +0 -1
- package/build/modern/mutationOptions.js +0 -8
- package/build/modern/mutationOptions.js.map +0 -1
- package/build/modern/queryOptions.cjs +0 -33
- package/build/modern/queryOptions.cjs.map +0 -1
- package/build/modern/queryOptions.d.cts +0 -4
- package/build/modern/queryOptions.d.ts +0 -4
- package/build/modern/queryOptions.js +0 -8
- package/build/modern/queryOptions.js.map +0 -1
- package/build/modern/suspense.cjs +0 -58
- package/build/modern/suspense.cjs.map +0 -1
- package/build/modern/suspense.d.cts +0 -5
- package/build/modern/suspense.d.ts +0 -5
- package/build/modern/suspense.js +0 -29
- package/build/modern/suspense.js.map +0 -1
- package/build/modern/types.cjs +0 -19
- package/build/modern/types.cjs.map +0 -1
- package/build/modern/types.d.cts +0 -24
- package/build/modern/types.d.ts +0 -24
- package/build/modern/types.js +0 -1
- package/build/modern/types.js.map +0 -1
- package/build/modern/useBaseQuery.cjs +0 -118
- package/build/modern/useBaseQuery.cjs.map +0 -1
- package/build/modern/useBaseQuery.d.cts +0 -1
- package/build/modern/useBaseQuery.d.ts +0 -1
- package/build/modern/useBaseQuery.js +0 -102
- package/build/modern/useBaseQuery.js.map +0 -1
- package/build/modern/useInfiniteQuery.cjs +0 -39
- package/build/modern/useInfiniteQuery.cjs.map +0 -1
- package/build/modern/useInfiniteQuery.d.cts +0 -1
- package/build/modern/useInfiniteQuery.d.ts +0 -1
- package/build/modern/useInfiniteQuery.js +0 -14
- package/build/modern/useInfiniteQuery.js.map +0 -1
- package/build/modern/useIsFetching.cjs +0 -45
- package/build/modern/useIsFetching.cjs.map +0 -1
- package/build/modern/useIsFetching.d.cts +0 -1
- package/build/modern/useIsFetching.d.ts +0 -1
- package/build/modern/useIsFetching.js +0 -20
- package/build/modern/useIsFetching.js.map +0 -1
- package/build/modern/useMutation.cjs +0 -63
- package/build/modern/useMutation.cjs.map +0 -1
- package/build/modern/useMutation.d.cts +0 -1
- package/build/modern/useMutation.d.ts +0 -1
- package/build/modern/useMutation.js +0 -43
- package/build/modern/useMutation.js.map +0 -1
- package/build/modern/useMutationState.cjs +0 -75
- package/build/modern/useMutationState.cjs.map +0 -1
- package/build/modern/useMutationState.d.cts +0 -2
- package/build/modern/useMutationState.d.ts +0 -2
- package/build/modern/useMutationState.js +0 -49
- package/build/modern/useMutationState.js.map +0 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +0 -37
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +0 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +0 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +0 -1
- package/build/modern/usePrefetchInfiniteQuery.js +0 -12
- package/build/modern/usePrefetchInfiniteQuery.js.map +0 -1
- package/build/modern/usePrefetchQuery.cjs +0 -37
- package/build/modern/usePrefetchQuery.cjs.map +0 -1
- package/build/modern/usePrefetchQuery.d.cts +0 -1
- package/build/modern/usePrefetchQuery.d.ts +0 -1
- package/build/modern/usePrefetchQuery.js +0 -12
- package/build/modern/usePrefetchQuery.js.map +0 -1
- package/build/modern/useQueries.cjs +0 -116
- package/build/modern/useQueries.cjs.map +0 -1
- package/build/modern/useQueries.d.cts +0 -3
- package/build/modern/useQueries.d.ts +0 -3
- package/build/modern/useQueries.js +0 -104
- package/build/modern/useQueries.js.map +0 -1
- package/build/modern/useQuery.cjs +0 -35
- package/build/modern/useQuery.cjs.map +0 -1
- package/build/modern/useQuery.d.cts +0 -1
- package/build/modern/useQuery.d.ts +0 -1
- package/build/modern/useQuery.js +0 -10
- package/build/modern/useQuery.js.map +0 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +0 -50
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +0 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +0 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +0 -1
- package/build/modern/useSuspenseInfiniteQuery.js +0 -25
- package/build/modern/useSuspenseInfiniteQuery.js.map +0 -1
- package/build/modern/useSuspenseQueries.cjs +0 -55
- package/build/modern/useSuspenseQueries.cjs.map +0 -1
- package/build/modern/useSuspenseQueries.d.cts +0 -3
- package/build/modern/useSuspenseQueries.d.ts +0 -3
- package/build/modern/useSuspenseQueries.js +0 -30
- package/build/modern/useSuspenseQueries.js.map +0 -1
- package/build/modern/useSuspenseQuery.cjs +0 -51
- package/build/modern/useSuspenseQuery.cjs.map +0 -1
- package/build/modern/useSuspenseQuery.d.cts +0 -1
- package/build/modern/useSuspenseQuery.d.ts +0 -1
- package/build/modern/useSuspenseQuery.js +0 -26
- package/build/modern/useSuspenseQuery.js.map +0 -1
- package/build/modern/utils.cjs +0 -79
- package/build/modern/utils.cjs.map +0 -1
- package/build/modern/utils.d.cts +0 -2
- package/build/modern/utils.d.ts +0 -2
- package/build/modern/utils.js +0 -53
- package/build/modern/utils.js.map +0 -1
- package/build/query-codemods/eslint.config.js +0 -18
- package/build/query-codemods/package.json +0 -38
- package/build/query-codemods/root.eslint.config.js +0 -64
- package/build/query-codemods/tsconfig.json +0 -8
- package/build/query-codemods/vite.config.ts +0 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/preact-query",
|
|
3
|
-
"version": "5.94.
|
|
3
|
+
"version": "5.94.4",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in preact",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"!build/codemods/**/__tests__"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@tanstack/query-core": "5.
|
|
46
|
+
"@tanstack/query-core": "5.94.4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@preact/preset-vite": "^2.10.2",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"preact-render-to-string": "^6.6.4",
|
|
56
56
|
"typescript": "5.9.3",
|
|
57
57
|
"typescript-eslint": "^8.54.0",
|
|
58
|
-
"@tanstack/query-
|
|
59
|
-
"@tanstack/query-
|
|
58
|
+
"@tanstack/query-persist-client-core": "5.94.4",
|
|
59
|
+
"@tanstack/query-test-utils": "0.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"preact": "^10.0.0"
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
module.exports = ({ root, jscodeshift }) => {
|
|
2
|
-
const findImportIdentifierOf = (importSpecifiers, identifier) => {
|
|
3
|
-
const specifier = importSpecifiers
|
|
4
|
-
.filter((node) => node.value.imported.name === identifier)
|
|
5
|
-
.paths()
|
|
6
|
-
|
|
7
|
-
if (specifier.length > 0) {
|
|
8
|
-
return specifier[0].value.local
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return jscodeshift.identifier(identifier)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const findImportSpecifiers = (packageName) =>
|
|
15
|
-
root
|
|
16
|
-
.find(jscodeshift.ImportDeclaration, {
|
|
17
|
-
source: {
|
|
18
|
-
value: packageName,
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
.find(jscodeshift.ImportSpecifier, {})
|
|
22
|
-
|
|
23
|
-
const locateImports = (
|
|
24
|
-
identifiers,
|
|
25
|
-
packageName = '@tanstack/react-query',
|
|
26
|
-
) => {
|
|
27
|
-
const findNamespaceImportIdentifier = () => {
|
|
28
|
-
const specifier = root
|
|
29
|
-
.find(jscodeshift.ImportDeclaration, {
|
|
30
|
-
source: {
|
|
31
|
-
value: packageName,
|
|
32
|
-
},
|
|
33
|
-
})
|
|
34
|
-
.find(jscodeshift.ImportNamespaceSpecifier)
|
|
35
|
-
.paths()
|
|
36
|
-
|
|
37
|
-
return specifier.length > 0 ? specifier[0].value.local : null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* First, we search for the namespace import identifier because if we have any, we assume the consumer uses
|
|
42
|
-
* namespace imports. In this case, we won't search for named imports at all.
|
|
43
|
-
*/
|
|
44
|
-
const namespaceImportIdentifier = findNamespaceImportIdentifier()
|
|
45
|
-
|
|
46
|
-
if (namespaceImportIdentifier) {
|
|
47
|
-
const identifierMap = {}
|
|
48
|
-
|
|
49
|
-
for (const identifier of identifiers) {
|
|
50
|
-
identifierMap[identifier] = jscodeshift.identifier(identifier)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
namespace: namespaceImportIdentifier,
|
|
55
|
-
...identifierMap,
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const importSpecifiers = findImportSpecifiers(packageName)
|
|
60
|
-
const identifierMap = {}
|
|
61
|
-
|
|
62
|
-
for (const identifier of identifiers) {
|
|
63
|
-
identifierMap[identifier] = findImportIdentifierOf(
|
|
64
|
-
importSpecifiers,
|
|
65
|
-
identifier,
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
namespace: null,
|
|
71
|
-
...identifierMap,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const findAllMethodCalls = () =>
|
|
76
|
-
root
|
|
77
|
-
// First, we need to find all method calls.
|
|
78
|
-
.find(jscodeshift.CallExpression, {
|
|
79
|
-
callee: {
|
|
80
|
-
type: jscodeshift.MemberExpression.name,
|
|
81
|
-
property: {
|
|
82
|
-
type: jscodeshift.Identifier.name,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
const findQueryClientIdentifiers = (importIdentifiers) =>
|
|
88
|
-
root
|
|
89
|
-
.find(jscodeshift.VariableDeclarator, {})
|
|
90
|
-
.filter((node) => {
|
|
91
|
-
if (node.value.init) {
|
|
92
|
-
const initializer = node.value.init
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
isClassInstantiationOf(
|
|
96
|
-
initializer,
|
|
97
|
-
getSelectorByImports(importIdentifiers, 'QueryClient'),
|
|
98
|
-
) ||
|
|
99
|
-
isFunctionCallOf(
|
|
100
|
-
initializer,
|
|
101
|
-
getSelectorByImports(importIdentifiers, 'useQueryClient'),
|
|
102
|
-
)
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return false
|
|
107
|
-
})
|
|
108
|
-
.paths()
|
|
109
|
-
.map((node) => node.value.id.name)
|
|
110
|
-
|
|
111
|
-
const isCallExpression = (node) =>
|
|
112
|
-
jscodeshift.match(node, { type: jscodeshift.CallExpression.name })
|
|
113
|
-
|
|
114
|
-
const isIdentifier = (node) =>
|
|
115
|
-
jscodeshift.match(node, { type: jscodeshift.Identifier.name })
|
|
116
|
-
|
|
117
|
-
const isMemberExpression = (node) =>
|
|
118
|
-
jscodeshift.match(node, { type: jscodeshift.MemberExpression.name })
|
|
119
|
-
|
|
120
|
-
const isNewExpression = (node) =>
|
|
121
|
-
jscodeshift.match(node, { type: jscodeshift.NewExpression.name })
|
|
122
|
-
|
|
123
|
-
const isArrayExpression = (node) =>
|
|
124
|
-
jscodeshift.match(node, { type: jscodeshift.ArrayExpression.name })
|
|
125
|
-
|
|
126
|
-
const isObjectExpression = (node) =>
|
|
127
|
-
jscodeshift.match(node, { type: jscodeshift.ObjectExpression.name })
|
|
128
|
-
|
|
129
|
-
const isObjectProperty = (node) =>
|
|
130
|
-
jscodeshift.match(node, { type: jscodeshift.ObjectProperty.name })
|
|
131
|
-
|
|
132
|
-
const isSpreadElement = (node) =>
|
|
133
|
-
jscodeshift.match(node, { type: jscodeshift.SpreadElement.name })
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @param {import('jscodeshift').Node} node
|
|
137
|
-
* @returns {boolean}
|
|
138
|
-
*/
|
|
139
|
-
const isFunctionDefinition = (node) => {
|
|
140
|
-
const isArrowFunctionExpression = jscodeshift.match(node, {
|
|
141
|
-
type: jscodeshift.ArrowFunctionExpression.name,
|
|
142
|
-
})
|
|
143
|
-
const isFunctionExpression = jscodeshift.match(node, {
|
|
144
|
-
type: jscodeshift.FunctionExpression.name,
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
return isArrowFunctionExpression || isFunctionExpression
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const warn = (message) => {
|
|
151
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
152
|
-
console.warn(message)
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const isClassInstantiationOf = (node, selector) => {
|
|
157
|
-
if (!isNewExpression(node)) {
|
|
158
|
-
return false
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const parts = selector.split('.')
|
|
162
|
-
|
|
163
|
-
return parts.length === 1
|
|
164
|
-
? isIdentifier(node.callee) && node.callee.name === parts[0]
|
|
165
|
-
: isMemberExpression(node.callee) &&
|
|
166
|
-
node.callee.object.name === parts[0] &&
|
|
167
|
-
node.callee.property.name === parts[1]
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const isFunctionCallOf = (node, selector) => {
|
|
171
|
-
if (!isCallExpression(node)) {
|
|
172
|
-
return false
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const parts = selector.split('.')
|
|
176
|
-
|
|
177
|
-
return parts.length === 1
|
|
178
|
-
? isIdentifier(node.callee) && node.callee.name === parts[0]
|
|
179
|
-
: isMemberExpression(node.callee) &&
|
|
180
|
-
node.callee.object.name === parts[0] &&
|
|
181
|
-
node.callee.property.name === parts[1]
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const getSelectorByImports = (imports, path) =>
|
|
185
|
-
imports.namespace
|
|
186
|
-
? `${imports.namespace.name}.${imports[path].name}`
|
|
187
|
-
: imports[path].name
|
|
188
|
-
|
|
189
|
-
return {
|
|
190
|
-
findAllMethodCalls,
|
|
191
|
-
getSelectorByImports,
|
|
192
|
-
isCallExpression,
|
|
193
|
-
isClassInstantiationOf,
|
|
194
|
-
isFunctionCallOf,
|
|
195
|
-
isIdentifier,
|
|
196
|
-
isMemberExpression,
|
|
197
|
-
isArrayExpression,
|
|
198
|
-
isObjectExpression,
|
|
199
|
-
isObjectProperty,
|
|
200
|
-
isSpreadElement,
|
|
201
|
-
isFunctionDefinition,
|
|
202
|
-
locateImports,
|
|
203
|
-
warn,
|
|
204
|
-
queryClient: {
|
|
205
|
-
findQueryClientIdentifiers,
|
|
206
|
-
},
|
|
207
|
-
}
|
|
208
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
module.exports = ({
|
|
2
|
-
jscodeshift,
|
|
3
|
-
utils,
|
|
4
|
-
root,
|
|
5
|
-
packageName = '@tanstack/react-query',
|
|
6
|
-
}) => {
|
|
7
|
-
const isGetQueryCacheMethodCall = (
|
|
8
|
-
initializer,
|
|
9
|
-
importIdentifiers,
|
|
10
|
-
knownQueryClientIds,
|
|
11
|
-
) => {
|
|
12
|
-
const isKnownQueryClient = (node) =>
|
|
13
|
-
utils.isIdentifier(node) && knownQueryClientIds.includes(node.name)
|
|
14
|
-
|
|
15
|
-
const isGetQueryCacheIdentifier = (node) =>
|
|
16
|
-
utils.isIdentifier(node) && node.name === 'getQueryCache'
|
|
17
|
-
|
|
18
|
-
const isValidInitializer = (node) =>
|
|
19
|
-
utils.isCallExpression(node) && utils.isMemberExpression(node.callee)
|
|
20
|
-
|
|
21
|
-
if (isValidInitializer(initializer)) {
|
|
22
|
-
const instance = initializer.callee.object
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
isGetQueryCacheIdentifier(initializer.callee.property) &&
|
|
26
|
-
(isKnownQueryClient(instance) ||
|
|
27
|
-
utils.isFunctionCallOf(
|
|
28
|
-
instance,
|
|
29
|
-
utils.getSelectorByImports(importIdentifiers, 'useQueryClient'),
|
|
30
|
-
))
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return false
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const findQueryCacheInstantiations = (
|
|
38
|
-
importIdentifiers,
|
|
39
|
-
knownQueryClientIds,
|
|
40
|
-
) =>
|
|
41
|
-
root.find(jscodeshift.VariableDeclarator, {}).filter((node) => {
|
|
42
|
-
if (node.value.init) {
|
|
43
|
-
const initializer = node.value.init
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
utils.isClassInstantiationOf(
|
|
47
|
-
initializer,
|
|
48
|
-
utils.getSelectorByImports(importIdentifiers, 'QueryCache'),
|
|
49
|
-
) ||
|
|
50
|
-
isGetQueryCacheMethodCall(
|
|
51
|
-
initializer,
|
|
52
|
-
importIdentifiers,
|
|
53
|
-
knownQueryClientIds,
|
|
54
|
-
)
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return false
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
const filterQueryCacheMethodCalls = (node) =>
|
|
62
|
-
utils.isIdentifier(node) && ['find', 'findAll'].includes(node.name)
|
|
63
|
-
|
|
64
|
-
const findQueryCacheMethodCalls = (importIdentifiers) => {
|
|
65
|
-
/**
|
|
66
|
-
* Here we collect all query client instantiations. We have to make aware of them because the query cache can be
|
|
67
|
-
* accessed by the query client as well.
|
|
68
|
-
*/
|
|
69
|
-
const queryClientIdentifiers =
|
|
70
|
-
utils.queryClient.findQueryClientIdentifiers(importIdentifiers)
|
|
71
|
-
/**
|
|
72
|
-
* Here we collect all query cache instantiations. The reason is simple: the methods can be called on query cache
|
|
73
|
-
* instances, to locate the possible usages we need to be aware of the identifier names.
|
|
74
|
-
*/
|
|
75
|
-
const queryCacheIdentifiers = findQueryCacheInstantiations(
|
|
76
|
-
importIdentifiers,
|
|
77
|
-
queryClientIdentifiers,
|
|
78
|
-
)
|
|
79
|
-
.paths()
|
|
80
|
-
.map((node) => node.value.id.name)
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
utils
|
|
84
|
-
// First, we need to find all method calls.
|
|
85
|
-
.findAllMethodCalls()
|
|
86
|
-
// Then we narrow the collection to all `fetch` and `fetchAll` methods.
|
|
87
|
-
.filter((node) =>
|
|
88
|
-
filterQueryCacheMethodCalls(node.value.callee.property),
|
|
89
|
-
)
|
|
90
|
-
.filter((node) => {
|
|
91
|
-
const object = node.value.callee.object
|
|
92
|
-
|
|
93
|
-
// If the method is called on a `QueryCache` instance, we keep it in the collection.
|
|
94
|
-
if (utils.isIdentifier(object)) {
|
|
95
|
-
return queryCacheIdentifiers.includes(object.name)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// If the method is called on a `QueryClient` instance, we keep it in the collection.
|
|
99
|
-
if (utils.isCallExpression(object)) {
|
|
100
|
-
return isGetQueryCacheMethodCall(
|
|
101
|
-
object,
|
|
102
|
-
importIdentifiers,
|
|
103
|
-
queryClientIdentifiers,
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return false
|
|
108
|
-
})
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const execute = (replacer) => {
|
|
113
|
-
findQueryCacheMethodCalls(
|
|
114
|
-
utils.locateImports(
|
|
115
|
-
['QueryCache', 'QueryClient', 'useQueryClient'],
|
|
116
|
-
packageName,
|
|
117
|
-
),
|
|
118
|
-
).replaceWith(replacer)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
execute,
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
module.exports = ({
|
|
2
|
-
jscodeshift,
|
|
3
|
-
utils,
|
|
4
|
-
root,
|
|
5
|
-
packageName = '@tanstack/react-query',
|
|
6
|
-
}) => {
|
|
7
|
-
const filterQueryClientMethodCalls = (node, methods) =>
|
|
8
|
-
utils.isIdentifier(node) && methods.includes(node.name)
|
|
9
|
-
|
|
10
|
-
const findQueryClientMethodCalls = (importIdentifiers, methods) => {
|
|
11
|
-
/**
|
|
12
|
-
* Here we collect all query client instantiations. We have to make aware of them because some method calls might
|
|
13
|
-
* be invoked on these instances.
|
|
14
|
-
*/
|
|
15
|
-
const queryClientIdentifiers =
|
|
16
|
-
utils.queryClient.findQueryClientIdentifiers(importIdentifiers)
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
utils
|
|
20
|
-
// First, we need to find all method calls.
|
|
21
|
-
.findAllMethodCalls()
|
|
22
|
-
// Then we narrow the collection to `QueryClient` methods.
|
|
23
|
-
.filter((node) =>
|
|
24
|
-
filterQueryClientMethodCalls(node.value.callee.property, methods),
|
|
25
|
-
)
|
|
26
|
-
.filter((node) => {
|
|
27
|
-
const object = node.value.callee.object
|
|
28
|
-
|
|
29
|
-
// If the method is called on a `QueryClient` instance, we keep it in the collection.
|
|
30
|
-
if (utils.isIdentifier(object)) {
|
|
31
|
-
return queryClientIdentifiers.includes(object.name)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// If the method is called on the return value of `useQueryClient` hook, we keep it in the collection.
|
|
35
|
-
return utils.isFunctionCallOf(
|
|
36
|
-
object,
|
|
37
|
-
utils.getSelectorByImports(importIdentifiers, 'useQueryClient'),
|
|
38
|
-
)
|
|
39
|
-
})
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const execute = (methods, replacer) => {
|
|
44
|
-
findQueryClientMethodCalls(
|
|
45
|
-
utils.locateImports(['QueryClient', 'useQueryClient'], packageName),
|
|
46
|
-
methods,
|
|
47
|
-
).replaceWith(replacer)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
execute,
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module.exports = ({
|
|
2
|
-
jscodeshift,
|
|
3
|
-
utils,
|
|
4
|
-
root,
|
|
5
|
-
packageName = '@tanstack/react-query',
|
|
6
|
-
}) => {
|
|
7
|
-
const filterUseQueryLikeHookCalls = (node, importIdentifiers, hooks) => {
|
|
8
|
-
for (const hook of hooks) {
|
|
9
|
-
const selector = utils.getSelectorByImports(importIdentifiers, hook)
|
|
10
|
-
|
|
11
|
-
if (utils.isFunctionCallOf(node, selector)) {
|
|
12
|
-
return true
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return false
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const findUseQueryLikeHookCalls = (importIdentifiers, hooks) =>
|
|
20
|
-
root
|
|
21
|
-
// First, we need to find all call expressions.
|
|
22
|
-
.find(jscodeshift.CallExpression, {})
|
|
23
|
-
// Then we narrow the collection to the `useQuery` like hook calls.
|
|
24
|
-
.filter((node) =>
|
|
25
|
-
filterUseQueryLikeHookCalls(node.value, importIdentifiers, hooks),
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
const execute = (hooks, replacer) => {
|
|
29
|
-
findUseQueryLikeHookCalls(
|
|
30
|
-
utils.locateImports(hooks, packageName),
|
|
31
|
-
hooks,
|
|
32
|
-
).replaceWith(replacer)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
execute,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
const createUtilsObject = require('../utils/index.cjs')
|
|
2
|
-
const createKeyReplacer = require('./utils/replacers/key-replacer.cjs')
|
|
3
|
-
const createUseQueryLikeTransformer = require('../utils/transformers/use-query-like-transformer.cjs')
|
|
4
|
-
const createQueryClientTransformer = require('../utils/transformers/query-client-transformer.cjs')
|
|
5
|
-
const createQueryCacheTransformer = require('../utils/transformers/query-cache-transformer.cjs')
|
|
6
|
-
|
|
7
|
-
const transformQueryClientUsages = ({
|
|
8
|
-
jscodeshift,
|
|
9
|
-
utils,
|
|
10
|
-
root,
|
|
11
|
-
filePath,
|
|
12
|
-
packageName,
|
|
13
|
-
}) => {
|
|
14
|
-
const transformer = createQueryClientTransformer({
|
|
15
|
-
jscodeshift,
|
|
16
|
-
utils,
|
|
17
|
-
root,
|
|
18
|
-
packageName,
|
|
19
|
-
})
|
|
20
|
-
const replacer = createKeyReplacer({ jscodeshift, root, filePath })
|
|
21
|
-
|
|
22
|
-
transformer.execute(
|
|
23
|
-
[
|
|
24
|
-
// Not object syntax-aware methods.
|
|
25
|
-
'getMutationDefaults',
|
|
26
|
-
'getQueriesData',
|
|
27
|
-
'getQueryData',
|
|
28
|
-
'getQueryDefaults',
|
|
29
|
-
'getQueryState',
|
|
30
|
-
'isFetching',
|
|
31
|
-
'setMutationDefaults',
|
|
32
|
-
'setQueriesData',
|
|
33
|
-
'setQueryData',
|
|
34
|
-
'setQueryDefaults',
|
|
35
|
-
// Object syntax-aware methods.
|
|
36
|
-
'cancelQueries',
|
|
37
|
-
'fetchInfiniteQuery',
|
|
38
|
-
'fetchQuery',
|
|
39
|
-
'invalidateQueries',
|
|
40
|
-
'prefetchInfiniteQuery',
|
|
41
|
-
'prefetchQuery',
|
|
42
|
-
'refetchQueries',
|
|
43
|
-
'removeQueries',
|
|
44
|
-
'resetQueries',
|
|
45
|
-
],
|
|
46
|
-
replacer,
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const transformUseQueriesUsages = ({
|
|
51
|
-
jscodeshift,
|
|
52
|
-
utils,
|
|
53
|
-
root,
|
|
54
|
-
packageName,
|
|
55
|
-
}) => {
|
|
56
|
-
const transformer = createUseQueryLikeTransformer({
|
|
57
|
-
jscodeshift,
|
|
58
|
-
utils,
|
|
59
|
-
root,
|
|
60
|
-
packageName,
|
|
61
|
-
})
|
|
62
|
-
const replacer = ({ node }) => {
|
|
63
|
-
/**
|
|
64
|
-
* When the node doesn't have the 'original' property, that means the codemod has been already applied,
|
|
65
|
-
* so we don't need to do any changes.
|
|
66
|
-
*/
|
|
67
|
-
if (!node.original) {
|
|
68
|
-
return node
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const newCallExpression = jscodeshift.callExpression(node.original.callee, [
|
|
72
|
-
jscodeshift.objectExpression([
|
|
73
|
-
jscodeshift.property(
|
|
74
|
-
'init',
|
|
75
|
-
jscodeshift.identifier('queries'),
|
|
76
|
-
node.original.arguments[0],
|
|
77
|
-
),
|
|
78
|
-
]),
|
|
79
|
-
])
|
|
80
|
-
|
|
81
|
-
// TODO: This should be part of one function!
|
|
82
|
-
if (node.typeParameters) {
|
|
83
|
-
newCallExpression.typeArguments = node.typeParameters
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return newCallExpression
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
transformer.execute(['useQueries'], replacer)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const transformUseQueryLikeUsages = ({
|
|
93
|
-
jscodeshift,
|
|
94
|
-
utils,
|
|
95
|
-
root,
|
|
96
|
-
filePath,
|
|
97
|
-
packageName,
|
|
98
|
-
}) => {
|
|
99
|
-
const transformer = createUseQueryLikeTransformer({
|
|
100
|
-
jscodeshift,
|
|
101
|
-
utils,
|
|
102
|
-
root,
|
|
103
|
-
packageName,
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
transformer.execute(
|
|
107
|
-
['useQuery', 'useInfiniteQuery', 'useIsFetching', 'useIsMutating'],
|
|
108
|
-
createKeyReplacer({
|
|
109
|
-
jscodeshift,
|
|
110
|
-
root,
|
|
111
|
-
filePath,
|
|
112
|
-
keyName: 'queryKey',
|
|
113
|
-
}),
|
|
114
|
-
)
|
|
115
|
-
transformer.execute(
|
|
116
|
-
['useMutation'],
|
|
117
|
-
createKeyReplacer({
|
|
118
|
-
jscodeshift,
|
|
119
|
-
root,
|
|
120
|
-
filePath,
|
|
121
|
-
keyName: 'mutationKey',
|
|
122
|
-
}),
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const transformQueryCacheUsages = ({
|
|
127
|
-
jscodeshift,
|
|
128
|
-
utils,
|
|
129
|
-
root,
|
|
130
|
-
filePath,
|
|
131
|
-
packageName,
|
|
132
|
-
}) => {
|
|
133
|
-
const transformer = createQueryCacheTransformer({
|
|
134
|
-
jscodeshift,
|
|
135
|
-
utils,
|
|
136
|
-
root,
|
|
137
|
-
packageName,
|
|
138
|
-
})
|
|
139
|
-
const replacer = createKeyReplacer({ jscodeshift, root, filePath })
|
|
140
|
-
|
|
141
|
-
transformer.execute(replacer)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = (file, api) => {
|
|
145
|
-
const jscodeshift = api.jscodeshift
|
|
146
|
-
const root = jscodeshift(file.source)
|
|
147
|
-
|
|
148
|
-
// TODO: Execute the transformers only when it contains a `react-query` import!
|
|
149
|
-
|
|
150
|
-
const utils = createUtilsObject({ root, jscodeshift })
|
|
151
|
-
const filePath = file.path
|
|
152
|
-
const packageName = 'react-query'
|
|
153
|
-
|
|
154
|
-
// This function transforms usages like `useQuery` and `useMutation`.
|
|
155
|
-
transformUseQueryLikeUsages({
|
|
156
|
-
jscodeshift,
|
|
157
|
-
utils,
|
|
158
|
-
root,
|
|
159
|
-
filePath,
|
|
160
|
-
packageName,
|
|
161
|
-
})
|
|
162
|
-
// This function transforms usages of `useQueries`.
|
|
163
|
-
transformUseQueriesUsages({
|
|
164
|
-
jscodeshift,
|
|
165
|
-
utils,
|
|
166
|
-
root,
|
|
167
|
-
packageName,
|
|
168
|
-
})
|
|
169
|
-
// This function transforms usages of `QueryClient`.
|
|
170
|
-
transformQueryClientUsages({
|
|
171
|
-
jscodeshift,
|
|
172
|
-
utils,
|
|
173
|
-
root,
|
|
174
|
-
filePath,
|
|
175
|
-
packageName,
|
|
176
|
-
})
|
|
177
|
-
// This function transforms usages of `QueryCache`.
|
|
178
|
-
transformQueryCacheUsages({ jscodeshift, utils, root, filePath, packageName })
|
|
179
|
-
|
|
180
|
-
return root.toSource({ quote: 'single', lineTerminator: '\n' })
|
|
181
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module.exports = (file, api) => {
|
|
2
|
-
const jscodeshift = api.jscodeshift
|
|
3
|
-
const root = jscodeshift(file.source)
|
|
4
|
-
|
|
5
|
-
const replacements = [
|
|
6
|
-
{ from: 'react-query', to: '@tanstack/react-query' },
|
|
7
|
-
{ from: 'react-query/devtools', to: '@tanstack/react-query-devtools' },
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
replacements.forEach(({ from, to }) => {
|
|
11
|
-
root
|
|
12
|
-
.find(jscodeshift.ImportDeclaration, {
|
|
13
|
-
source: {
|
|
14
|
-
value: from,
|
|
15
|
-
},
|
|
16
|
-
})
|
|
17
|
-
.replaceWith(({ node }) => {
|
|
18
|
-
node.source.value = to
|
|
19
|
-
|
|
20
|
-
return node
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
return root.toSource({ quote: 'single', lineTerminator: '\n' })
|
|
25
|
-
}
|