@tanstack/preact-query 0.0.1 → 5.91.0

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.
Files changed (338) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -45
  3. package/build/codemods/src/utils/index.cjs +208 -0
  4. package/build/codemods/src/utils/transformers/query-cache-transformer.cjs +124 -0
  5. package/build/codemods/src/utils/transformers/query-client-transformer.cjs +53 -0
  6. package/build/codemods/src/utils/transformers/use-query-like-transformer.cjs +38 -0
  7. package/build/codemods/src/v4/key-transformation.cjs +181 -0
  8. package/build/codemods/src/v4/replace-import-specifier.cjs +25 -0
  9. package/build/codemods/src/v4/utils/replacers/key-replacer.cjs +164 -0
  10. package/build/codemods/src/v5/is-loading/is-loading.cjs +244 -0
  11. package/build/codemods/src/v5/keep-previous-data/README.md +32 -0
  12. package/build/codemods/src/v5/keep-previous-data/keep-previous-data.cjs +271 -0
  13. package/build/codemods/src/v5/keep-previous-data/utils/already-has-placeholder-data-property.cjs +26 -0
  14. package/build/codemods/src/v5/remove-overloads/remove-overloads.cjs +58 -0
  15. package/build/codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs +271 -0
  16. package/build/codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs +185 -0
  17. package/build/codemods/src/v5/remove-overloads/utils/index.cjs +123 -0
  18. package/build/codemods/src/v5/remove-overloads/utils/unknown-usage-error.cjs +27 -0
  19. package/build/codemods/src/v5/rename-hydrate/rename-hydrate.cjs +55 -0
  20. package/build/codemods/src/v5/rename-properties/rename-properties.cjs +41 -0
  21. package/build/legacy/HydrationBoundary.cjs +80 -0
  22. package/build/legacy/HydrationBoundary.cjs.map +1 -0
  23. package/build/legacy/HydrationBoundary.d.cts +14 -0
  24. package/build/legacy/HydrationBoundary.d.ts +14 -0
  25. package/build/legacy/HydrationBoundary.js +55 -0
  26. package/build/legacy/HydrationBoundary.js.map +1 -0
  27. package/build/legacy/IsRestoringProvider.cjs +37 -0
  28. package/build/legacy/IsRestoringProvider.cjs.map +1 -0
  29. package/build/legacy/IsRestoringProvider.d.cts +6 -0
  30. package/build/legacy/IsRestoringProvider.d.ts +6 -0
  31. package/build/legacy/IsRestoringProvider.js +11 -0
  32. package/build/legacy/IsRestoringProvider.js.map +1 -0
  33. package/build/legacy/QueryClientProvider.cjs +62 -0
  34. package/build/legacy/QueryClientProvider.cjs.map +1 -0
  35. package/build/legacy/QueryClientProvider.d.cts +13 -0
  36. package/build/legacy/QueryClientProvider.d.ts +13 -0
  37. package/build/legacy/QueryClientProvider.js +35 -0
  38. package/build/legacy/QueryClientProvider.js.map +1 -0
  39. package/build/legacy/QueryErrorResetBoundary.cjs +57 -0
  40. package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -0
  41. package/build/legacy/QueryErrorResetBoundary.d.cts +19 -0
  42. package/build/legacy/QueryErrorResetBoundary.d.ts +19 -0
  43. package/build/legacy/QueryErrorResetBoundary.js +31 -0
  44. package/build/legacy/QueryErrorResetBoundary.js.map +1 -0
  45. package/build/legacy/errorBoundaryUtils.cjs +57 -0
  46. package/build/legacy/errorBoundaryUtils.cjs.map +1 -0
  47. package/build/legacy/errorBoundaryUtils.d.cts +15 -0
  48. package/build/legacy/errorBoundaryUtils.d.ts +15 -0
  49. package/build/legacy/errorBoundaryUtils.js +30 -0
  50. package/build/legacy/errorBoundaryUtils.js.map +1 -0
  51. package/build/legacy/index.cjs +97 -0
  52. package/build/legacy/index.cjs.map +1 -0
  53. package/build/legacy/index.d.cts +21 -0
  54. package/build/legacy/index.d.ts +21 -0
  55. package/build/legacy/index.js +54 -0
  56. package/build/legacy/index.js.map +1 -0
  57. package/build/legacy/infiniteQueryOptions.cjs +33 -0
  58. package/build/legacy/infiniteQueryOptions.cjs.map +1 -0
  59. package/build/legacy/infiniteQueryOptions.d.cts +23 -0
  60. package/build/legacy/infiniteQueryOptions.d.ts +23 -0
  61. package/build/legacy/infiniteQueryOptions.js +8 -0
  62. package/build/legacy/infiniteQueryOptions.js.map +1 -0
  63. package/build/legacy/mutationOptions.cjs +33 -0
  64. package/build/legacy/mutationOptions.cjs.map +1 -0
  65. package/build/legacy/mutationOptions.d.cts +7 -0
  66. package/build/legacy/mutationOptions.d.ts +7 -0
  67. package/build/legacy/mutationOptions.js +8 -0
  68. package/build/legacy/mutationOptions.js.map +1 -0
  69. package/build/legacy/queryOptions.cjs +33 -0
  70. package/build/legacy/queryOptions.cjs.map +1 -0
  71. package/build/legacy/queryOptions.d.cts +24 -0
  72. package/build/legacy/queryOptions.d.ts +24 -0
  73. package/build/legacy/queryOptions.js +8 -0
  74. package/build/legacy/queryOptions.js.map +1 -0
  75. package/build/legacy/suspense.cjs +58 -0
  76. package/build/legacy/suspense.cjs.map +1 -0
  77. package/build/legacy/suspense.d.cts +11 -0
  78. package/build/legacy/suspense.d.ts +11 -0
  79. package/build/legacy/suspense.js +29 -0
  80. package/build/legacy/suspense.js.map +1 -0
  81. package/build/legacy/types.cjs +19 -0
  82. package/build/legacy/types.cjs.map +1 -0
  83. package/build/legacy/types.d.cts +52 -0
  84. package/build/legacy/types.d.ts +52 -0
  85. package/build/legacy/types.js +1 -0
  86. package/build/legacy/types.js.map +1 -0
  87. package/build/legacy/useBaseQuery.cjs +121 -0
  88. package/build/legacy/useBaseQuery.cjs.map +1 -0
  89. package/build/legacy/useBaseQuery.d.cts +6 -0
  90. package/build/legacy/useBaseQuery.d.ts +6 -0
  91. package/build/legacy/useBaseQuery.js +105 -0
  92. package/build/legacy/useBaseQuery.js.map +1 -0
  93. package/build/legacy/useInfiniteQuery.cjs +39 -0
  94. package/build/legacy/useInfiniteQuery.cjs.map +1 -0
  95. package/build/legacy/useInfiniteQuery.d.cts +9 -0
  96. package/build/legacy/useInfiniteQuery.d.ts +9 -0
  97. package/build/legacy/useInfiniteQuery.js +14 -0
  98. package/build/legacy/useInfiniteQuery.js.map +1 -0
  99. package/build/legacy/useIsFetching.cjs +45 -0
  100. package/build/legacy/useIsFetching.cjs.map +1 -0
  101. package/build/legacy/useIsFetching.d.cts +5 -0
  102. package/build/legacy/useIsFetching.d.ts +5 -0
  103. package/build/legacy/useIsFetching.js +20 -0
  104. package/build/legacy/useIsFetching.js.map +1 -0
  105. package/build/legacy/useMutation.cjs +63 -0
  106. package/build/legacy/useMutation.cjs.map +1 -0
  107. package/build/legacy/useMutation.d.cts +6 -0
  108. package/build/legacy/useMutation.d.ts +6 -0
  109. package/build/legacy/useMutation.js +43 -0
  110. package/build/legacy/useMutation.js.map +1 -0
  111. package/build/legacy/useMutationState.cjs +75 -0
  112. package/build/legacy/useMutationState.cjs.map +1 -0
  113. package/build/legacy/useMutationState.d.cts +10 -0
  114. package/build/legacy/useMutationState.d.ts +10 -0
  115. package/build/legacy/useMutationState.js +49 -0
  116. package/build/legacy/useMutationState.js.map +1 -0
  117. package/build/legacy/usePrefetchInfiniteQuery.cjs +37 -0
  118. package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -0
  119. package/build/legacy/usePrefetchInfiniteQuery.d.cts +5 -0
  120. package/build/legacy/usePrefetchInfiniteQuery.d.ts +5 -0
  121. package/build/legacy/usePrefetchInfiniteQuery.js +12 -0
  122. package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -0
  123. package/build/legacy/usePrefetchQuery.cjs +37 -0
  124. package/build/legacy/usePrefetchQuery.cjs.map +1 -0
  125. package/build/legacy/usePrefetchQuery.d.cts +6 -0
  126. package/build/legacy/usePrefetchQuery.d.ts +6 -0
  127. package/build/legacy/usePrefetchQuery.js +12 -0
  128. package/build/legacy/usePrefetchQuery.js.map +1 -0
  129. package/build/legacy/useQueries.cjs +120 -0
  130. package/build/legacy/useQueries.cjs.map +1 -0
  131. package/build/legacy/useQueries.d.cts +76 -0
  132. package/build/legacy/useQueries.d.ts +76 -0
  133. package/build/legacy/useQueries.js +109 -0
  134. package/build/legacy/useQueries.js.map +1 -0
  135. package/build/legacy/useQuery.cjs +35 -0
  136. package/build/legacy/useQuery.cjs.map +1 -0
  137. package/build/legacy/useQuery.d.cts +9 -0
  138. package/build/legacy/useQuery.d.ts +9 -0
  139. package/build/legacy/useQuery.js +10 -0
  140. package/build/legacy/useQuery.js.map +1 -0
  141. package/build/legacy/useSuspenseInfiniteQuery.cjs +50 -0
  142. package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -0
  143. package/build/legacy/useSuspenseInfiniteQuery.d.cts +6 -0
  144. package/build/legacy/useSuspenseInfiniteQuery.d.ts +6 -0
  145. package/build/legacy/useSuspenseInfiniteQuery.js +25 -0
  146. package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -0
  147. package/build/legacy/useSuspenseQueries.cjs +55 -0
  148. package/build/legacy/useSuspenseQueries.cjs.map +1 -0
  149. package/build/legacy/useSuspenseQueries.d.cts +79 -0
  150. package/build/legacy/useSuspenseQueries.d.ts +79 -0
  151. package/build/legacy/useSuspenseQueries.js +30 -0
  152. package/build/legacy/useSuspenseQueries.js.map +1 -0
  153. package/build/legacy/useSuspenseQuery.cjs +51 -0
  154. package/build/legacy/useSuspenseQuery.cjs.map +1 -0
  155. package/build/legacy/useSuspenseQuery.d.cts +6 -0
  156. package/build/legacy/useSuspenseQuery.d.ts +6 -0
  157. package/build/legacy/useSuspenseQuery.js +26 -0
  158. package/build/legacy/useSuspenseQuery.js.map +1 -0
  159. package/build/legacy/utils.cjs +79 -0
  160. package/build/legacy/utils.cjs.map +1 -0
  161. package/build/legacy/utils.d.cts +4 -0
  162. package/build/legacy/utils.d.ts +4 -0
  163. package/build/legacy/utils.js +53 -0
  164. package/build/legacy/utils.js.map +1 -0
  165. package/build/modern/HydrationBoundary.cjs +80 -0
  166. package/build/modern/HydrationBoundary.cjs.map +1 -0
  167. package/build/modern/HydrationBoundary.d.cts +14 -0
  168. package/build/modern/HydrationBoundary.d.ts +14 -0
  169. package/build/modern/HydrationBoundary.js +55 -0
  170. package/build/modern/HydrationBoundary.js.map +1 -0
  171. package/build/modern/IsRestoringProvider.cjs +37 -0
  172. package/build/modern/IsRestoringProvider.cjs.map +1 -0
  173. package/build/modern/IsRestoringProvider.d.cts +6 -0
  174. package/build/modern/IsRestoringProvider.d.ts +6 -0
  175. package/build/modern/IsRestoringProvider.js +11 -0
  176. package/build/modern/IsRestoringProvider.js.map +1 -0
  177. package/build/modern/QueryClientProvider.cjs +62 -0
  178. package/build/modern/QueryClientProvider.cjs.map +1 -0
  179. package/build/modern/QueryClientProvider.d.cts +13 -0
  180. package/build/modern/QueryClientProvider.d.ts +13 -0
  181. package/build/modern/QueryClientProvider.js +35 -0
  182. package/build/modern/QueryClientProvider.js.map +1 -0
  183. package/build/modern/QueryErrorResetBoundary.cjs +57 -0
  184. package/build/modern/QueryErrorResetBoundary.cjs.map +1 -0
  185. package/build/modern/QueryErrorResetBoundary.d.cts +19 -0
  186. package/build/modern/QueryErrorResetBoundary.d.ts +19 -0
  187. package/build/modern/QueryErrorResetBoundary.js +31 -0
  188. package/build/modern/QueryErrorResetBoundary.js.map +1 -0
  189. package/build/modern/errorBoundaryUtils.cjs +57 -0
  190. package/build/modern/errorBoundaryUtils.cjs.map +1 -0
  191. package/build/modern/errorBoundaryUtils.d.cts +15 -0
  192. package/build/modern/errorBoundaryUtils.d.ts +15 -0
  193. package/build/modern/errorBoundaryUtils.js +30 -0
  194. package/build/modern/errorBoundaryUtils.js.map +1 -0
  195. package/build/modern/index.cjs +97 -0
  196. package/build/modern/index.cjs.map +1 -0
  197. package/build/modern/index.d.cts +21 -0
  198. package/build/modern/index.d.ts +21 -0
  199. package/build/modern/index.js +54 -0
  200. package/build/modern/index.js.map +1 -0
  201. package/build/modern/infiniteQueryOptions.cjs +33 -0
  202. package/build/modern/infiniteQueryOptions.cjs.map +1 -0
  203. package/build/modern/infiniteQueryOptions.d.cts +23 -0
  204. package/build/modern/infiniteQueryOptions.d.ts +23 -0
  205. package/build/modern/infiniteQueryOptions.js +8 -0
  206. package/build/modern/infiniteQueryOptions.js.map +1 -0
  207. package/build/modern/mutationOptions.cjs +33 -0
  208. package/build/modern/mutationOptions.cjs.map +1 -0
  209. package/build/modern/mutationOptions.d.cts +7 -0
  210. package/build/modern/mutationOptions.d.ts +7 -0
  211. package/build/modern/mutationOptions.js +8 -0
  212. package/build/modern/mutationOptions.js.map +1 -0
  213. package/build/modern/queryOptions.cjs +33 -0
  214. package/build/modern/queryOptions.cjs.map +1 -0
  215. package/build/modern/queryOptions.d.cts +24 -0
  216. package/build/modern/queryOptions.d.ts +24 -0
  217. package/build/modern/queryOptions.js +8 -0
  218. package/build/modern/queryOptions.js.map +1 -0
  219. package/build/modern/suspense.cjs +58 -0
  220. package/build/modern/suspense.cjs.map +1 -0
  221. package/build/modern/suspense.d.cts +11 -0
  222. package/build/modern/suspense.d.ts +11 -0
  223. package/build/modern/suspense.js +29 -0
  224. package/build/modern/suspense.js.map +1 -0
  225. package/build/modern/types.cjs +19 -0
  226. package/build/modern/types.cjs.map +1 -0
  227. package/build/modern/types.d.cts +52 -0
  228. package/build/modern/types.d.ts +52 -0
  229. package/build/modern/types.js +1 -0
  230. package/build/modern/types.js.map +1 -0
  231. package/build/modern/useBaseQuery.cjs +118 -0
  232. package/build/modern/useBaseQuery.cjs.map +1 -0
  233. package/build/modern/useBaseQuery.d.cts +6 -0
  234. package/build/modern/useBaseQuery.d.ts +6 -0
  235. package/build/modern/useBaseQuery.js +102 -0
  236. package/build/modern/useBaseQuery.js.map +1 -0
  237. package/build/modern/useInfiniteQuery.cjs +39 -0
  238. package/build/modern/useInfiniteQuery.cjs.map +1 -0
  239. package/build/modern/useInfiniteQuery.d.cts +9 -0
  240. package/build/modern/useInfiniteQuery.d.ts +9 -0
  241. package/build/modern/useInfiniteQuery.js +14 -0
  242. package/build/modern/useInfiniteQuery.js.map +1 -0
  243. package/build/modern/useIsFetching.cjs +45 -0
  244. package/build/modern/useIsFetching.cjs.map +1 -0
  245. package/build/modern/useIsFetching.d.cts +5 -0
  246. package/build/modern/useIsFetching.d.ts +5 -0
  247. package/build/modern/useIsFetching.js +20 -0
  248. package/build/modern/useIsFetching.js.map +1 -0
  249. package/build/modern/useMutation.cjs +63 -0
  250. package/build/modern/useMutation.cjs.map +1 -0
  251. package/build/modern/useMutation.d.cts +6 -0
  252. package/build/modern/useMutation.d.ts +6 -0
  253. package/build/modern/useMutation.js +43 -0
  254. package/build/modern/useMutation.js.map +1 -0
  255. package/build/modern/useMutationState.cjs +75 -0
  256. package/build/modern/useMutationState.cjs.map +1 -0
  257. package/build/modern/useMutationState.d.cts +10 -0
  258. package/build/modern/useMutationState.d.ts +10 -0
  259. package/build/modern/useMutationState.js +49 -0
  260. package/build/modern/useMutationState.js.map +1 -0
  261. package/build/modern/usePrefetchInfiniteQuery.cjs +37 -0
  262. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -0
  263. package/build/modern/usePrefetchInfiniteQuery.d.cts +5 -0
  264. package/build/modern/usePrefetchInfiniteQuery.d.ts +5 -0
  265. package/build/modern/usePrefetchInfiniteQuery.js +12 -0
  266. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -0
  267. package/build/modern/usePrefetchQuery.cjs +37 -0
  268. package/build/modern/usePrefetchQuery.cjs.map +1 -0
  269. package/build/modern/usePrefetchQuery.d.cts +6 -0
  270. package/build/modern/usePrefetchQuery.d.ts +6 -0
  271. package/build/modern/usePrefetchQuery.js +12 -0
  272. package/build/modern/usePrefetchQuery.js.map +1 -0
  273. package/build/modern/useQueries.cjs +120 -0
  274. package/build/modern/useQueries.cjs.map +1 -0
  275. package/build/modern/useQueries.d.cts +76 -0
  276. package/build/modern/useQueries.d.ts +76 -0
  277. package/build/modern/useQueries.js +109 -0
  278. package/build/modern/useQueries.js.map +1 -0
  279. package/build/modern/useQuery.cjs +35 -0
  280. package/build/modern/useQuery.cjs.map +1 -0
  281. package/build/modern/useQuery.d.cts +9 -0
  282. package/build/modern/useQuery.d.ts +9 -0
  283. package/build/modern/useQuery.js +10 -0
  284. package/build/modern/useQuery.js.map +1 -0
  285. package/build/modern/useSuspenseInfiniteQuery.cjs +50 -0
  286. package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -0
  287. package/build/modern/useSuspenseInfiniteQuery.d.cts +6 -0
  288. package/build/modern/useSuspenseInfiniteQuery.d.ts +6 -0
  289. package/build/modern/useSuspenseInfiniteQuery.js +25 -0
  290. package/build/modern/useSuspenseInfiniteQuery.js.map +1 -0
  291. package/build/modern/useSuspenseQueries.cjs +55 -0
  292. package/build/modern/useSuspenseQueries.cjs.map +1 -0
  293. package/build/modern/useSuspenseQueries.d.cts +79 -0
  294. package/build/modern/useSuspenseQueries.d.ts +79 -0
  295. package/build/modern/useSuspenseQueries.js +30 -0
  296. package/build/modern/useSuspenseQueries.js.map +1 -0
  297. package/build/modern/useSuspenseQuery.cjs +51 -0
  298. package/build/modern/useSuspenseQuery.cjs.map +1 -0
  299. package/build/modern/useSuspenseQuery.d.cts +6 -0
  300. package/build/modern/useSuspenseQuery.d.ts +6 -0
  301. package/build/modern/useSuspenseQuery.js +26 -0
  302. package/build/modern/useSuspenseQuery.js.map +1 -0
  303. package/build/modern/utils.cjs +79 -0
  304. package/build/modern/utils.cjs.map +1 -0
  305. package/build/modern/utils.d.cts +4 -0
  306. package/build/modern/utils.d.ts +4 -0
  307. package/build/modern/utils.js +53 -0
  308. package/build/modern/utils.js.map +1 -0
  309. package/build/query-codemods/eslint.config.js +18 -0
  310. package/build/query-codemods/package.json +38 -0
  311. package/build/query-codemods/root.eslint.config.js +64 -0
  312. package/build/query-codemods/tsconfig.json +8 -0
  313. package/build/query-codemods/vite.config.ts +30 -0
  314. package/package.json +82 -8
  315. package/src/HydrationBoundary.tsx +108 -0
  316. package/src/IsRestoringProvider.ts +7 -0
  317. package/src/QueryClientProvider.tsx +45 -0
  318. package/src/QueryErrorResetBoundary.tsx +57 -0
  319. package/src/errorBoundaryUtils.ts +76 -0
  320. package/src/index.ts +56 -0
  321. package/src/infiniteQueryOptions.ts +150 -0
  322. package/src/mutationOptions.ts +42 -0
  323. package/src/queryOptions.ts +88 -0
  324. package/src/suspense.ts +81 -0
  325. package/src/types.ts +241 -0
  326. package/src/useBaseQuery.ts +169 -0
  327. package/src/useInfiniteQuery.ts +81 -0
  328. package/src/useIsFetching.ts +23 -0
  329. package/src/useMutation.ts +69 -0
  330. package/src/useMutationState.ts +74 -0
  331. package/src/usePrefetchInfiniteQuery.tsx +31 -0
  332. package/src/usePrefetchQuery.tsx +20 -0
  333. package/src/useQueries.ts +331 -0
  334. package/src/useQuery.ts +52 -0
  335. package/src/useSuspenseInfiniteQuery.ts +50 -0
  336. package/src/useSuspenseQueries.ts +211 -0
  337. package/src/useSuspenseQuery.ts +34 -0
  338. package/src/utils.ts +88 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Tanner Linsley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,48 @@
1
- # @tanstack/preact-query
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@tanstack/preact-query`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
1
+ <img src="https://static.scarf.sh/a.png?x-pxid=be2d8a11-9712-4c1d-9963-580b2d4fb133" />
2
+
3
+ ![TanStack Query Header](https://github.com/TanStack/query/raw/main/media/repo-header.png)
4
+
5
+ Hooks for fetching, caching and updating asynchronous data in Preact
6
+
7
+ <a href="https://twitter.com/intent/tweet?button_hashtag=TanStack" target="\_parent">
8
+ <img alt="#TanStack" src="https://img.shields.io/twitter/url?color=%2308a0e9&label=%23TanStack&style=social&url=https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Fbutton_hashtag%3DTanStack">
9
+ </a><a href="https://discord.com/invite/WrRKjPJ" target="\_parent">
10
+ <img alt="" src="https://img.shields.io/badge/Discord-TanStack-%235865F2" />
11
+ </a><a href="https://github.com/TanStack/query/actions?query=workflow%3A%22preact-query+tests%22">
12
+ <img src="https://github.com/TanStack/query/workflows/preact-query%20tests/badge.svg" />
13
+ </a><a href="https://www.npmjs.com/package/@tanstack/query-core" target="\_parent">
14
+ <img alt="" src="https://img.shields.io/npm/dm/@tanstack/query-core.svg" />
15
+ </a><a href="https://bundlejs.com/?q=%40tanstack%2Fpreact-query&config=%7B%22esbuild%22%3A%7B%22external%22%3A%5B%22react%22%2C%22react-dom%22%5D%7D%7D&badge=" target="\_parent">
16
+ <img alt="" src="https://deno.bundlejs.com/?q=@tanstack/preact-query&config={%22esbuild%22:{%22external%22:[%22react%22,%22react-dom%22]}}&badge=detailed" />
17
+ </a><a href="#badge">
18
+ <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
19
+ </a><a href="https://github.com/TanStack/query/discussions">
20
+ <img alt="Join the discussion on Github" src="https://img.shields.io/badge/Github%20Discussions%20%26%20Support-Chat%20now!-blue" />
21
+ </a><a href="https://bestofjs.org/projects/tanstack-query"><img alt="Best of JS" src="https://img.shields.io/endpoint?url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=TanStack%2Fquery%26since=daily" /></a><a href="https://github.com/TanStack/query/" target="\_parent">
22
+ <img alt="" src="https://img.shields.io/github/stars/TanStack/query.svg?style=social&label=Star" />
23
+ </a><a href="https://twitter.com/tannerlinsley" target="\_parent">
24
+ <img alt="" src="https://img.shields.io/twitter/follow/tannerlinsley.svg?style=social&label=Follow" />
25
+ </a> <a href="https://gitpod.io/from-referrer/">
26
+ <img src="https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod" alt="Gitpod Ready-to-Code"/>
27
+ </a>
28
+
29
+ Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [TanStack Table](https://github.com/TanStack/table), [TanStack Router](https://github.com/tanstack/router), [TanStack Virtual](https://github.com/tanstack/virtual), [React Charts](https://github.com/TanStack/react-charts), [React Ranger](https://github.com/TanStack/ranger)
30
+
31
+ ## Visit [tanstack.com/query](https://tanstack.com/query) for docs, guides, API and more!
32
+
33
+ ## Quick Features
34
+
35
+ - Transport/protocol/backend agnostic data fetching (REST, GraphQL, promises, whatever!)
36
+ - Auto Caching + Refetching (stale-while-revalidate, Window Refocus, Polling/Realtime)
37
+ - Parallel + Dependent Queries
38
+ - Mutations + Reactive Query Refetching
39
+ - Multi-layer Cache + Automatic Garbage Collection
40
+ - Paginated + Cursor-based Queries
41
+ - Load-More + Infinite Scroll Queries w/ Scroll Recovery
42
+ - Request Cancellation
43
+ - [Preact Suspense](https://preactjs.com/guide/v10/api-reference/#suspense) + Fetch-As-You-Render Query Prefetching -- Though not recommended because of the bulk preact/compat adds
44
+ - Dedicated Devtools
45
+
46
+ ### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
47
+
48
+ <!-- Use the force, Luke -->
@@ -0,0 +1,208 @@
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
+ }
@@ -0,0 +1,124 @@
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
+ }
@@ -0,0 +1,53 @@
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
+ }
@@ -0,0 +1,38 @@
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
+ }