@tuyau/react-query 0.0.1-next.1 → 0.0.1-next.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
@@ -45,7 +45,7 @@ interface DecorateMutationFn<EDef extends EndpointDef, TParams = Record<string,
45
45
  /**
46
46
  * Output type for mutation options
47
47
  */
48
- interface TuyauMutationOptionsOut<TInput, TError, TOutput, TContext, TParams = Record<string, string | number>> extends UseMutationOptions<TOutput, TError, TInput extends undefined | {} | Record<string, never> ? {
48
+ interface TuyauMutationOptionsOut<TInput, TError, TOutput, TContext, TParams = Record<string, string | number>> extends UseMutationOptions<TOutput, TError, TInput extends undefined | {} | Record<string, never> | unknown ? {
49
49
  payload?: TInput;
50
50
  params?: TParams;
51
51
  } : {
@@ -163,7 +163,7 @@ type InferRequestType<Endpoint extends DecorateQueryFn<any> | DecorateMutationFn
163
163
  /**
164
164
  * Infer response type from an endpoint
165
165
  */
166
- type InferResponseType<Endpoint extends DecorateQueryFn<any> | DecorateMutationFn<any>> = Endpoint['~types']['response'];
166
+ type InferResponseType<Endpoint extends DecorateQueryFn<any> | DecorateMutationFn<any>> = Endpoint['~types']['response']['200'];
167
167
  /**
168
168
  * Tuyau-specific request options for React Query integration
169
169
  */
package/build/index.js CHANGED
@@ -82,11 +82,7 @@ function tuyauQueryOptions(options) {
82
82
  ...effectiveAbortOnUnmount ? { signal: queryFnContext.signal } : { signal: null }
83
83
  }
84
84
  };
85
- return await client.$fetch({
86
- paths: requestPath,
87
- input: payload,
88
- queryOptions: actualOpts
89
- });
85
+ return await client.$fetch({ paths: requestPath, input: payload, queryOptions: actualOpts });
90
86
  };
91
87
  return Object.assign(queryOptions({ ...opts, queryKey, queryFn }), {
92
88
  tuyau: { path, type: "query" }
@@ -139,11 +135,7 @@ function tuyauInfiniteQueryOptions(options) {
139
135
  ...effectiveAbortOnUnmount ? { signal: queryFnContext.signal } : { signal: null }
140
136
  }
141
137
  };
142
- return await client.$fetch({
143
- paths: requestPath,
144
- input: payload,
145
- queryOptions: actualOpts
146
- });
138
+ return await client.$fetch({ paths: requestPath, input: payload, queryOptions: actualOpts });
147
139
  };
148
140
  return Object.assign(
149
141
  infiniteQueryOptions({
@@ -157,16 +149,13 @@ function tuyauInfiniteQueryOptions(options) {
157
149
  }
158
150
 
159
151
  // src/mutation.ts
152
+ import {
153
+ mutationOptions
154
+ } from "@tanstack/react-query";
160
155
  function getMutationKeyInternal(path) {
161
156
  const splitPath = path.flatMap((part) => part.toString().split("."));
162
157
  return splitPath.length ? [splitPath] : [];
163
158
  }
164
- function createTuyauOptionsResult(opts) {
165
- return {
166
- path: opts.path,
167
- type: "mutation"
168
- };
169
- }
170
159
  function tuyauMutationOptions(args) {
171
160
  const { opts, path, client, overrides } = args;
172
161
  const queryClient = unwrapLazyArg(args.queryClient);
@@ -179,23 +168,20 @@ function tuyauMutationOptions(args) {
179
168
  const requestPath = buildRequestPath(path, input.params);
180
169
  return await client.$fetch({ paths: requestPath, input: input.payload });
181
170
  };
182
- return {
183
- ...opts,
184
- mutationKey,
185
- mutationFn,
186
- onSuccess(data, variables, context) {
187
- const originalFn = () => {
188
- if (opts?.onSuccess) return opts.onSuccess(data, variables, context);
189
- if (defaultOpts?.onSuccess) return defaultOpts.onSuccess(data, variables, context);
190
- };
191
- return mutationSuccessOverride({
192
- originalFn,
193
- queryClient,
194
- meta: opts?.meta ?? defaultOpts?.meta ?? {}
195
- });
196
- },
197
- tuyau: createTuyauOptionsResult({ path })
171
+ const onSuccess = (data, variables, context) => {
172
+ const originalFn = () => {
173
+ if (opts?.onSuccess) return opts.onSuccess(data, variables, context);
174
+ if (defaultOpts?.onSuccess) return defaultOpts.onSuccess(data, variables, context);
175
+ };
176
+ return mutationSuccessOverride({
177
+ originalFn,
178
+ queryClient,
179
+ meta: opts?.meta ?? defaultOpts?.meta ?? {}
180
+ });
198
181
  };
182
+ return Object.assign(mutationOptions({ ...opts, mutationKey, mutationFn, onSuccess }), {
183
+ tuyau: { path, type: "mutation" }
184
+ });
199
185
  }
200
186
 
201
187
  // src/main.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tuyau/react-query",
3
3
  "type": "module",
4
- "version": "0.0.1-next.1",
4
+ "version": "0.0.1-next.2",
5
5
  "description": "React Query plugin for Tuyau",
6
6
  "author": "Julien Ripouteau <julien@ripouteau.com>",
7
7
  "license": "ISC",
@@ -21,13 +21,13 @@
21
21
  "@tuyau/utils": "0.0.9"
22
22
  },
23
23
  "devDependencies": {
24
- "@adonisjs/core": "^6.18.0",
25
- "@happy-dom/global-registrator": "^17.4.7",
26
- "@tanstack/react-query": "^5.76.1",
24
+ "@adonisjs/core": "^6.19.0",
25
+ "@happy-dom/global-registrator": "^17.6.3",
26
+ "@tanstack/react-query": "^5.83.0",
27
27
  "@testing-library/react": "^16.3.0",
28
- "@types/react": "^19.1.4",
28
+ "@types/react": "^19.1.8",
29
29
  "@vinejs/vine": "^3.0.1",
30
- "nock": "^14.0.4",
30
+ "nock": "^14.0.6",
31
31
  "react": "^19.1.0",
32
32
  "@tuyau/client": "0.2.11-next.2"
33
33
  },