@tuyau/react-query 1.0.0-beta.1 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SchemaEndpoint, RawRequestArgs, TuyauRegistry, InferTree, AdonisEndpoint, InferRoutes } from '@tuyau/core/types';
2
2
  import * as _tanstack_react_query from '@tanstack/react-query';
3
- import { SkipToken, DataTag, QueryFilters, WithRequired as WithRequired$1, UseMutationOptions, InfiniteData, InfiniteQueryObserverOptions, DefinedInitialDataOptions, UndefinedInitialDataOptions, UnusedSkipTokenOptions, QueryClient } from '@tanstack/react-query';
3
+ import { SkipToken, DataTag, QueryFilters, WithRequired as WithRequired$1, UseMutationOptions, InfiniteData, InfiniteQueryObserverOptions, DefinedInitialDataOptions, UndefinedInitialDataOptions, UnusedSkipTokenOptions } from '@tanstack/react-query';
4
4
  import { Tuyau } from '@tuyau/core/client';
5
5
 
6
6
  type Response$2<E extends SchemaEndpoint> = E['types']['response'];
@@ -183,7 +183,6 @@ type TuyauReactQuery<R extends Record<string, SchemaEndpoint>> = TransformToReac
183
183
 
184
184
  declare function createTuyauReactQueryClient<Reg extends TuyauRegistry, Tree = InferTree<Reg>, Routes extends Record<string, AdonisEndpoint> = InferRoutes<Reg>>(options: {
185
185
  client: Tuyau<Reg, Routes>;
186
- queryClient: QueryClient | (() => QueryClient);
187
186
  globalOptions?: TuyauReactRequestOptions;
188
187
  }): TransformToReactQuery<Tree>;
189
188
 
package/build/index.js CHANGED
@@ -12,9 +12,23 @@ function buildKey(opts) {
12
12
  if (!request && type === "any") {
13
13
  return splitPath.length ? [splitPath] : [];
14
14
  }
15
- if (type === "infinite" && isObject(request) && ("direction" in request || "cursor" in request)) {
16
- const { cursor: _, direction: __, ...inputWithoutCursorAndDirection } = request;
17
- return [splitPath, { request: inputWithoutCursorAndDirection, type: "infinite" }];
15
+ if (type === "infinite" && isObject(request)) {
16
+ const query = request.query;
17
+ const body = request.body;
18
+ const hasCursorInQuery = isObject(query) && ("direction" in query || "cursor" in query);
19
+ const hasCursorInBody = isObject(body) && ("direction" in body || "cursor" in body);
20
+ if (hasCursorInQuery || hasCursorInBody) {
21
+ const cleanedRequest = { ...request };
22
+ if (hasCursorInQuery && isObject(query)) {
23
+ const { cursor: _, direction: __, ...cleanQuery } = query;
24
+ cleanedRequest.query = cleanQuery;
25
+ }
26
+ if (hasCursorInBody && isObject(body)) {
27
+ const { cursor: _, direction: __, ...cleanBody } = body;
28
+ cleanedRequest.body = cleanBody;
29
+ }
30
+ return [splitPath, { request: cleanedRequest, type: "infinite" }];
31
+ }
18
32
  }
19
33
  return [
20
34
  splitPath,
@@ -35,6 +49,7 @@ function tuyauQueryOptions(options) {
35
49
  const effectiveAbortOnUnmount = opts?.tuyau?.abortOnUnmount ?? globalOptions?.abortOnUnmount ?? false;
36
50
  return await client.request(routeName, {
37
51
  ...request,
52
+ retry: 0,
38
53
  ...effectiveAbortOnUnmount ? { signal: queryFnContext.signal } : {}
39
54
  });
40
55
  };
@@ -67,6 +82,7 @@ function tuyauInfiniteQueryOptions(options) {
67
82
  }
68
83
  return await client.request(routeName, {
69
84
  ...requestArgs,
85
+ retry: 0,
70
86
  ...effectiveAbortOnUnmount ? { signal: queryFnContext.signal } : {}
71
87
  });
72
88
  };
@@ -92,7 +108,7 @@ function tuyauMutationOptions(options) {
92
108
  const mutationKey = getMutationKeyInternal({ segments: routeName.split(".") });
93
109
  const mutationFn = async (request) => {
94
110
  const requestArgs = request || {};
95
- return await client.request(routeName, requestArgs);
111
+ return await client.request(routeName, { ...requestArgs, retry: 0 });
96
112
  };
97
113
  return mutationOptions({ ...opts, mutationKey, mutationFn });
98
114
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tuyau/react-query",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.1",
4
+ "version": "1.0.0-beta.2",
5
5
  "description": "React Query plugin for Tuyau",
6
6
  "author": "Julien Ripouteau <julien@ripouteau.com>",
7
7
  "license": "ISC",
@@ -21,15 +21,15 @@
21
21
  "@tuyau/core": "1.0.0-beta.2"
22
22
  },
23
23
  "devDependencies": {
24
- "@adonisjs/core": "^7.0.0-next.10",
24
+ "@adonisjs/core": "^7.0.0-next.13",
25
25
  "@faker-js/faker": "^10.1.0",
26
- "@happy-dom/global-registrator": "^20.0.10",
27
- "@tanstack/react-query": "^5.90.7",
26
+ "@happy-dom/global-registrator": "^20.0.11",
27
+ "@tanstack/react-query": "^5.90.12",
28
28
  "@testing-library/react": "^16.3.0",
29
- "@types/react": "^19.2.2",
29
+ "@types/react": "^19.2.7",
30
30
  "@vinejs/vine": "^4.1.0",
31
- "react": "^19.2.0",
32
- "@tuyau/core": "1.0.0-beta.4"
31
+ "react": "^19.2.1",
32
+ "@tuyau/core": "1.0.0-beta.6"
33
33
  },
34
34
  "tsup": {
35
35
  "entry": [