@navios/react-query 0.1.1 → 0.1.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.
|
@@ -4,11 +4,11 @@ import type { AnyZodObject } from 'zod';
|
|
|
4
4
|
import type { BaseEndpointConfig } from '@navios/common';
|
|
5
5
|
import type { BuilderInstance } from '@navios/common';
|
|
6
6
|
import type { DataTag } from '@tanstack/react-query';
|
|
7
|
-
import { DefinedUseInfiniteQueryResult } from '@tanstack/react-query';
|
|
8
7
|
import type { EndpointFunctionArgs } from '@navios/common';
|
|
9
8
|
import type { HttpMethod } from '@navios/common';
|
|
10
9
|
import type { InfiniteData } from '@tanstack/react-query';
|
|
11
10
|
import type { NaviosZodRequest } from '@navios/common';
|
|
11
|
+
import { NoInfer as NoInfer_2 } from '@tanstack/react-query';
|
|
12
12
|
import type { QueryClient } from '@tanstack/react-query';
|
|
13
13
|
import { QueryKeyCreatorResult as QueryKeyCreatorResult_2 } from './utils/query-key-creator.mjs';
|
|
14
14
|
import { UrlHasParams } from '@navios/common';
|
|
@@ -18,11 +18,11 @@ import { UseInfiniteQueryResult } from '@tanstack/react-query';
|
|
|
18
18
|
import type { UseMutationOptions } from '@tanstack/react-query';
|
|
19
19
|
import type { UseMutationResult } from '@tanstack/react-query';
|
|
20
20
|
import type { UseQueryOptions } from '@tanstack/react-query';
|
|
21
|
-
import
|
|
21
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
22
22
|
import type { UseSuspenseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
23
23
|
import { UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
|
|
24
24
|
import type { UseSuspenseQueryOptions } from '@tanstack/react-query';
|
|
25
|
-
import
|
|
25
|
+
import { UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
26
26
|
import type { Util_FlatObject } from '@navios/common';
|
|
27
27
|
import type { z } from 'zod';
|
|
28
28
|
import type { ZodType } from 'zod';
|
|
@@ -342,8 +342,8 @@ export { makeMutation as makeMutation_alias_1 }
|
|
|
342
342
|
declare function makeQueryOptions<Config extends AnyEndpointConfig, Options extends BaseQueryParams<Config>, BaseQuery extends Omit<UseQueryOptions<ReturnType<Options['processResponse']>, Error, any>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam' | 'enabled' | 'throwOnError' | 'placeholderData'>>(endpoint: AbstractEndpoint<Config>, options: Options, baseQuery?: BaseQuery): {
|
|
343
343
|
(params: BaseQueryArgs<Config>): Options["processResponse"] extends (...args: any[]) => infer Result ? UseSuspenseQueryOptions<Result, Error, BaseQuery["select"] extends (...args: any[]) => infer T ? T : Result, DataTag<Split_3<Config["url"], "/">, Result, Error>> : never;
|
|
344
344
|
queryKey: QueryKeyCreatorResult_2<Config["querySchema"], Config["url"], Options["processResponse"] extends (...args: any[]) => infer Result ? Result : never, false, UrlHasParams<Config["url"]>>;
|
|
345
|
-
use(params: ClientQueryArgs):
|
|
346
|
-
useSuspense(params: ClientQueryArgs):
|
|
345
|
+
use(params: ClientQueryArgs): UseQueryResult<NoInfer_2<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown>, Error>;
|
|
346
|
+
useSuspense(params: ClientQueryArgs): UseSuspenseQueryResult<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown, Error>;
|
|
347
347
|
invalidate(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
348
348
|
invalidateAll(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
349
349
|
};
|
|
@@ -4,11 +4,11 @@ import type { AnyZodObject } from 'zod';
|
|
|
4
4
|
import type { BaseEndpointConfig } from '@navios/common';
|
|
5
5
|
import type { BuilderInstance } from '@navios/common';
|
|
6
6
|
import type { DataTag } from '@tanstack/react-query';
|
|
7
|
-
import { DefinedUseInfiniteQueryResult } from '@tanstack/react-query';
|
|
8
7
|
import type { EndpointFunctionArgs } from '@navios/common';
|
|
9
8
|
import type { HttpMethod } from '@navios/common';
|
|
10
9
|
import type { InfiniteData } from '@tanstack/react-query';
|
|
11
10
|
import type { NaviosZodRequest } from '@navios/common';
|
|
11
|
+
import { NoInfer as NoInfer_2 } from '@tanstack/react-query';
|
|
12
12
|
import type { QueryClient } from '@tanstack/react-query';
|
|
13
13
|
import { QueryKeyCreatorResult as QueryKeyCreatorResult_2 } from './utils/query-key-creator.mjs';
|
|
14
14
|
import { UrlHasParams } from '@navios/common';
|
|
@@ -18,11 +18,11 @@ import { UseInfiniteQueryResult } from '@tanstack/react-query';
|
|
|
18
18
|
import type { UseMutationOptions } from '@tanstack/react-query';
|
|
19
19
|
import type { UseMutationResult } from '@tanstack/react-query';
|
|
20
20
|
import type { UseQueryOptions } from '@tanstack/react-query';
|
|
21
|
-
import
|
|
21
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
22
22
|
import type { UseSuspenseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
23
23
|
import { UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
|
|
24
24
|
import type { UseSuspenseQueryOptions } from '@tanstack/react-query';
|
|
25
|
-
import
|
|
25
|
+
import { UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
26
26
|
import type { Util_FlatObject } from '@navios/common';
|
|
27
27
|
import type { z } from 'zod';
|
|
28
28
|
import type { ZodType } from 'zod';
|
|
@@ -342,8 +342,8 @@ export { makeMutation as makeMutation_alias_1 }
|
|
|
342
342
|
declare function makeQueryOptions<Config extends AnyEndpointConfig, Options extends BaseQueryParams<Config>, BaseQuery extends Omit<UseQueryOptions<ReturnType<Options['processResponse']>, Error, any>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam' | 'enabled' | 'throwOnError' | 'placeholderData'>>(endpoint: AbstractEndpoint<Config>, options: Options, baseQuery?: BaseQuery): {
|
|
343
343
|
(params: BaseQueryArgs<Config>): Options["processResponse"] extends (...args: any[]) => infer Result ? UseSuspenseQueryOptions<Result, Error, BaseQuery["select"] extends (...args: any[]) => infer T ? T : Result, DataTag<Split_3<Config["url"], "/">, Result, Error>> : never;
|
|
344
344
|
queryKey: QueryKeyCreatorResult_2<Config["querySchema"], Config["url"], Options["processResponse"] extends (...args: any[]) => infer Result ? Result : never, false, UrlHasParams<Config["url"]>>;
|
|
345
|
-
use(params: ClientQueryArgs):
|
|
346
|
-
useSuspense(params: ClientQueryArgs):
|
|
345
|
+
use(params: ClientQueryArgs): UseQueryResult<NoInfer_2<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown>, Error>;
|
|
346
|
+
useSuspense(params: ClientQueryArgs): UseSuspenseQueryResult<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown, Error>;
|
|
347
347
|
invalidate(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
348
348
|
invalidateAll(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
349
349
|
};
|
package/dist/index.js
CHANGED
|
@@ -230,10 +230,10 @@ function makeQueryOptions(endpoint, options, baseQuery = {}) {
|
|
|
230
230
|
};
|
|
231
231
|
result.queryKey = queryKey;
|
|
232
232
|
result.use = (params) => {
|
|
233
|
-
return (0, import_react_query3.
|
|
233
|
+
return (0, import_react_query3.useQuery)(result(params));
|
|
234
234
|
};
|
|
235
235
|
result.useSuspense = (params) => {
|
|
236
|
-
return (0, import_react_query3.
|
|
236
|
+
return (0, import_react_query3.useSuspenseQuery)(result(params));
|
|
237
237
|
};
|
|
238
238
|
result.invalidate = (queryClient, params) => {
|
|
239
239
|
return queryClient.invalidateQueries({
|
package/dist/index.mjs
CHANGED
|
@@ -179,11 +179,7 @@ function makeMutation(endpoint, options) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
// packages/react-query/src/make-query-options.mts
|
|
182
|
-
import {
|
|
183
|
-
queryOptions,
|
|
184
|
-
useInfiniteQuery as useInfiniteQuery2,
|
|
185
|
-
useSuspenseInfiniteQuery as useSuspenseInfiniteQuery2
|
|
186
|
-
} from "@tanstack/react-query";
|
|
182
|
+
import { queryOptions, useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
|
187
183
|
function makeQueryOptions(endpoint, options, baseQuery = {}) {
|
|
188
184
|
const config = endpoint.config;
|
|
189
185
|
const queryKey = queryKeyCreator(config, options, false);
|
|
@@ -211,10 +207,10 @@ function makeQueryOptions(endpoint, options, baseQuery = {}) {
|
|
|
211
207
|
};
|
|
212
208
|
result.queryKey = queryKey;
|
|
213
209
|
result.use = (params) => {
|
|
214
|
-
return
|
|
210
|
+
return useQuery(result(params));
|
|
215
211
|
};
|
|
216
212
|
result.useSuspense = (params) => {
|
|
217
|
-
return
|
|
213
|
+
return useSuspenseQuery(result(params));
|
|
218
214
|
};
|
|
219
215
|
result.invalidate = (queryClient, params) => {
|
|
220
216
|
return queryClient.invalidateQueries({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navios/react-query",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Oleksandr Hanzha",
|
|
6
6
|
"email": "alex@granted.name"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"main": "./dist/index.js",
|
|
16
16
|
"module": "./dist/index.mjs",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@navios/common": "^0.1.
|
|
18
|
+
"@navios/common": "^0.1.3",
|
|
19
19
|
"@tanstack/react-query": "^5.51.21",
|
|
20
20
|
"zod": "^3.23.8"
|
|
21
21
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"./package.json": "./package.json"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@navios/common": "^0.1.
|
|
36
|
+
"@navios/common": "^0.1.3",
|
|
37
37
|
"@tanstack/react-query": "^5.75.7",
|
|
38
38
|
"navios": "^0.4.0",
|
|
39
39
|
"react": "^19.1.0",
|
|
@@ -6,11 +6,7 @@ import type {
|
|
|
6
6
|
UseSuspenseQueryOptions,
|
|
7
7
|
} from '@tanstack/react-query'
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
queryOptions,
|
|
11
|
-
useInfiniteQuery,
|
|
12
|
-
useSuspenseInfiniteQuery,
|
|
13
|
-
} from '@tanstack/react-query'
|
|
9
|
+
import { queryOptions, useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
|
14
10
|
|
|
15
11
|
import type { BaseQueryArgs, BaseQueryParams } from './types.mjs'
|
|
16
12
|
import type { ClientQueryArgs } from './types/index.mjs'
|
|
@@ -83,12 +79,12 @@ export function makeQueryOptions<
|
|
|
83
79
|
result.queryKey = queryKey
|
|
84
80
|
result.use = (params: ClientQueryArgs) => {
|
|
85
81
|
// @ts-expect-error We add additional function to the result
|
|
86
|
-
return
|
|
82
|
+
return useQuery(result(params))
|
|
87
83
|
}
|
|
88
84
|
|
|
89
85
|
result.useSuspense = (params: ClientQueryArgs) => {
|
|
90
86
|
// @ts-expect-error We add additional function to the result
|
|
91
|
-
return
|
|
87
|
+
return useSuspenseQuery(result(params))
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
result.invalidate = (queryClient: QueryClient, params: ClientQueryArgs) => {
|