@navios/react-query 0.6.1 → 0.7.1
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 +47 -0
- package/README.md +142 -41
- package/dist/src/client/declare-client.d.mts.map +1 -1
- package/dist/src/mutation/make-hook.d.mts +3 -1
- package/dist/src/mutation/make-hook.d.mts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/index.cjs +412 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +961 -0
- package/lib/index.d.cts.map +1 -0
- package/lib/index.d.mts +961 -34
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +389 -350
- package/lib/index.mjs.map +1 -1
- package/package.json +8 -8
- package/project.json +2 -2
- package/src/__tests__/declare-client.spec.mts +2 -2
- package/src/__tests__/make-mutation.spec.mts +10 -9
- package/src/client/declare-client.mts +28 -6
- package/src/mutation/make-hook.mts +3 -11
- package/{tsup.config.mts → tsdown.config.mts} +4 -3
- package/dist/src/declare-client.d.mts +0 -31
- package/dist/src/declare-client.d.mts.map +0 -1
- package/dist/src/make-infinite-query-options.d.mts +0 -13
- package/dist/src/make-infinite-query-options.d.mts.map +0 -1
- package/dist/src/make-mutation.d.mts +0 -15
- package/dist/src/make-mutation.d.mts.map +0 -1
- package/dist/src/make-query-options.d.mts +0 -15
- package/dist/src/make-query-options.d.mts.map +0 -1
- package/dist/src/types/client-endpoint-helper.d.mts +0 -8
- package/dist/src/types/client-endpoint-helper.d.mts.map +0 -1
- package/dist/src/types/client-instance.d.mts +0 -211
- package/dist/src/types/client-instance.d.mts.map +0 -1
- package/dist/src/types/index.d.mts +0 -8
- package/dist/src/types/index.d.mts.map +0 -1
- package/dist/src/types/mutation-args.d.mts +0 -10
- package/dist/src/types/mutation-args.d.mts.map +0 -1
- package/dist/src/types/mutation-helpers.d.mts +0 -10
- package/dist/src/types/mutation-helpers.d.mts.map +0 -1
- package/dist/src/types/query-args.d.mts +0 -8
- package/dist/src/types/query-args.d.mts.map +0 -1
- package/dist/src/types/query-helpers.d.mts +0 -14
- package/dist/src/types/query-helpers.d.mts.map +0 -1
- package/dist/src/types/query-url-params-args.d.mts +0 -5
- package/dist/src/types/query-url-params-args.d.mts.map +0 -1
- package/dist/src/types.d.mts +0 -49
- package/dist/src/types.d.mts.map +0 -1
- package/dist/src/utils/mutation-key.creator.d.mts +0 -39
- package/dist/src/utils/mutation-key.creator.d.mts.map +0 -1
- package/dist/src/utils/query-key-creator.d.mts +0 -24
- package/dist/src/utils/query-key-creator.d.mts.map +0 -1
- package/lib/_tsup-dts-rollup.d.mts +0 -1097
- package/lib/_tsup-dts-rollup.d.ts +0 -1097
- package/lib/index.d.ts +0 -34
- package/lib/index.js +0 -375
- package/lib/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.7.1] - 2025-12-20
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Fixed package.json exports to use correct CommonJS file extensions (`.cjs` and `.d.cts`)
|
|
8
|
+
|
|
9
|
+
## [0.7.0] - 2025-12-18
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Fixed `mutationFromEndpoint` callback signatures** - The `mutationFromEndpoint` method now uses the correct callback signature `(data, variables, context)` instead of the deprecated `(queryClient, data, variables, context)`. This makes it consistent with the main `mutation` API introduced in 0.6.0.
|
|
14
|
+
|
|
15
|
+
**Before:**
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
client.mutationFromEndpoint(endpoint, {
|
|
19
|
+
onSuccess: (queryClient, data, variables, context) => {
|
|
20
|
+
queryClient.invalidateQueries({ queryKey: ['users'] })
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**After:**
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
client.mutationFromEndpoint(endpoint, {
|
|
29
|
+
useContext: () => {
|
|
30
|
+
const queryClient = useQueryClient()
|
|
31
|
+
return { queryClient }
|
|
32
|
+
},
|
|
33
|
+
onSuccess: (data, variables, context) => {
|
|
34
|
+
context.queryClient.invalidateQueries({ queryKey: ['users'] })
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
|
|
41
|
+
- **Documentation improvements** - Added comprehensive documentation for:
|
|
42
|
+
- `onFail` callback for query error handling
|
|
43
|
+
- `defaults` option in `declareClient` for setting default `keyPrefix` and `keySuffix`
|
|
44
|
+
- `keyPrefix` and `keySuffix` options for query/mutation key customization
|
|
45
|
+
- Examples for `queryFromEndpoint` and `infiniteQueryFromEndpoint`
|
|
46
|
+
- Query helper methods documentation
|
|
47
|
+
|
|
3
48
|
## [0.6.0] - Dec 13, 2025
|
|
4
49
|
|
|
5
50
|
### Breaking Changes
|
|
@@ -7,6 +52,7 @@
|
|
|
7
52
|
- **Mutation callback signatures changed** - The `onSuccess`, `onError`, `onMutate`, and `onSettled` callbacks now use a unified context-based signature instead of receiving `queryClient` as the first parameter:
|
|
8
53
|
|
|
9
54
|
**Before (0.5.x):**
|
|
55
|
+
|
|
10
56
|
```typescript
|
|
11
57
|
const mutation = client.mutation({
|
|
12
58
|
onSuccess: (queryClient, data, variables) => {
|
|
@@ -19,6 +65,7 @@
|
|
|
19
65
|
```
|
|
20
66
|
|
|
21
67
|
**After (0.6.0):**
|
|
68
|
+
|
|
22
69
|
```typescript
|
|
23
70
|
const mutation = client.mutation({
|
|
24
71
|
onSuccess: (data, variables, context) => {
|
package/README.md
CHANGED
|
@@ -15,23 +15,26 @@ Type-safe React Query integration for Navios API client with Zod schema validati
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install @navios/react-query @navios/builder navios zod @tanstack/react-query
|
|
18
|
+
npm install @navios/react-query @navios/builder @navios/http zod @tanstack/react-query
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Quick Start
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
24
|
import { builder } from '@navios/builder'
|
|
25
|
+
import { create } from '@navios/http'
|
|
25
26
|
import { declareClient } from '@navios/react-query'
|
|
26
|
-
|
|
27
|
+
|
|
27
28
|
import { z } from 'zod/v4'
|
|
28
29
|
|
|
29
30
|
// Create the API builder
|
|
30
31
|
const api = builder({})
|
|
31
32
|
api.provideClient(create({ baseURL: 'https://api.example.com' }))
|
|
32
33
|
|
|
33
|
-
// Create the client
|
|
34
|
-
const client = declareClient({
|
|
34
|
+
// Create the client with optional defaults
|
|
35
|
+
const client = declareClient({
|
|
36
|
+
api,
|
|
37
|
+
})
|
|
35
38
|
```
|
|
36
39
|
|
|
37
40
|
## Queries
|
|
@@ -130,6 +133,22 @@ const getUsers = client.query({
|
|
|
130
133
|
})
|
|
131
134
|
```
|
|
132
135
|
|
|
136
|
+
### Query with Error Handling
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const getUsers = client.query({
|
|
140
|
+
method: 'GET',
|
|
141
|
+
url: '/users',
|
|
142
|
+
responseSchema: z.array(UserSchema),
|
|
143
|
+
onFail: (error) => {
|
|
144
|
+
// Called when the endpoint throws an error
|
|
145
|
+
// Note: The error is still thrown after this callback
|
|
146
|
+
console.error('Failed to fetch users:', error)
|
|
147
|
+
// You can log to error tracking service, show toast, etc.
|
|
148
|
+
},
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
133
152
|
### Query Helpers
|
|
134
153
|
|
|
135
154
|
```typescript
|
|
@@ -141,8 +160,13 @@ const { data } = getUsers.use({ params: { page: 1 } })
|
|
|
141
160
|
const { data } = getUsers.useSuspense({ params: { page: 1 } })
|
|
142
161
|
|
|
143
162
|
// Invalidation
|
|
144
|
-
|
|
145
|
-
getUsers.
|
|
163
|
+
const queryClient = useQueryClient()
|
|
164
|
+
getUsers.invalidate(queryClient, { params: { page: 1 } })
|
|
165
|
+
getUsers.invalidateAll(queryClient, {}) // Invalidate all pages
|
|
166
|
+
|
|
167
|
+
// Access query key creator
|
|
168
|
+
const queryKey = getUsers.queryKey.dataTag({ params: { page: 1 } })
|
|
169
|
+
// Use with queryClient.getQueryData(queryKey), etc.
|
|
146
170
|
```
|
|
147
171
|
|
|
148
172
|
## Infinite Queries
|
|
@@ -262,19 +286,20 @@ const updateUser = client.mutation({
|
|
|
262
286
|
onMutate: async (variables, context) => {
|
|
263
287
|
// Cancel outgoing queries
|
|
264
288
|
await context.queryClient.cancelQueries({
|
|
265
|
-
queryKey: ['users', variables.urlParams.userId]
|
|
289
|
+
queryKey: ['users', variables.urlParams.userId],
|
|
266
290
|
})
|
|
267
291
|
|
|
268
292
|
// Snapshot previous value
|
|
269
|
-
const previousUser = context.queryClient.getQueryData(
|
|
270
|
-
|
|
271
|
-
|
|
293
|
+
const previousUser = context.queryClient.getQueryData([
|
|
294
|
+
'users',
|
|
295
|
+
variables.urlParams.userId,
|
|
296
|
+
])
|
|
272
297
|
|
|
273
298
|
// Optimistically update
|
|
274
|
-
context.queryClient.setQueryData(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
)
|
|
299
|
+
context.queryClient.setQueryData(['users', variables.urlParams.userId], {
|
|
300
|
+
...previousUser,
|
|
301
|
+
name: variables.data.name,
|
|
302
|
+
})
|
|
278
303
|
|
|
279
304
|
return { previousUser }
|
|
280
305
|
},
|
|
@@ -289,7 +314,7 @@ const updateUser = client.mutation({
|
|
|
289
314
|
if (context.onMutateResult?.previousUser) {
|
|
290
315
|
context.queryClient.setQueryData(
|
|
291
316
|
['users', variables.urlParams.userId],
|
|
292
|
-
context.onMutateResult.previousUser
|
|
317
|
+
context.onMutateResult.previousUser,
|
|
293
318
|
)
|
|
294
319
|
}
|
|
295
320
|
},
|
|
@@ -297,7 +322,7 @@ const updateUser = client.mutation({
|
|
|
297
322
|
// Called on both success and error
|
|
298
323
|
onSettled: (data, error, variables, context) => {
|
|
299
324
|
context.queryClient.invalidateQueries({
|
|
300
|
-
queryKey: ['users', variables.urlParams.userId]
|
|
325
|
+
queryKey: ['users', variables.urlParams.userId],
|
|
301
326
|
})
|
|
302
327
|
},
|
|
303
328
|
})
|
|
@@ -333,7 +358,7 @@ const updateUser = client.mutation({
|
|
|
333
358
|
|
|
334
359
|
// With useKey, you must pass urlParams when calling the hook
|
|
335
360
|
const { mutateAsync, isPending } = updateUser({
|
|
336
|
-
urlParams: { userId: '123' }
|
|
361
|
+
urlParams: { userId: '123' },
|
|
337
362
|
})
|
|
338
363
|
|
|
339
364
|
// Check if any mutation for this user is in progress
|
|
@@ -377,6 +402,8 @@ function DownloadButton({ fileId }: { fileId: string }) {
|
|
|
377
402
|
|
|
378
403
|
If you have endpoints defined separately, you can use them with the client:
|
|
379
404
|
|
|
405
|
+
### Query from Endpoint
|
|
406
|
+
|
|
380
407
|
```typescript
|
|
381
408
|
// Define endpoint separately
|
|
382
409
|
const getUserEndpoint = api.declareEndpoint({
|
|
@@ -390,12 +417,67 @@ const getUser = client.queryFromEndpoint(getUserEndpoint, {
|
|
|
390
417
|
processResponse: (data) => data,
|
|
391
418
|
})
|
|
392
419
|
|
|
393
|
-
//
|
|
420
|
+
// Use in component
|
|
421
|
+
function UserProfile({ userId }: { userId: string }) {
|
|
422
|
+
const { data } = getUser.useSuspense({
|
|
423
|
+
urlParams: { userId },
|
|
424
|
+
})
|
|
425
|
+
return <div>{data.name}</div>
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Infinite Query from Endpoint
|
|
430
|
+
|
|
431
|
+
```typescript
|
|
432
|
+
const getUsersEndpoint = api.declareEndpoint({
|
|
433
|
+
method: 'GET',
|
|
434
|
+
url: '/users',
|
|
435
|
+
querySchema: z.object({
|
|
436
|
+
cursor: z.string().optional(),
|
|
437
|
+
limit: z.number().default(20),
|
|
438
|
+
}),
|
|
439
|
+
responseSchema: z.object({
|
|
440
|
+
users: z.array(UserSchema),
|
|
441
|
+
nextCursor: z.string().nullable(),
|
|
442
|
+
}),
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
const getUsers = client.infiniteQueryFromEndpoint(getUsersEndpoint, {
|
|
446
|
+
processResponse: (data) => data,
|
|
447
|
+
getNextPageParam: (lastPage, allPages) => lastPage.nextCursor ?? undefined,
|
|
448
|
+
})
|
|
449
|
+
|
|
450
|
+
function InfiniteUsersList() {
|
|
451
|
+
const { data, fetchNextPage } = getUsers.useSuspense({
|
|
452
|
+
params: { limit: 20 },
|
|
453
|
+
})
|
|
454
|
+
// ... use data
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Mutation from Endpoint
|
|
459
|
+
|
|
460
|
+
```typescript
|
|
461
|
+
const updateUserEndpoint = api.declareEndpoint({
|
|
462
|
+
method: 'PUT',
|
|
463
|
+
url: '/users/$userId',
|
|
464
|
+
requestSchema: z.object({ name: z.string() }),
|
|
465
|
+
responseSchema: UserSchema,
|
|
466
|
+
})
|
|
467
|
+
|
|
394
468
|
const updateUser = client.mutationFromEndpoint(updateUserEndpoint, {
|
|
395
469
|
processResponse: (data) => data,
|
|
470
|
+
useContext: () => {
|
|
471
|
+
const queryClient = useQueryClient()
|
|
472
|
+
return { queryClient }
|
|
473
|
+
},
|
|
396
474
|
onSuccess: (data, variables, context) => {
|
|
475
|
+
context.queryClient.invalidateQueries({ queryKey: ['users'] })
|
|
397
476
|
console.log('Updated:', data)
|
|
398
477
|
},
|
|
478
|
+
onError: (error, variables, context) => {
|
|
479
|
+
console.error('Update failed:', error)
|
|
480
|
+
},
|
|
399
481
|
})
|
|
400
482
|
```
|
|
401
483
|
|
|
@@ -439,8 +521,23 @@ function AvatarUpload({ userId }: { userId: string }) {
|
|
|
439
521
|
Creates a client instance for making type-safe queries and mutations.
|
|
440
522
|
|
|
441
523
|
**Options:**
|
|
524
|
+
|
|
442
525
|
- `api` - The API builder created with `@navios/builder`
|
|
443
|
-
- `defaults` -
|
|
526
|
+
- `defaults` - Optional default options applied to all queries/mutations:
|
|
527
|
+
- `keyPrefix?: string[]` - Prefix added to all query/mutation keys
|
|
528
|
+
- `keySuffix?: string[]` - Suffix added to all query/mutation keys
|
|
529
|
+
|
|
530
|
+
**Example:**
|
|
531
|
+
|
|
532
|
+
```typescript
|
|
533
|
+
const client = declareClient({
|
|
534
|
+
api,
|
|
535
|
+
defaults: {
|
|
536
|
+
keyPrefix: ['api', 'v1'], // All keys will start with ['api', 'v1']
|
|
537
|
+
keySuffix: ['cache'], // All keys will end with ['cache']
|
|
538
|
+
},
|
|
539
|
+
})
|
|
540
|
+
```
|
|
444
541
|
|
|
445
542
|
**Returns:** `ClientInstance` with the following methods:
|
|
446
543
|
|
|
@@ -459,31 +556,34 @@ Creates a client instance for making type-safe queries and mutations.
|
|
|
459
556
|
|
|
460
557
|
### Query Config
|
|
461
558
|
|
|
462
|
-
| Property
|
|
463
|
-
|
|
464
|
-
| `method`
|
|
465
|
-
| `url`
|
|
466
|
-
| `responseSchema`
|
|
467
|
-
| `querySchema`
|
|
468
|
-
| `requestSchema`
|
|
469
|
-
| `processResponse` | `(data) => Result`
|
|
559
|
+
| Property | Type | Required | Description |
|
|
560
|
+
| ----------------- | ---------------------------------------- | -------- | ---------------------------------------------------------------- |
|
|
561
|
+
| `method` | `'GET' \| 'POST' \| 'HEAD' \| 'OPTIONS'` | Yes | HTTP method |
|
|
562
|
+
| `url` | `string` | Yes | URL pattern (e.g., `/users/$userId`) |
|
|
563
|
+
| `responseSchema` | `ZodSchema` | Yes | Zod schema for response validation |
|
|
564
|
+
| `querySchema` | `ZodObject` | No | Zod schema for query parameters |
|
|
565
|
+
| `requestSchema` | `ZodSchema` | No | Zod schema for request body (POST queries) |
|
|
566
|
+
| `processResponse` | `(data) => Result` | No | Transform the response |
|
|
567
|
+
| `onFail` | `(error) => void` | No | Called when the endpoint throws an error (error is still thrown) |
|
|
568
|
+
| `keyPrefix` | `string[]` | No | Prefix to add to query keys (useful for namespacing) |
|
|
569
|
+
| `keySuffix` | `string[]` | No | Suffix to add to query keys |
|
|
470
570
|
|
|
471
571
|
### Mutation Config
|
|
472
572
|
|
|
473
|
-
| Property
|
|
474
|
-
|
|
475
|
-
| `method`
|
|
476
|
-
| `url`
|
|
477
|
-
| `responseSchema`
|
|
478
|
-
| `requestSchema`
|
|
479
|
-
| `querySchema`
|
|
480
|
-
| `processResponse` | `(data) => Result`
|
|
481
|
-
| `useKey`
|
|
482
|
-
| `useContext`
|
|
483
|
-
| `onMutate`
|
|
484
|
-
| `onSuccess`
|
|
485
|
-
| `onError`
|
|
486
|
-
| `onSettled`
|
|
573
|
+
| Property | Type | Required | Description |
|
|
574
|
+
| ----------------- | ------------------------------------------- | -------- | ------------------------------------ |
|
|
575
|
+
| `method` | `'POST' \| 'PUT' \| 'PATCH' \| 'DELETE'` | Yes | HTTP method |
|
|
576
|
+
| `url` | `string` | Yes | URL pattern (e.g., `/users/$userId`) |
|
|
577
|
+
| `responseSchema` | `ZodSchema` | Yes | Zod schema for response validation |
|
|
578
|
+
| `requestSchema` | `ZodSchema` | No | Zod schema for request body |
|
|
579
|
+
| `querySchema` | `ZodObject` | No | Zod schema for query parameters |
|
|
580
|
+
| `processResponse` | `(data) => Result` | No | Transform the response |
|
|
581
|
+
| `useKey` | `boolean` | No | Enable mutation key for scoping |
|
|
582
|
+
| `useContext` | `() => Context` | No | Hook to provide context to callbacks |
|
|
583
|
+
| `onMutate` | `(variables, context) => onMutateResult` | No | Called before mutation |
|
|
584
|
+
| `onSuccess` | `(data, variables, context) => void` | No | Called on success |
|
|
585
|
+
| `onError` | `(error, variables, context) => void` | No | Called on error |
|
|
586
|
+
| `onSettled` | `(data, error, variables, context) => void` | No | Called on completion |
|
|
487
587
|
|
|
488
588
|
### Context Object
|
|
489
589
|
|
|
@@ -499,6 +599,7 @@ The context passed to mutation callbacks includes:
|
|
|
499
599
|
See [CHANGELOG.md](./CHANGELOG.md) for migration guide from 0.5.x to 0.6.0.
|
|
500
600
|
|
|
501
601
|
Key changes:
|
|
602
|
+
|
|
502
603
|
- Mutation callbacks now receive `(data, variables, context)` instead of `(queryClient, data, variables)`
|
|
503
604
|
- Use `useContext` hook to provide `queryClient` and other dependencies
|
|
504
605
|
- New `onMutate` and `onSettled` callbacks for optimistic updates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declare-client.d.mts","sourceRoot":"","sources":["../../../src/client/declare-client.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,UAAU,EACX,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,
|
|
1
|
+
{"version":3,"file":"declare-client.d.mts","sourceRoot":"","sources":["../../../src/client/declare-client.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,UAAU,EACX,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEnD,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAMjD;;GAEG;AACH,MAAM,WAAW,WAAW,CAC1B,MAAM,GAAG,UAAU,EACnB,GAAG,GAAG,MAAM,EACZ,WAAW,GAAG,SAAS,EACvB,QAAQ,SAAS,OAAO,GAAG,OAAO,EAClC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC3B,aAAa,GAAG,OAAO;IAEvB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,GAAG,CAAA;IACR,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,cAAc,EAAE,QAAQ,CAAA;I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C,GAAG,EAAE,aAAa,EAAE,WAAW,CAAC,EACxD,OAAO,EAAE,OAAO,GACd,uBAAuB,GAAG;QAAE,cAAc,EAAE,eAAe,GAAG,SAAS,CAAA;KAAE,KACxE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,QAAQ,CAAC,EAAE,CACT,SAAS,EAAE,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,CAAC,EACxD,OAAO,EAAE,OAAO,GAAG,uBAAuB,KACvC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAC/C,SAAS,CAAC,EAAE,CACV,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,SAAS,EAAE,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,CAAC,EACxD,OAAO,EAAE,OAAO,GACd,uBAAuB,GAAG;QAAE,cAAc,EAAE,eAAe,GAAG,SAAS,CAAA;KAAE,KACxE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,aAAa,EAAE,EAC3D,GAAG,EACH,QAAa,GACd,EAAE,OAAO,GAAG,cAAc,CAqN1B"}
|
|
@@ -13,7 +13,9 @@ import type { MutationParams } from './types.mjs';
|
|
|
13
13
|
* @returns A hook function that returns mutation result with attached helpers
|
|
14
14
|
*/
|
|
15
15
|
export declare function makeMutation<Config extends AnyEndpointConfig, TData = unknown, TVariables extends NaviosZodRequest<Config> = NaviosZodRequest<Config>, TResponse = z.output<Config['responseSchema']>, TOnMutateResult = unknown, TContext = unknown, UseKey extends boolean = false>(endpoint: AbstractEndpoint<Config>, options: MutationParams<Config, TData, TVariables, TResponse, TOnMutateResult, TContext, UseKey>): {
|
|
16
|
-
(keyParams: UseKey extends true ? UrlHasParams<Config["url"]> extends true ?
|
|
16
|
+
(keyParams: UseKey extends true ? UrlHasParams<Config["url"]> extends true ? {
|
|
17
|
+
urlParams: UrlParams<Config["url"]>;
|
|
18
|
+
} : never : never): UseMutationResult<TData, Error, NaviosZodRequest<Config>, TOnMutateResult>;
|
|
17
19
|
useIsMutating(keyParams: UseKey extends true ? UrlHasParams<Config["url"]> extends true ? UrlParams<Config["url"]> : never : never): boolean;
|
|
18
20
|
mutationKey: (params: UrlHasParams<Config["url"]> extends infer T ? T extends UrlHasParams<Config["url"]> ? T extends true ? {
|
|
19
21
|
urlParams: UrlParams<Config["url"]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-hook.d.mts","sourceRoot":"","sources":["../../../src/mutation/make-hook.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACV,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,SAAS,iBAAiB,EAChC,KAAK,GAAG,OAAO,EACf,UAAU,SAAS,gBAAgB,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAC,MAAM,CAAC,EACtE,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAC9C,eAAe,GAAG,OAAO,EACzB,QAAQ,GAAG,OAAO,EAClB,MAAM,SAAS,OAAO,GAAG,KAAK,EAE9B,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAClC,OAAO,EAAE,cAAc,CACr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