@navios/react-query 0.1.1 → 0.1.3
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/dist/_tsup-dts-rollup.d.mts +84 -30
- package/dist/_tsup-dts-rollup.d.ts +84 -30
- package/dist/index.js +15 -3
- package/dist/index.mjs +16 -8
- package/package.json +4 -4
- package/src/__tests__/declare-client.spec.mts +0 -1
- package/src/declare-client.mts +31 -0
- package/src/make-query-options.mts +3 -7
- package/src/types/client-instance.mts +372 -22
|
@@ -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';
|
|
@@ -142,9 +142,7 @@ declare interface ClientInstance {
|
|
|
142
142
|
useContext?: () => Context;
|
|
143
143
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
144
144
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
145
|
-
}): (
|
|
146
|
-
urlParams: UrlParams<Url>;
|
|
147
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, QuerySchema>> & ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>;
|
|
145
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, QuerySchema>>) & ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>;
|
|
148
146
|
mutation<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(config: {
|
|
149
147
|
method: Method;
|
|
150
148
|
url: Url;
|
|
@@ -154,9 +152,7 @@ declare interface ClientInstance {
|
|
|
154
152
|
useContext?: () => Context;
|
|
155
153
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
156
154
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
157
|
-
}): ((
|
|
158
|
-
urlParams: UrlParams<Url>;
|
|
159
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response>;
|
|
155
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response>;
|
|
160
156
|
mutation<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(config: {
|
|
161
157
|
method: Method;
|
|
162
158
|
url: Url;
|
|
@@ -167,9 +163,7 @@ declare interface ClientInstance {
|
|
|
167
163
|
useContext?: () => Context;
|
|
168
164
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
169
165
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
170
|
-
}): ((params: UrlHasParams<Url> extends true ? {
|
|
171
|
-
urlParams: UrlParams<Url>;
|
|
172
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response>;
|
|
166
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response>;
|
|
173
167
|
mutation<Method extends 'DELETE' = 'DELETE', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(config: {
|
|
174
168
|
method: Method;
|
|
175
169
|
url: Url;
|
|
@@ -180,9 +174,7 @@ declare interface ClientInstance {
|
|
|
180
174
|
useContext?: () => Context;
|
|
181
175
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
182
176
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
183
|
-
}): ((params: UrlHasParams<Url> extends true ? {
|
|
184
|
-
urlParams: UrlParams<Url>;
|
|
185
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
177
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
186
178
|
mutation<Method extends 'DELETE' = 'DELETE', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(config: {
|
|
187
179
|
method: Method;
|
|
188
180
|
url: Url;
|
|
@@ -192,9 +184,7 @@ declare interface ClientInstance {
|
|
|
192
184
|
useContext?: () => Context;
|
|
193
185
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
194
186
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
195
|
-
}): (
|
|
196
|
-
urlParams: UrlParams<Url>;
|
|
197
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>> & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
187
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
198
188
|
mutation<Method extends 'DELETE' = 'DELETE', Url extends string = string, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(config: {
|
|
199
189
|
method: Method;
|
|
200
190
|
url: Url;
|
|
@@ -204,9 +194,7 @@ declare interface ClientInstance {
|
|
|
204
194
|
useContext?: () => Context;
|
|
205
195
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
206
196
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
207
|
-
}): ((params: UrlHasParams<Url> extends true ? {
|
|
208
|
-
urlParams: UrlParams<Url>;
|
|
209
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response>;
|
|
197
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response>;
|
|
210
198
|
mutation<Method extends 'DELETE' = 'DELETE', Url extends string = string, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(config: {
|
|
211
199
|
method: Method;
|
|
212
200
|
url: Url;
|
|
@@ -215,9 +203,7 @@ declare interface ClientInstance {
|
|
|
215
203
|
useContext?: () => Context;
|
|
216
204
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
217
205
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
218
|
-
}): (
|
|
219
|
-
urlParams: UrlParams<Url>;
|
|
220
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>> & ClientEndpointHelper<Method, Url, undefined, Response>;
|
|
206
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & ClientEndpointHelper<Method, Url, undefined, Response>;
|
|
221
207
|
queryFromEndpoint<Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, Result = z.output<Response>>(endpoint: any & {
|
|
222
208
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>;
|
|
223
209
|
}, options?: {
|
|
@@ -229,18 +215,86 @@ declare interface ClientInstance {
|
|
|
229
215
|
config: BaseEndpointConfig<Method, Url, undefined, Response>;
|
|
230
216
|
}, options?: {
|
|
231
217
|
processResponse?: (data: z.output<Response>) => Result;
|
|
232
|
-
}): (params: UrlHasParams<Url> extends true ? {
|
|
218
|
+
}): ((params: UrlHasParams<Url> extends true ? {
|
|
233
219
|
urlParams: UrlParams<Url>;
|
|
234
|
-
} : {}) => UseSuspenseQueryOptions<Result, Error, Result, DataTag<Split<Url, '/'>, Result, Error>> & QueryHelpers<Url, undefined, Result>;
|
|
220
|
+
} : {}) => UseSuspenseQueryOptions<Result, Error, Result, DataTag<Split<Url, '/'>, Result, Error>>) & QueryHelpers<Url, undefined, Result>;
|
|
235
221
|
infiniteQueryFromEndpoint<Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, PageResult = z.output<Response>, Result = InfiniteData<PageResult>>(endpoint: any & {
|
|
236
222
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>;
|
|
237
223
|
}, options: {
|
|
238
224
|
processResponse?: (data: z.output<Response>) => PageResult;
|
|
239
225
|
getNextPageParam: (lastPage: PageResult, allPages: PageResult[], lastPageParam: z.infer<QuerySchema> | undefined, allPageParams: z.infer<QuerySchema>[] | undefined) => z.input<QuerySchema> | undefined;
|
|
240
226
|
getPreviousPageParam?: (firstPage: PageResult, allPages: PageResult[], lastPageParam: z.infer<QuerySchema> | undefined, allPageParams: z.infer<QuerySchema>[] | undefined) => z.input<QuerySchema>;
|
|
241
|
-
}): (params: UrlHasParams<Url> extends true ? {
|
|
227
|
+
}): ((params: UrlHasParams<Url> extends true ? {
|
|
242
228
|
urlParams: UrlParams<Url>;
|
|
243
|
-
} : {}) => UseSuspenseInfiniteQueryOptions<PageResult, Error, Result, PageResult, DataTag<Split<Url, '/'>, PageResult, Error>, z.output<QuerySchema>> & QueryHelpers<Url, QuerySchema, PageResult, true>;
|
|
229
|
+
} : {}) => UseSuspenseInfiniteQueryOptions<PageResult, Error, Result, PageResult, DataTag<Split<Url, '/'>, PageResult, Error>, z.output<QuerySchema>>) & QueryHelpers<Url, QuerySchema, PageResult, true>;
|
|
230
|
+
mutationFromEndpoint<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(endpoint: any & {
|
|
231
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response, RequestSchema>;
|
|
232
|
+
}, mutationOptions: {
|
|
233
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
234
|
+
useKey: UseKey;
|
|
235
|
+
useContext?: () => Context;
|
|
236
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
237
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
238
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, QuerySchema>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>;
|
|
239
|
+
mutationFromEndpoint<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(endpoint: any & {
|
|
240
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response, RequestSchema>;
|
|
241
|
+
}, mutationOptions: {
|
|
242
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
243
|
+
useKey: UseKey;
|
|
244
|
+
useContext?: () => Context;
|
|
245
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
246
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
247
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response, undefined>;
|
|
248
|
+
mutationFromEndpoint<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(endpoint: any & {
|
|
249
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response, RequestSchema>;
|
|
250
|
+
}, mutationOptions: {
|
|
251
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
252
|
+
useContext?: () => Context;
|
|
253
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
254
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
255
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, QuerySchema>>) & ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>;
|
|
256
|
+
mutationFromEndpoint<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(endpoint: any & {
|
|
257
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response, RequestSchema>;
|
|
258
|
+
}, mutationOptions: {
|
|
259
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
260
|
+
useContext?: () => Context;
|
|
261
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
262
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
263
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & ClientEndpointHelper<Method, Url, RequestSchema, Response, undefined>;
|
|
264
|
+
mutationFromEndpoint<Method extends 'DELETE' = 'DELETE', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(endpoint: any & {
|
|
265
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>;
|
|
266
|
+
}, mutationOptions: {
|
|
267
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
268
|
+
useKey: UseKey;
|
|
269
|
+
useContext?: () => Context;
|
|
270
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
271
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
272
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
273
|
+
mutationFromEndpoint<Method extends 'DELETE' = 'DELETE', Url extends string = string, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(endpoint: any & {
|
|
274
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response>;
|
|
275
|
+
}, mutationOptions: {
|
|
276
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
277
|
+
useKey: UseKey;
|
|
278
|
+
useContext?: () => Context;
|
|
279
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
280
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
281
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response, undefined>;
|
|
282
|
+
mutationFromEndpoint<Method extends 'DELETE' = 'DELETE', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(endpoint: any & {
|
|
283
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>;
|
|
284
|
+
}, mutationOptions: {
|
|
285
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
286
|
+
useContext?: () => Context;
|
|
287
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
288
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
289
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
290
|
+
mutationFromEndpoint<Method extends 'DELETE' = 'DELETE', Url extends string = string, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(endpoint: any & {
|
|
291
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response>;
|
|
292
|
+
}, mutationOptions: {
|
|
293
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
294
|
+
useContext?: () => Context;
|
|
295
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
296
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
297
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & ClientEndpointHelper<Method, Url, undefined, Response, undefined>;
|
|
244
298
|
}
|
|
245
299
|
export { ClientInstance }
|
|
246
300
|
export { ClientInstance as ClientInstance_alias_1 }
|
|
@@ -342,8 +396,8 @@ export { makeMutation as makeMutation_alias_1 }
|
|
|
342
396
|
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
397
|
(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
398
|
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):
|
|
399
|
+
use(params: ClientQueryArgs): UseQueryResult<NoInfer_2<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown>, Error>;
|
|
400
|
+
useSuspense(params: ClientQueryArgs): UseSuspenseQueryResult<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown, Error>;
|
|
347
401
|
invalidate(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
348
402
|
invalidateAll(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
349
403
|
};
|
|
@@ -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';
|
|
@@ -142,9 +142,7 @@ declare interface ClientInstance {
|
|
|
142
142
|
useContext?: () => Context;
|
|
143
143
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
144
144
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
145
|
-
}): (
|
|
146
|
-
urlParams: UrlParams<Url>;
|
|
147
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, QuerySchema>> & ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>;
|
|
145
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, QuerySchema>>) & ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>;
|
|
148
146
|
mutation<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(config: {
|
|
149
147
|
method: Method;
|
|
150
148
|
url: Url;
|
|
@@ -154,9 +152,7 @@ declare interface ClientInstance {
|
|
|
154
152
|
useContext?: () => Context;
|
|
155
153
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
156
154
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
157
|
-
}): ((
|
|
158
|
-
urlParams: UrlParams<Url>;
|
|
159
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response>;
|
|
155
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response>;
|
|
160
156
|
mutation<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(config: {
|
|
161
157
|
method: Method;
|
|
162
158
|
url: Url;
|
|
@@ -167,9 +163,7 @@ declare interface ClientInstance {
|
|
|
167
163
|
useContext?: () => Context;
|
|
168
164
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
169
165
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
170
|
-
}): ((params: UrlHasParams<Url> extends true ? {
|
|
171
|
-
urlParams: UrlParams<Url>;
|
|
172
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response>;
|
|
166
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response>;
|
|
173
167
|
mutation<Method extends 'DELETE' = 'DELETE', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(config: {
|
|
174
168
|
method: Method;
|
|
175
169
|
url: Url;
|
|
@@ -180,9 +174,7 @@ declare interface ClientInstance {
|
|
|
180
174
|
useContext?: () => Context;
|
|
181
175
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
182
176
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
183
|
-
}): ((params: UrlHasParams<Url> extends true ? {
|
|
184
|
-
urlParams: UrlParams<Url>;
|
|
185
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
177
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
186
178
|
mutation<Method extends 'DELETE' = 'DELETE', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(config: {
|
|
187
179
|
method: Method;
|
|
188
180
|
url: Url;
|
|
@@ -192,9 +184,7 @@ declare interface ClientInstance {
|
|
|
192
184
|
useContext?: () => Context;
|
|
193
185
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
194
186
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
195
|
-
}): (
|
|
196
|
-
urlParams: UrlParams<Url>;
|
|
197
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>> & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
187
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
198
188
|
mutation<Method extends 'DELETE' = 'DELETE', Url extends string = string, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(config: {
|
|
199
189
|
method: Method;
|
|
200
190
|
url: Url;
|
|
@@ -204,9 +194,7 @@ declare interface ClientInstance {
|
|
|
204
194
|
useContext?: () => Context;
|
|
205
195
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
206
196
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
207
|
-
}): ((params: UrlHasParams<Url> extends true ? {
|
|
208
|
-
urlParams: UrlParams<Url>;
|
|
209
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response>;
|
|
197
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response>;
|
|
210
198
|
mutation<Method extends 'DELETE' = 'DELETE', Url extends string = string, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(config: {
|
|
211
199
|
method: Method;
|
|
212
200
|
url: Url;
|
|
@@ -215,9 +203,7 @@ declare interface ClientInstance {
|
|
|
215
203
|
useContext?: () => Context;
|
|
216
204
|
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
217
205
|
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
218
|
-
}): (
|
|
219
|
-
urlParams: UrlParams<Url>;
|
|
220
|
-
} : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>> & ClientEndpointHelper<Method, Url, undefined, Response>;
|
|
206
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & ClientEndpointHelper<Method, Url, undefined, Response>;
|
|
221
207
|
queryFromEndpoint<Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, Result = z.output<Response>>(endpoint: any & {
|
|
222
208
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>;
|
|
223
209
|
}, options?: {
|
|
@@ -229,18 +215,86 @@ declare interface ClientInstance {
|
|
|
229
215
|
config: BaseEndpointConfig<Method, Url, undefined, Response>;
|
|
230
216
|
}, options?: {
|
|
231
217
|
processResponse?: (data: z.output<Response>) => Result;
|
|
232
|
-
}): (params: UrlHasParams<Url> extends true ? {
|
|
218
|
+
}): ((params: UrlHasParams<Url> extends true ? {
|
|
233
219
|
urlParams: UrlParams<Url>;
|
|
234
|
-
} : {}) => UseSuspenseQueryOptions<Result, Error, Result, DataTag<Split<Url, '/'>, Result, Error>> & QueryHelpers<Url, undefined, Result>;
|
|
220
|
+
} : {}) => UseSuspenseQueryOptions<Result, Error, Result, DataTag<Split<Url, '/'>, Result, Error>>) & QueryHelpers<Url, undefined, Result>;
|
|
235
221
|
infiniteQueryFromEndpoint<Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, PageResult = z.output<Response>, Result = InfiniteData<PageResult>>(endpoint: any & {
|
|
236
222
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>;
|
|
237
223
|
}, options: {
|
|
238
224
|
processResponse?: (data: z.output<Response>) => PageResult;
|
|
239
225
|
getNextPageParam: (lastPage: PageResult, allPages: PageResult[], lastPageParam: z.infer<QuerySchema> | undefined, allPageParams: z.infer<QuerySchema>[] | undefined) => z.input<QuerySchema> | undefined;
|
|
240
226
|
getPreviousPageParam?: (firstPage: PageResult, allPages: PageResult[], lastPageParam: z.infer<QuerySchema> | undefined, allPageParams: z.infer<QuerySchema>[] | undefined) => z.input<QuerySchema>;
|
|
241
|
-
}): (params: UrlHasParams<Url> extends true ? {
|
|
227
|
+
}): ((params: UrlHasParams<Url> extends true ? {
|
|
242
228
|
urlParams: UrlParams<Url>;
|
|
243
|
-
} : {}) => UseSuspenseInfiniteQueryOptions<PageResult, Error, Result, PageResult, DataTag<Split<Url, '/'>, PageResult, Error>, z.output<QuerySchema>> & QueryHelpers<Url, QuerySchema, PageResult, true>;
|
|
229
|
+
} : {}) => UseSuspenseInfiniteQueryOptions<PageResult, Error, Result, PageResult, DataTag<Split<Url, '/'>, PageResult, Error>, z.output<QuerySchema>>) & QueryHelpers<Url, QuerySchema, PageResult, true>;
|
|
230
|
+
mutationFromEndpoint<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(endpoint: any & {
|
|
231
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response, RequestSchema>;
|
|
232
|
+
}, mutationOptions: {
|
|
233
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
234
|
+
useKey: UseKey;
|
|
235
|
+
useContext?: () => Context;
|
|
236
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
237
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
238
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, QuerySchema>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>;
|
|
239
|
+
mutationFromEndpoint<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(endpoint: any & {
|
|
240
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response, RequestSchema>;
|
|
241
|
+
}, mutationOptions: {
|
|
242
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
243
|
+
useKey: UseKey;
|
|
244
|
+
useContext?: () => Context;
|
|
245
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
246
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
247
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, RequestSchema, Response, undefined>;
|
|
248
|
+
mutationFromEndpoint<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(endpoint: any & {
|
|
249
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response, RequestSchema>;
|
|
250
|
+
}, mutationOptions: {
|
|
251
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
252
|
+
useContext?: () => Context;
|
|
253
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
254
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
255
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, QuerySchema>>) & ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>;
|
|
256
|
+
mutationFromEndpoint<Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH', Url extends string = string, RequestSchema extends ZodType = ZodType, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(endpoint: any & {
|
|
257
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response, RequestSchema>;
|
|
258
|
+
}, mutationOptions: {
|
|
259
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
260
|
+
useContext?: () => Context;
|
|
261
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
262
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, undefined>>, context: Context) => void | Promise<void>;
|
|
263
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, RequestSchema, undefined>>) & ClientEndpointHelper<Method, Url, RequestSchema, Response, undefined>;
|
|
264
|
+
mutationFromEndpoint<Method extends 'DELETE' = 'DELETE', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(endpoint: any & {
|
|
265
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>;
|
|
266
|
+
}, mutationOptions: {
|
|
267
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
268
|
+
useKey: UseKey;
|
|
269
|
+
useContext?: () => Context;
|
|
270
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
271
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
272
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
273
|
+
mutationFromEndpoint<Method extends 'DELETE' = 'DELETE', Url extends string = string, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends true = true>(endpoint: any & {
|
|
274
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response>;
|
|
275
|
+
}, mutationOptions: {
|
|
276
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
277
|
+
useKey: UseKey;
|
|
278
|
+
useContext?: () => Context;
|
|
279
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
280
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
281
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & MutationHelpers<Url, Result> & ClientEndpointHelper<Method, Url, undefined, Response, undefined>;
|
|
282
|
+
mutationFromEndpoint<Method extends 'DELETE' = 'DELETE', Url extends string = string, QuerySchema extends AnyZodObject = AnyZodObject, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(endpoint: any & {
|
|
283
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>;
|
|
284
|
+
}, mutationOptions: {
|
|
285
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
286
|
+
useContext?: () => Context;
|
|
287
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
288
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
289
|
+
}): (() => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, QuerySchema>>) & ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>;
|
|
290
|
+
mutationFromEndpoint<Method extends 'DELETE' = 'DELETE', Url extends string = string, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown>(endpoint: any & {
|
|
291
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response>;
|
|
292
|
+
}, mutationOptions: {
|
|
293
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
294
|
+
useContext?: () => Context;
|
|
295
|
+
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
296
|
+
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>, context: Context) => void | Promise<void>;
|
|
297
|
+
}): ((params: UrlHasParams<Url> extends true ? UrlParams<Url> : {}) => UseMutationResult<Result, Error, ClientMutationArgs<Url, undefined, undefined>>) & ClientEndpointHelper<Method, Url, undefined, Response, undefined>;
|
|
244
298
|
}
|
|
245
299
|
export { ClientInstance }
|
|
246
300
|
export { ClientInstance as ClientInstance_alias_1 }
|
|
@@ -342,8 +396,8 @@ export { makeMutation as makeMutation_alias_1 }
|
|
|
342
396
|
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
397
|
(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
398
|
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):
|
|
399
|
+
use(params: ClientQueryArgs): UseQueryResult<NoInfer_2<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown>, Error>;
|
|
400
|
+
useSuspense(params: ClientQueryArgs): UseSuspenseQueryResult<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown, Error>;
|
|
347
401
|
invalidate(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
348
402
|
invalidateAll(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
349
403
|
};
|
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({
|
|
@@ -326,6 +326,16 @@ function declareClient({
|
|
|
326
326
|
useMutation2.endpoint = endpoint;
|
|
327
327
|
return useMutation2;
|
|
328
328
|
}
|
|
329
|
+
function mutationFromEndpoint(endpoint, options) {
|
|
330
|
+
return makeMutation(endpoint, {
|
|
331
|
+
processResponse: options.processResponse,
|
|
332
|
+
useContext: options.useContext,
|
|
333
|
+
onSuccess: options.onSuccess,
|
|
334
|
+
// @ts-expect-error simplify types here
|
|
335
|
+
onError: options.onError,
|
|
336
|
+
...defaults
|
|
337
|
+
});
|
|
338
|
+
}
|
|
329
339
|
return {
|
|
330
340
|
// @ts-expect-error We simplified types here
|
|
331
341
|
query,
|
|
@@ -336,7 +346,9 @@ function declareClient({
|
|
|
336
346
|
// @ts-expect-error We simplified types here
|
|
337
347
|
infiniteQueryFromEndpoint,
|
|
338
348
|
// @ts-expect-error We simplified types here
|
|
339
|
-
mutation
|
|
349
|
+
mutation,
|
|
350
|
+
// @ts-expect-error We simplified types here
|
|
351
|
+
mutationFromEndpoint
|
|
340
352
|
};
|
|
341
353
|
}
|
|
342
354
|
// Annotate the CommonJS export names for ESM import in node:
|
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({
|
|
@@ -307,6 +303,16 @@ function declareClient({
|
|
|
307
303
|
useMutation2.endpoint = endpoint;
|
|
308
304
|
return useMutation2;
|
|
309
305
|
}
|
|
306
|
+
function mutationFromEndpoint(endpoint, options) {
|
|
307
|
+
return makeMutation(endpoint, {
|
|
308
|
+
processResponse: options.processResponse,
|
|
309
|
+
useContext: options.useContext,
|
|
310
|
+
onSuccess: options.onSuccess,
|
|
311
|
+
// @ts-expect-error simplify types here
|
|
312
|
+
onError: options.onError,
|
|
313
|
+
...defaults
|
|
314
|
+
});
|
|
315
|
+
}
|
|
310
316
|
return {
|
|
311
317
|
// @ts-expect-error We simplified types here
|
|
312
318
|
query,
|
|
@@ -317,7 +323,9 @@ function declareClient({
|
|
|
317
323
|
// @ts-expect-error We simplified types here
|
|
318
324
|
infiniteQueryFromEndpoint,
|
|
319
325
|
// @ts-expect-error We simplified types here
|
|
320
|
-
mutation
|
|
326
|
+
mutation,
|
|
327
|
+
// @ts-expect-error We simplified types here
|
|
328
|
+
mutationFromEndpoint
|
|
321
329
|
};
|
|
322
330
|
}
|
|
323
331
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navios/react-query",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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.5",
|
|
19
19
|
"@tanstack/react-query": "^5.51.21",
|
|
20
20
|
"zod": "^3.23.8"
|
|
21
21
|
},
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"./package.json": "./package.json"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@navios/common": "^0.1.
|
|
36
|
+
"@navios/common": "^0.1.5",
|
|
37
37
|
"@tanstack/react-query": "^5.75.7",
|
|
38
|
-
"navios": "^0.
|
|
38
|
+
"navios": "^0.5.0",
|
|
39
39
|
"react": "^19.1.0",
|
|
40
40
|
"typescript": "^5.8.3",
|
|
41
41
|
"zod": "^3.24.4"
|
package/src/declare-client.mts
CHANGED
|
@@ -211,6 +211,35 @@ export function declareClient<Options extends ClientOptions>({
|
|
|
211
211
|
return useMutation
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
function mutationFromEndpoint(
|
|
215
|
+
endpoint: AbstractEndpoint<AnyEndpointConfig>,
|
|
216
|
+
options: {
|
|
217
|
+
processResponse: ProcessResponseFunction
|
|
218
|
+
useContext?: () => unknown
|
|
219
|
+
onSuccess?: (
|
|
220
|
+
queryClient: QueryClient,
|
|
221
|
+
data: unknown,
|
|
222
|
+
variables: Util_FlatObject<ClientMutationArgs>,
|
|
223
|
+
context: unknown,
|
|
224
|
+
) => void | Promise<void>
|
|
225
|
+
onError?: (
|
|
226
|
+
queryClient: QueryClient,
|
|
227
|
+
error: Error,
|
|
228
|
+
variables: Util_FlatObject<ClientMutationArgs>,
|
|
229
|
+
context: unknown,
|
|
230
|
+
) => void | Promise<void>
|
|
231
|
+
},
|
|
232
|
+
) {
|
|
233
|
+
return makeMutation(endpoint, {
|
|
234
|
+
processResponse: options.processResponse,
|
|
235
|
+
useContext: options.useContext,
|
|
236
|
+
onSuccess: options.onSuccess,
|
|
237
|
+
// @ts-expect-error simplify types here
|
|
238
|
+
onError: options.onError,
|
|
239
|
+
...defaults,
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
|
|
214
243
|
return {
|
|
215
244
|
// @ts-expect-error We simplified types here
|
|
216
245
|
query,
|
|
@@ -222,5 +251,7 @@ export function declareClient<Options extends ClientOptions>({
|
|
|
222
251
|
infiniteQueryFromEndpoint,
|
|
223
252
|
// @ts-expect-error We simplified types here
|
|
224
253
|
mutation,
|
|
254
|
+
// @ts-expect-error We simplified types here
|
|
255
|
+
mutationFromEndpoint,
|
|
225
256
|
}
|
|
226
257
|
}
|
|
@@ -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) => {
|
|
@@ -182,13 +182,11 @@ export interface ClientInstance {
|
|
|
182
182
|
>,
|
|
183
183
|
context: Context,
|
|
184
184
|
) => void | Promise<void>
|
|
185
|
-
}): (
|
|
186
|
-
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
187
|
-
) => UseMutationResult<
|
|
185
|
+
}): (() => UseMutationResult<
|
|
188
186
|
Result,
|
|
189
187
|
Error,
|
|
190
188
|
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
191
|
-
> &
|
|
189
|
+
>) &
|
|
192
190
|
ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
193
191
|
|
|
194
192
|
mutation<
|
|
@@ -222,9 +220,7 @@ export interface ClientInstance {
|
|
|
222
220
|
>,
|
|
223
221
|
context: Context,
|
|
224
222
|
) => void | Promise<void>
|
|
225
|
-
}): ((
|
|
226
|
-
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
227
|
-
) => UseMutationResult<
|
|
223
|
+
}): (() => UseMutationResult<
|
|
228
224
|
Result,
|
|
229
225
|
Error,
|
|
230
226
|
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
@@ -266,7 +262,7 @@ export interface ClientInstance {
|
|
|
266
262
|
context: Context,
|
|
267
263
|
) => void | Promise<void>
|
|
268
264
|
}): ((
|
|
269
|
-
params: UrlHasParams<Url> extends true ?
|
|
265
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
270
266
|
) => UseMutationResult<
|
|
271
267
|
Result,
|
|
272
268
|
Error,
|
|
@@ -309,7 +305,7 @@ export interface ClientInstance {
|
|
|
309
305
|
context: Context,
|
|
310
306
|
) => void | Promise<void>
|
|
311
307
|
}): ((
|
|
312
|
-
params: UrlHasParams<Url> extends true ?
|
|
308
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
313
309
|
) => UseMutationResult<
|
|
314
310
|
Result,
|
|
315
311
|
Error,
|
|
@@ -349,13 +345,11 @@ export interface ClientInstance {
|
|
|
349
345
|
>,
|
|
350
346
|
context: Context,
|
|
351
347
|
) => void | Promise<void>
|
|
352
|
-
}): (
|
|
353
|
-
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
354
|
-
) => UseMutationResult<
|
|
348
|
+
}): (() => UseMutationResult<
|
|
355
349
|
Result,
|
|
356
350
|
Error,
|
|
357
351
|
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
358
|
-
> &
|
|
352
|
+
>) &
|
|
359
353
|
ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
360
354
|
|
|
361
355
|
mutation<
|
|
@@ -386,7 +380,7 @@ export interface ClientInstance {
|
|
|
386
380
|
context: Context,
|
|
387
381
|
) => void | Promise<void>
|
|
388
382
|
}): ((
|
|
389
|
-
params: UrlHasParams<Url> extends true ?
|
|
383
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
390
384
|
) => UseMutationResult<
|
|
391
385
|
Result,
|
|
392
386
|
Error,
|
|
@@ -420,13 +414,11 @@ export interface ClientInstance {
|
|
|
420
414
|
variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>,
|
|
421
415
|
context: Context,
|
|
422
416
|
) => void | Promise<void>
|
|
423
|
-
}): (
|
|
424
|
-
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
425
|
-
) => UseMutationResult<
|
|
417
|
+
}): (() => UseMutationResult<
|
|
426
418
|
Result,
|
|
427
419
|
Error,
|
|
428
420
|
ClientMutationArgs<Url, undefined, undefined>
|
|
429
|
-
> &
|
|
421
|
+
>) &
|
|
430
422
|
ClientEndpointHelper<Method, Url, undefined, Response>
|
|
431
423
|
|
|
432
424
|
queryFromEndpoint<
|
|
@@ -464,14 +456,14 @@ export interface ClientInstance {
|
|
|
464
456
|
options?: {
|
|
465
457
|
processResponse?: (data: z.output<Response>) => Result
|
|
466
458
|
},
|
|
467
|
-
): (
|
|
459
|
+
): ((
|
|
468
460
|
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
469
461
|
) => UseSuspenseQueryOptions<
|
|
470
462
|
Result,
|
|
471
463
|
Error,
|
|
472
464
|
Result,
|
|
473
465
|
DataTag<Split<Url, '/'>, Result, Error>
|
|
474
|
-
> &
|
|
466
|
+
>) &
|
|
475
467
|
QueryHelpers<Url, undefined, Result>
|
|
476
468
|
|
|
477
469
|
infiniteQueryFromEndpoint<
|
|
@@ -500,7 +492,7 @@ export interface ClientInstance {
|
|
|
500
492
|
allPageParams: z.infer<QuerySchema>[] | undefined,
|
|
501
493
|
) => z.input<QuerySchema>
|
|
502
494
|
},
|
|
503
|
-
): (
|
|
495
|
+
): ((
|
|
504
496
|
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
505
497
|
) => UseSuspenseInfiniteQueryOptions<
|
|
506
498
|
PageResult,
|
|
@@ -509,6 +501,364 @@ export interface ClientInstance {
|
|
|
509
501
|
PageResult,
|
|
510
502
|
DataTag<Split<Url, '/'>, PageResult, Error>,
|
|
511
503
|
z.output<QuerySchema>
|
|
512
|
-
> &
|
|
504
|
+
>) &
|
|
513
505
|
QueryHelpers<Url, QuerySchema, PageResult, true>
|
|
506
|
+
|
|
507
|
+
mutationFromEndpoint<
|
|
508
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
509
|
+
Url extends string = string,
|
|
510
|
+
RequestSchema extends ZodType = ZodType,
|
|
511
|
+
QuerySchema extends AnyZodObject = AnyZodObject,
|
|
512
|
+
Response extends ZodType = ZodType,
|
|
513
|
+
ReqResult = z.output<Response>,
|
|
514
|
+
Result = unknown,
|
|
515
|
+
Context = unknown,
|
|
516
|
+
UseKey extends true = true,
|
|
517
|
+
>(
|
|
518
|
+
endpoint: any & {
|
|
519
|
+
config: BaseEndpointConfig<
|
|
520
|
+
Method,
|
|
521
|
+
Url,
|
|
522
|
+
QuerySchema,
|
|
523
|
+
Response,
|
|
524
|
+
RequestSchema
|
|
525
|
+
>
|
|
526
|
+
},
|
|
527
|
+
mutationOptions: {
|
|
528
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
529
|
+
useKey: UseKey
|
|
530
|
+
useContext?: () => Context
|
|
531
|
+
onSuccess?: (
|
|
532
|
+
queryClient: QueryClient,
|
|
533
|
+
data: NoInfer<Result>,
|
|
534
|
+
variables: Util_FlatObject<
|
|
535
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
536
|
+
>,
|
|
537
|
+
context: Context,
|
|
538
|
+
) => void | Promise<void>
|
|
539
|
+
onError?: (
|
|
540
|
+
queryClient: QueryClient,
|
|
541
|
+
error: Error,
|
|
542
|
+
variables: Util_FlatObject<
|
|
543
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
544
|
+
>,
|
|
545
|
+
context: Context,
|
|
546
|
+
) => void | Promise<void>
|
|
547
|
+
},
|
|
548
|
+
): ((
|
|
549
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
550
|
+
) => UseMutationResult<
|
|
551
|
+
Result,
|
|
552
|
+
Error,
|
|
553
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
554
|
+
>) &
|
|
555
|
+
MutationHelpers<Url, Result> &
|
|
556
|
+
ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
557
|
+
|
|
558
|
+
mutationFromEndpoint<
|
|
559
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
560
|
+
Url extends string = string,
|
|
561
|
+
RequestSchema extends ZodType = ZodType,
|
|
562
|
+
Response extends ZodType = ZodType,
|
|
563
|
+
ReqResult = z.output<Response>,
|
|
564
|
+
Result = unknown,
|
|
565
|
+
Context = unknown,
|
|
566
|
+
UseKey extends true = true,
|
|
567
|
+
>(
|
|
568
|
+
endpoint: any & {
|
|
569
|
+
config: BaseEndpointConfig<
|
|
570
|
+
Method,
|
|
571
|
+
Url,
|
|
572
|
+
undefined,
|
|
573
|
+
Response,
|
|
574
|
+
RequestSchema
|
|
575
|
+
>
|
|
576
|
+
},
|
|
577
|
+
mutationOptions: {
|
|
578
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
579
|
+
useKey: UseKey
|
|
580
|
+
useContext?: () => Context
|
|
581
|
+
onSuccess?: (
|
|
582
|
+
queryClient: QueryClient,
|
|
583
|
+
data: NoInfer<Result>,
|
|
584
|
+
variables: Util_FlatObject<
|
|
585
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
586
|
+
>,
|
|
587
|
+
context: Context,
|
|
588
|
+
) => void | Promise<void>
|
|
589
|
+
onError?: (
|
|
590
|
+
queryClient: QueryClient,
|
|
591
|
+
error: Error,
|
|
592
|
+
variables: Util_FlatObject<
|
|
593
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
594
|
+
>,
|
|
595
|
+
context: Context,
|
|
596
|
+
) => void | Promise<void>
|
|
597
|
+
},
|
|
598
|
+
): ((
|
|
599
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
600
|
+
) => UseMutationResult<
|
|
601
|
+
Result,
|
|
602
|
+
Error,
|
|
603
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
604
|
+
>) &
|
|
605
|
+
MutationHelpers<Url, Result> &
|
|
606
|
+
ClientEndpointHelper<Method, Url, RequestSchema, Response, undefined>
|
|
607
|
+
|
|
608
|
+
mutationFromEndpoint<
|
|
609
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
610
|
+
Url extends string = string,
|
|
611
|
+
RequestSchema extends ZodType = ZodType,
|
|
612
|
+
QuerySchema extends AnyZodObject = AnyZodObject,
|
|
613
|
+
Response extends ZodType = ZodType,
|
|
614
|
+
ReqResult = z.output<Response>,
|
|
615
|
+
Result = unknown,
|
|
616
|
+
Context = unknown,
|
|
617
|
+
>(
|
|
618
|
+
endpoint: any & {
|
|
619
|
+
config: BaseEndpointConfig<
|
|
620
|
+
Method,
|
|
621
|
+
Url,
|
|
622
|
+
QuerySchema,
|
|
623
|
+
Response,
|
|
624
|
+
RequestSchema
|
|
625
|
+
>
|
|
626
|
+
},
|
|
627
|
+
mutationOptions: {
|
|
628
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
629
|
+
useContext?: () => Context
|
|
630
|
+
onSuccess?: (
|
|
631
|
+
queryClient: QueryClient,
|
|
632
|
+
data: NoInfer<Result>,
|
|
633
|
+
variables: Util_FlatObject<
|
|
634
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
635
|
+
>,
|
|
636
|
+
context: Context,
|
|
637
|
+
) => void | Promise<void>
|
|
638
|
+
onError?: (
|
|
639
|
+
queryClient: QueryClient,
|
|
640
|
+
error: Error,
|
|
641
|
+
variables: Util_FlatObject<
|
|
642
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
643
|
+
>,
|
|
644
|
+
context: Context,
|
|
645
|
+
) => void | Promise<void>
|
|
646
|
+
},
|
|
647
|
+
): (() => UseMutationResult<
|
|
648
|
+
Result,
|
|
649
|
+
Error,
|
|
650
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
651
|
+
>) &
|
|
652
|
+
ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
653
|
+
|
|
654
|
+
mutationFromEndpoint<
|
|
655
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
656
|
+
Url extends string = string,
|
|
657
|
+
RequestSchema extends ZodType = ZodType,
|
|
658
|
+
Response extends ZodType = ZodType,
|
|
659
|
+
ReqResult = z.output<Response>,
|
|
660
|
+
Result = unknown,
|
|
661
|
+
Context = unknown,
|
|
662
|
+
>(
|
|
663
|
+
endpoint: any & {
|
|
664
|
+
config: BaseEndpointConfig<
|
|
665
|
+
Method,
|
|
666
|
+
Url,
|
|
667
|
+
undefined,
|
|
668
|
+
Response,
|
|
669
|
+
RequestSchema
|
|
670
|
+
>
|
|
671
|
+
},
|
|
672
|
+
mutationOptions: {
|
|
673
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
674
|
+
useContext?: () => Context
|
|
675
|
+
onSuccess?: (
|
|
676
|
+
queryClient: QueryClient,
|
|
677
|
+
data: NoInfer<Result>,
|
|
678
|
+
variables: Util_FlatObject<
|
|
679
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
680
|
+
>,
|
|
681
|
+
context: Context,
|
|
682
|
+
) => void | Promise<void>
|
|
683
|
+
onError?: (
|
|
684
|
+
queryClient: QueryClient,
|
|
685
|
+
error: Error,
|
|
686
|
+
variables: Util_FlatObject<
|
|
687
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
688
|
+
>,
|
|
689
|
+
context: Context,
|
|
690
|
+
) => void | Promise<void>
|
|
691
|
+
},
|
|
692
|
+
): (() => UseMutationResult<
|
|
693
|
+
Result,
|
|
694
|
+
Error,
|
|
695
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
696
|
+
>) &
|
|
697
|
+
ClientEndpointHelper<Method, Url, RequestSchema, Response, undefined>
|
|
698
|
+
|
|
699
|
+
mutationFromEndpoint<
|
|
700
|
+
Method extends 'DELETE' = 'DELETE',
|
|
701
|
+
Url extends string = string,
|
|
702
|
+
QuerySchema extends AnyZodObject = AnyZodObject,
|
|
703
|
+
Response extends ZodType = ZodType,
|
|
704
|
+
ReqResult = z.output<Response>,
|
|
705
|
+
Result = unknown,
|
|
706
|
+
Context = unknown,
|
|
707
|
+
UseKey extends true = true,
|
|
708
|
+
>(
|
|
709
|
+
endpoint: any & {
|
|
710
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
711
|
+
},
|
|
712
|
+
mutationOptions: {
|
|
713
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
714
|
+
useKey: UseKey
|
|
715
|
+
useContext?: () => Context
|
|
716
|
+
onSuccess?: (
|
|
717
|
+
queryClient: QueryClient,
|
|
718
|
+
data: NoInfer<Result>,
|
|
719
|
+
variables: Util_FlatObject<
|
|
720
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
721
|
+
>,
|
|
722
|
+
context: Context,
|
|
723
|
+
) => void | Promise<void>
|
|
724
|
+
onError?: (
|
|
725
|
+
queryClient: QueryClient,
|
|
726
|
+
error: Error,
|
|
727
|
+
variables: Util_FlatObject<
|
|
728
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
729
|
+
>,
|
|
730
|
+
context: Context,
|
|
731
|
+
) => void | Promise<void>
|
|
732
|
+
},
|
|
733
|
+
): ((
|
|
734
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
735
|
+
) => UseMutationResult<
|
|
736
|
+
Result,
|
|
737
|
+
Error,
|
|
738
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
739
|
+
>) &
|
|
740
|
+
MutationHelpers<Url, Result> &
|
|
741
|
+
ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
742
|
+
|
|
743
|
+
mutationFromEndpoint<
|
|
744
|
+
Method extends 'DELETE' = 'DELETE',
|
|
745
|
+
Url extends string = string,
|
|
746
|
+
Response extends ZodType = ZodType,
|
|
747
|
+
ReqResult = z.output<Response>,
|
|
748
|
+
Result = unknown,
|
|
749
|
+
Context = unknown,
|
|
750
|
+
UseKey extends true = true,
|
|
751
|
+
>(
|
|
752
|
+
endpoint: any & {
|
|
753
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
754
|
+
},
|
|
755
|
+
mutationOptions: {
|
|
756
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
757
|
+
useKey: UseKey
|
|
758
|
+
useContext?: () => Context
|
|
759
|
+
onSuccess?: (
|
|
760
|
+
queryClient: QueryClient,
|
|
761
|
+
data: NoInfer<Result>,
|
|
762
|
+
variables: Util_FlatObject<
|
|
763
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
764
|
+
>,
|
|
765
|
+
context: Context,
|
|
766
|
+
) => void | Promise<void>
|
|
767
|
+
onError?: (
|
|
768
|
+
queryClient: QueryClient,
|
|
769
|
+
error: Error,
|
|
770
|
+
variables: Util_FlatObject<
|
|
771
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
772
|
+
>,
|
|
773
|
+
context: Context,
|
|
774
|
+
) => void | Promise<void>
|
|
775
|
+
},
|
|
776
|
+
): ((
|
|
777
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
778
|
+
) => UseMutationResult<
|
|
779
|
+
Result,
|
|
780
|
+
Error,
|
|
781
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
782
|
+
>) &
|
|
783
|
+
MutationHelpers<Url, Result> &
|
|
784
|
+
ClientEndpointHelper<Method, Url, undefined, Response, undefined>
|
|
785
|
+
|
|
786
|
+
mutationFromEndpoint<
|
|
787
|
+
Method extends 'DELETE' = 'DELETE',
|
|
788
|
+
Url extends string = string,
|
|
789
|
+
QuerySchema extends AnyZodObject = AnyZodObject,
|
|
790
|
+
Response extends ZodType = ZodType,
|
|
791
|
+
ReqResult = z.output<Response>,
|
|
792
|
+
Result = unknown,
|
|
793
|
+
Context = unknown,
|
|
794
|
+
>(
|
|
795
|
+
endpoint: any & {
|
|
796
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
797
|
+
},
|
|
798
|
+
mutationOptions: {
|
|
799
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
800
|
+
useContext?: () => Context
|
|
801
|
+
onSuccess?: (
|
|
802
|
+
queryClient: QueryClient,
|
|
803
|
+
data: NoInfer<Result>,
|
|
804
|
+
variables: Util_FlatObject<
|
|
805
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
806
|
+
>,
|
|
807
|
+
context: Context,
|
|
808
|
+
) => void | Promise<void>
|
|
809
|
+
onError?: (
|
|
810
|
+
queryClient: QueryClient,
|
|
811
|
+
error: Error,
|
|
812
|
+
variables: Util_FlatObject<
|
|
813
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
814
|
+
>,
|
|
815
|
+
context: Context,
|
|
816
|
+
) => void | Promise<void>
|
|
817
|
+
},
|
|
818
|
+
): (() => UseMutationResult<
|
|
819
|
+
Result,
|
|
820
|
+
Error,
|
|
821
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
822
|
+
>) &
|
|
823
|
+
ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
824
|
+
|
|
825
|
+
mutationFromEndpoint<
|
|
826
|
+
Method extends 'DELETE' = 'DELETE',
|
|
827
|
+
Url extends string = string,
|
|
828
|
+
Response extends ZodType = ZodType,
|
|
829
|
+
ReqResult = z.output<Response>,
|
|
830
|
+
Result = unknown,
|
|
831
|
+
Context = unknown,
|
|
832
|
+
>(
|
|
833
|
+
endpoint: any & {
|
|
834
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
835
|
+
},
|
|
836
|
+
mutationOptions: {
|
|
837
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
838
|
+
useContext?: () => Context
|
|
839
|
+
onSuccess?: (
|
|
840
|
+
queryClient: QueryClient,
|
|
841
|
+
data: NoInfer<Result>,
|
|
842
|
+
variables: Util_FlatObject<
|
|
843
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
844
|
+
>,
|
|
845
|
+
context: Context,
|
|
846
|
+
) => void | Promise<void>
|
|
847
|
+
onError?: (
|
|
848
|
+
queryClient: QueryClient,
|
|
849
|
+
error: Error,
|
|
850
|
+
variables: Util_FlatObject<
|
|
851
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
852
|
+
>,
|
|
853
|
+
context: Context,
|
|
854
|
+
) => void | Promise<void>
|
|
855
|
+
},
|
|
856
|
+
): ((
|
|
857
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
858
|
+
) => UseMutationResult<
|
|
859
|
+
Result,
|
|
860
|
+
Error,
|
|
861
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
862
|
+
>) &
|
|
863
|
+
ClientEndpointHelper<Method, Url, undefined, Response, undefined>
|
|
514
864
|
}
|