@navios/react-query 0.3.0 → 0.4.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.
- package/README.md +13 -7
- package/dist/src/declare-client.d.mts +4 -4
- package/dist/src/declare-client.d.mts.map +1 -1
- package/dist/src/make-mutation.d.mts +1 -1
- package/dist/src/make-mutation.d.mts.map +1 -1
- package/dist/src/types/client-endpoint-helper.d.mts +1 -1
- package/dist/src/types/client-endpoint-helper.d.mts.map +1 -1
- package/dist/src/types/client-instance.d.mts +15 -15
- package/dist/src/types/client-instance.d.mts.map +1 -1
- package/dist/src/types/mutation-args.d.mts +3 -3
- package/dist/src/types/mutation-args.d.mts.map +1 -1
- package/dist/src/types/query-args.d.mts +3 -3
- package/dist/src/types/query-args.d.mts.map +1 -1
- package/dist/src/types/query-helpers.d.mts +2 -2
- package/dist/src/types/query-helpers.d.mts.map +1 -1
- package/dist/src/types.d.mts +4 -4
- package/dist/src/types.d.mts.map +1 -1
- package/dist/src/utils/query-key-creator.d.mts +3 -3
- package/dist/src/utils/query-key-creator.d.mts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/_tsup-dts-rollup.d.mts +30 -30
- package/lib/_tsup-dts-rollup.d.ts +30 -30
- package/lib/index.js.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/client-type-check.spec.mts +1 -1
- package/src/__tests__/declare-client.spec.mts +1 -1
- package/src/__tests__/make-mutation.spec.mts +1 -1
- package/src/__tests__/makeDataTag.spec.mts +1 -1
- package/src/__tests__/makeInfiniteQueryOptions.spec.mts +1 -1
- package/src/__tests__/makeQueryOptions.spec.mts +1 -1
- package/src/declare-client.mts +4 -4
- package/src/make-infinite-query-options.mts +1 -1
- package/src/make-mutation.mts +1 -1
- package/src/types/client-endpoint-helper.mts +1 -1
- package/src/types/client-instance.mts +13 -15
- package/src/types/mutation-args.mts +3 -3
- package/src/types/query-args.mts +3 -3
- package/src/types/query-helpers.mts +2 -2
- package/src/types.mts +5 -5
- package/src/utils/query-key-creator.mts +3 -7
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
UseSuspenseInfiniteQueryOptions,
|
|
13
13
|
UseSuspenseQueryOptions,
|
|
14
14
|
} from '@tanstack/react-query'
|
|
15
|
-
import type {
|
|
15
|
+
import type { z, ZodObject, ZodType } from 'zod/v4'
|
|
16
16
|
|
|
17
17
|
import type { ProcessResponseFunction, Split } from '../types.mjs'
|
|
18
18
|
import type { ClientEndpointHelper } from './client-endpoint-helper.mjs'
|
|
@@ -46,7 +46,7 @@ export interface ClientInstance {
|
|
|
46
46
|
query<
|
|
47
47
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
48
48
|
Url extends string = string,
|
|
49
|
-
QuerySchema extends
|
|
49
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
50
50
|
Response extends ZodType = ZodType,
|
|
51
51
|
Result = z.output<Response>,
|
|
52
52
|
>(config: {
|
|
@@ -69,7 +69,7 @@ export interface ClientInstance {
|
|
|
69
69
|
infiniteQuery<
|
|
70
70
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
71
71
|
Url extends string = string,
|
|
72
|
-
QuerySchema extends
|
|
72
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
73
73
|
Response extends ZodType = ZodType,
|
|
74
74
|
PageResult = z.output<Response>,
|
|
75
75
|
Result = InfiniteData<PageResult>,
|
|
@@ -97,7 +97,6 @@ export interface ClientInstance {
|
|
|
97
97
|
PageResult,
|
|
98
98
|
Error,
|
|
99
99
|
Result,
|
|
100
|
-
PageResult,
|
|
101
100
|
DataTag<Split<Url, '/'>, PageResult, Error>,
|
|
102
101
|
z.output<QuerySchema>
|
|
103
102
|
>) &
|
|
@@ -108,7 +107,7 @@ export interface ClientInstance {
|
|
|
108
107
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
109
108
|
Url extends string = string,
|
|
110
109
|
RequestSchema extends ZodType = ZodType,
|
|
111
|
-
QuerySchema extends
|
|
110
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
112
111
|
Response extends ZodType = ZodType,
|
|
113
112
|
ReqResult = z.output<Response>,
|
|
114
113
|
Result = unknown,
|
|
@@ -153,7 +152,7 @@ export interface ClientInstance {
|
|
|
153
152
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
154
153
|
Url extends string = string,
|
|
155
154
|
RequestSchema extends ZodType = ZodType,
|
|
156
|
-
QuerySchema extends
|
|
155
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
157
156
|
Response extends ZodType = ZodType,
|
|
158
157
|
ReqResult = z.output<Response>,
|
|
159
158
|
Result = unknown,
|
|
@@ -274,7 +273,7 @@ export interface ClientInstance {
|
|
|
274
273
|
mutation<
|
|
275
274
|
Method extends 'DELETE' = 'DELETE',
|
|
276
275
|
Url extends string = string,
|
|
277
|
-
QuerySchema extends
|
|
276
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
278
277
|
Response extends ZodType = ZodType,
|
|
279
278
|
ReqResult = z.output<Response>,
|
|
280
279
|
Result = unknown,
|
|
@@ -317,7 +316,7 @@ export interface ClientInstance {
|
|
|
317
316
|
mutation<
|
|
318
317
|
Method extends 'DELETE' = 'DELETE',
|
|
319
318
|
Url extends string = string,
|
|
320
|
-
QuerySchema extends
|
|
319
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
321
320
|
Response extends ZodType = ZodType,
|
|
322
321
|
ReqResult = z.output<Response>,
|
|
323
322
|
Result = unknown,
|
|
@@ -424,7 +423,7 @@ export interface ClientInstance {
|
|
|
424
423
|
queryFromEndpoint<
|
|
425
424
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
426
425
|
Url extends string = string,
|
|
427
|
-
QuerySchema extends
|
|
426
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
428
427
|
Response extends ZodType = ZodType,
|
|
429
428
|
Result = z.output<Response>,
|
|
430
429
|
>(
|
|
@@ -469,7 +468,7 @@ export interface ClientInstance {
|
|
|
469
468
|
infiniteQueryFromEndpoint<
|
|
470
469
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
471
470
|
Url extends string = string,
|
|
472
|
-
QuerySchema extends
|
|
471
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
473
472
|
Response extends ZodType = ZodType,
|
|
474
473
|
PageResult = z.output<Response>,
|
|
475
474
|
Result = InfiniteData<PageResult>,
|
|
@@ -498,7 +497,6 @@ export interface ClientInstance {
|
|
|
498
497
|
PageResult,
|
|
499
498
|
Error,
|
|
500
499
|
Result,
|
|
501
|
-
PageResult,
|
|
502
500
|
DataTag<Split<Url, '/'>, PageResult, Error>,
|
|
503
501
|
z.output<QuerySchema>
|
|
504
502
|
>) &
|
|
@@ -508,7 +506,7 @@ export interface ClientInstance {
|
|
|
508
506
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
509
507
|
Url extends string = string,
|
|
510
508
|
RequestSchema extends ZodType = ZodType,
|
|
511
|
-
QuerySchema extends
|
|
509
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
512
510
|
Response extends ZodType = ZodType,
|
|
513
511
|
ReqResult = z.output<Response>,
|
|
514
512
|
Result = unknown,
|
|
@@ -609,7 +607,7 @@ export interface ClientInstance {
|
|
|
609
607
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
610
608
|
Url extends string = string,
|
|
611
609
|
RequestSchema extends ZodType = ZodType,
|
|
612
|
-
QuerySchema extends
|
|
610
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
613
611
|
Response extends ZodType = ZodType,
|
|
614
612
|
ReqResult = z.output<Response>,
|
|
615
613
|
Result = unknown,
|
|
@@ -699,7 +697,7 @@ export interface ClientInstance {
|
|
|
699
697
|
mutationFromEndpoint<
|
|
700
698
|
Method extends 'DELETE' = 'DELETE',
|
|
701
699
|
Url extends string = string,
|
|
702
|
-
QuerySchema extends
|
|
700
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
703
701
|
Response extends ZodType = ZodType,
|
|
704
702
|
ReqResult = z.output<Response>,
|
|
705
703
|
Result = unknown,
|
|
@@ -786,7 +784,7 @@ export interface ClientInstance {
|
|
|
786
784
|
mutationFromEndpoint<
|
|
787
785
|
Method extends 'DELETE' = 'DELETE',
|
|
788
786
|
Url extends string = string,
|
|
789
|
-
QuerySchema extends
|
|
787
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
790
788
|
Response extends ZodType = ZodType,
|
|
791
789
|
ReqResult = z.output<Response>,
|
|
792
790
|
Result = unknown,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { UrlHasParams, UrlParams } from '@navios/builder'
|
|
2
|
-
import type {
|
|
2
|
+
import type { z, ZodObject } from 'zod/v4'
|
|
3
3
|
|
|
4
4
|
export type ClientMutationArgs<
|
|
5
5
|
Url extends string = string,
|
|
6
6
|
RequestSchema = unknown,
|
|
7
7
|
QuerySchema = unknown,
|
|
8
8
|
> = (UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {}) &
|
|
9
|
-
(RequestSchema extends
|
|
10
|
-
(QuerySchema extends
|
|
9
|
+
(RequestSchema extends ZodObject ? { data: z.input<RequestSchema> } : {}) &
|
|
10
|
+
(QuerySchema extends ZodObject ? { params: z.input<QuerySchema> } : {})
|
package/src/types/query-args.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { UrlHasParams, UrlParams } from '@navios/builder'
|
|
2
|
-
import type {
|
|
2
|
+
import type { z, ZodObject } from 'zod/v4'
|
|
3
3
|
|
|
4
4
|
export type ClientQueryArgs<
|
|
5
5
|
Url extends string = string,
|
|
6
|
-
QuerySchema =
|
|
6
|
+
QuerySchema = ZodObject,
|
|
7
7
|
> = (UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {}) &
|
|
8
|
-
(QuerySchema extends
|
|
8
|
+
(QuerySchema extends ZodObject ? { params: z.input<QuerySchema> } : {})
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
UseQueryResult,
|
|
5
5
|
UseSuspenseQueryResult,
|
|
6
6
|
} from '@tanstack/react-query'
|
|
7
|
-
import type {
|
|
7
|
+
import type { ZodObject } from 'zod/v4'
|
|
8
8
|
|
|
9
9
|
import type { QueryKeyCreatorResult } from '../utils/query-key-creator.mjs'
|
|
10
10
|
import type { ClientQueryArgs } from './query-args.mjs'
|
|
@@ -12,7 +12,7 @@ import type { ClientQueryUrlParamsArgs } from './query-url-params-args.mjs'
|
|
|
12
12
|
|
|
13
13
|
export type QueryHelpers<
|
|
14
14
|
Url extends string,
|
|
15
|
-
QuerySchema extends
|
|
15
|
+
QuerySchema extends ZodObject | undefined = undefined,
|
|
16
16
|
Result = undefined,
|
|
17
17
|
IsInfinite extends boolean = false,
|
|
18
18
|
> = {
|
package/src/types.mts
CHANGED
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
UrlParams,
|
|
9
9
|
} from '@navios/builder'
|
|
10
10
|
import type { QueryClient, UseMutationOptions } from '@tanstack/react-query'
|
|
11
|
-
import type {
|
|
11
|
+
import type { z, ZodObject } from 'zod/v4'
|
|
12
12
|
|
|
13
13
|
export type Split<S extends string, D extends string> = string extends S
|
|
14
14
|
? string[]
|
|
@@ -88,7 +88,7 @@ export type BaseQueryArgs<Config extends AnyEndpointConfig> = (UrlHasParams<
|
|
|
88
88
|
> extends true
|
|
89
89
|
? { urlParams: UrlParams<Config['url']> }
|
|
90
90
|
: {}) &
|
|
91
|
-
(Config['querySchema'] extends
|
|
91
|
+
(Config['querySchema'] extends ZodObject
|
|
92
92
|
? { params: z.input<Config['querySchema']> }
|
|
93
93
|
: {})
|
|
94
94
|
|
|
@@ -96,7 +96,7 @@ export type BaseMutationArgs<Config extends AnyEndpointConfig> =
|
|
|
96
96
|
NaviosZodRequest<Config>
|
|
97
97
|
|
|
98
98
|
export type InfiniteQueryOptions<
|
|
99
|
-
Config extends BaseEndpointConfig<HttpMethod, string,
|
|
99
|
+
Config extends BaseEndpointConfig<HttpMethod, string, ZodObject>,
|
|
100
100
|
Res = any,
|
|
101
101
|
> = {
|
|
102
102
|
keyPrefix?: string[]
|
|
@@ -104,8 +104,8 @@ export type InfiniteQueryOptions<
|
|
|
104
104
|
processResponse: (data: z.infer<Config['responseSchema']>) => Res
|
|
105
105
|
onFail?: (err: unknown) => void
|
|
106
106
|
getNextPageParam: (
|
|
107
|
-
lastPage:
|
|
108
|
-
allPages:
|
|
107
|
+
lastPage: Res,
|
|
108
|
+
allPages: Res[],
|
|
109
109
|
lastPageParam: z.infer<Config['querySchema']> | undefined,
|
|
110
110
|
allPageParams: z.infer<Config['querySchema']>[] | undefined,
|
|
111
111
|
) =>
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
UrlParams,
|
|
5
5
|
} from '@navios/builder'
|
|
6
6
|
import type { DataTag, InfiniteData } from '@tanstack/react-query'
|
|
7
|
-
import type {
|
|
7
|
+
import type { z, ZodObject } from 'zod/v4'
|
|
8
8
|
|
|
9
9
|
import { bindUrlParams } from '@navios/builder'
|
|
10
10
|
|
|
@@ -28,9 +28,7 @@ export type QueryKeyCreatorResult<
|
|
|
28
28
|
template: Split<Url, '/'>
|
|
29
29
|
dataTag: (
|
|
30
30
|
params: (HasParams extends true ? { urlParams: UrlParams<Url> } : {}) &
|
|
31
|
-
(QuerySchema extends
|
|
32
|
-
? { params: z.input<QuerySchema> }
|
|
33
|
-
: {}),
|
|
31
|
+
(QuerySchema extends ZodObject ? { params: z.input<QuerySchema> } : {}),
|
|
34
32
|
) => DataTag<
|
|
35
33
|
Split<Url, '/'>,
|
|
36
34
|
IsInfinite extends true ? InfiniteData<Result> : Result,
|
|
@@ -45,9 +43,7 @@ export type QueryKeyCreatorResult<
|
|
|
45
43
|
>
|
|
46
44
|
bindToUrl: (
|
|
47
45
|
params: (HasParams extends true ? { urlParams: UrlParams<Url> } : {}) &
|
|
48
|
-
(QuerySchema extends
|
|
49
|
-
? { params: z.infer<QuerySchema> }
|
|
50
|
-
: {}),
|
|
46
|
+
(QuerySchema extends ZodObject ? { params: z.infer<QuerySchema> } : {}),
|
|
51
47
|
) => string
|
|
52
48
|
}
|
|
53
49
|
|