@navios/react-query 0.7.0 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +166 -0
- package/README.md +152 -4
- package/dist/src/__tests__/errorSchema.spec.d.mts +2 -0
- package/dist/src/__tests__/errorSchema.spec.d.mts.map +1 -0
- package/dist/src/client/__type-tests__/from-endpoint.spec-d.d.mts +2 -0
- package/dist/src/client/__type-tests__/from-endpoint.spec-d.d.mts.map +1 -0
- package/dist/src/client/__type-tests__/infinite-query.spec-d.d.mts +2 -0
- package/dist/src/client/__type-tests__/infinite-query.spec-d.d.mts.map +1 -0
- package/dist/src/client/__type-tests__/multipart-mutation.spec-d.d.mts +2 -0
- package/dist/src/client/__type-tests__/multipart-mutation.spec-d.d.mts.map +1 -0
- package/dist/src/client/__type-tests__/mutation.spec-d.d.mts +2 -0
- package/dist/src/client/__type-tests__/mutation.spec-d.d.mts.map +1 -0
- package/dist/src/client/__type-tests__/query.spec-d.d.mts +2 -0
- package/dist/src/client/__type-tests__/query.spec-d.d.mts.map +1 -0
- package/dist/src/client/declare-client.d.mts +15 -8
- package/dist/src/client/declare-client.d.mts.map +1 -1
- package/dist/src/client/types/from-endpoint.d.mts +130 -0
- package/dist/src/client/types/from-endpoint.d.mts.map +1 -0
- package/dist/src/client/types/helpers.d.mts +74 -0
- package/dist/src/client/types/helpers.d.mts.map +1 -0
- package/dist/src/client/types/index.d.mts +21 -0
- package/dist/src/client/types/index.d.mts.map +1 -0
- package/dist/src/client/types/infinite-query.d.mts +61 -0
- package/dist/src/client/types/infinite-query.d.mts.map +1 -0
- package/dist/src/client/types/multipart-mutation.d.mts +98 -0
- package/dist/src/client/types/multipart-mutation.d.mts.map +1 -0
- package/dist/src/client/types/mutation.d.mts +75 -0
- package/dist/src/client/types/mutation.d.mts.map +1 -0
- package/dist/src/client/types/query.d.mts +65 -0
- package/dist/src/client/types/query.d.mts.map +1 -0
- package/dist/src/client/types.d.mts +1 -608
- package/dist/src/client/types.d.mts.map +1 -1
- package/dist/src/common/types.d.mts +30 -3
- package/dist/src/common/types.d.mts.map +1 -1
- package/dist/src/mutation/index.d.mts +1 -0
- package/dist/src/mutation/index.d.mts.map +1 -1
- package/dist/src/mutation/make-hook.d.mts +42 -16
- package/dist/src/mutation/make-hook.d.mts.map +1 -1
- package/dist/src/mutation/optimistic.d.mts +166 -0
- package/dist/src/mutation/optimistic.d.mts.map +1 -0
- package/dist/src/mutation/types.d.mts +51 -19
- package/dist/src/mutation/types.d.mts.map +1 -1
- package/dist/src/query/index.d.mts +1 -0
- package/dist/src/query/index.d.mts.map +1 -1
- package/dist/src/query/key-creator.d.mts.map +1 -1
- package/dist/src/query/make-infinite-options.d.mts +3 -2
- package/dist/src/query/make-infinite-options.d.mts.map +1 -1
- package/dist/src/query/make-options.d.mts +42 -12
- package/dist/src/query/make-options.d.mts.map +1 -1
- package/dist/src/query/prefetch.d.mts +245 -0
- package/dist/src/query/prefetch.d.mts.map +1 -0
- package/dist/src/query/types.d.mts +35 -17
- package/dist/src/query/types.d.mts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/index.cjs +454 -37
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1021 -598
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +1019 -596
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +441 -29
- package/lib/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/declare-client.spec.mts +1 -2
- package/src/__tests__/errorSchema.spec.mts +391 -0
- package/src/__tests__/make-mutation.spec.mts +6 -5
- package/src/__tests__/makeDataTag.spec.mts +2 -1
- package/src/__tests__/makeQueryOptions.spec.mts +2 -1
- package/src/client/__type-tests__/from-endpoint.spec-d.mts +550 -0
- package/src/client/__type-tests__/infinite-query.spec-d.mts +648 -0
- package/src/client/__type-tests__/multipart-mutation.spec-d.mts +725 -0
- package/src/client/__type-tests__/mutation.spec-d.mts +757 -0
- package/src/client/__type-tests__/query.spec-d.mts +701 -0
- package/src/client/declare-client.mts +59 -34
- package/src/client/types/from-endpoint.mts +345 -0
- package/src/client/types/helpers.mts +140 -0
- package/src/client/types/index.mts +26 -0
- package/src/client/types/infinite-query.mts +133 -0
- package/src/client/types/multipart-mutation.mts +264 -0
- package/src/client/types/mutation.mts +176 -0
- package/src/client/types/query.mts +132 -0
- package/src/client/types.mts +1 -1935
- package/src/common/types.mts +48 -3
- package/src/mutation/index.mts +1 -0
- package/src/mutation/make-hook.mts +171 -63
- package/src/mutation/optimistic.mts +294 -0
- package/src/mutation/types.mts +102 -29
- package/src/query/index.mts +1 -0
- package/src/query/key-creator.mts +24 -13
- package/src/query/make-infinite-options.mts +53 -10
- package/src/query/make-options.mts +184 -43
- package/src/query/prefetch.mts +326 -0
- package/src/query/types.mts +76 -16
- package/dist/src/declare-client.d.mts +0 -31
- package/dist/src/declare-client.d.mts.map +0 -1
- package/dist/src/make-infinite-query-options.d.mts +0 -13
- package/dist/src/make-infinite-query-options.d.mts.map +0 -1
- package/dist/src/make-mutation.d.mts +0 -15
- package/dist/src/make-mutation.d.mts.map +0 -1
- package/dist/src/make-query-options.d.mts +0 -15
- package/dist/src/make-query-options.d.mts.map +0 -1
- package/dist/src/types/client-endpoint-helper.d.mts +0 -8
- package/dist/src/types/client-endpoint-helper.d.mts.map +0 -1
- package/dist/src/types/client-instance.d.mts +0 -211
- package/dist/src/types/client-instance.d.mts.map +0 -1
- package/dist/src/types/index.d.mts +0 -8
- package/dist/src/types/index.d.mts.map +0 -1
- package/dist/src/types/mutation-args.d.mts +0 -10
- package/dist/src/types/mutation-args.d.mts.map +0 -1
- package/dist/src/types/mutation-helpers.d.mts +0 -10
- package/dist/src/types/mutation-helpers.d.mts.map +0 -1
- package/dist/src/types/query-args.d.mts +0 -8
- package/dist/src/types/query-args.d.mts.map +0 -1
- package/dist/src/types/query-helpers.d.mts +0 -14
- package/dist/src/types/query-helpers.d.mts.map +0 -1
- package/dist/src/types/query-url-params-args.d.mts +0 -5
- package/dist/src/types/query-url-params-args.d.mts.map +0 -1
- package/dist/src/types.d.mts +0 -49
- package/dist/src/types.d.mts.map +0 -1
- package/dist/src/utils/mutation-key.creator.d.mts +0 -39
- package/dist/src/utils/mutation-key.creator.d.mts.map +0 -1
- package/dist/src/utils/query-key-creator.d.mts +0 -24
- package/dist/src/utils/query-key-creator.d.mts.map +0 -1
- package/src/client/__type-tests__/client-instance.spec-d.mts +0 -852
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["result","queryOptions","infiniteQueryOptions","useMutation"],"sources":["../src/query/key-creator.mts","../src/query/make-options.mts","../src/query/make-infinite-options.mts","../src/mutation/key-creator.mts","../src/mutation/make-hook.mts","../src/client/declare-client.mts"],"sourcesContent":["import type { AnyEndpointConfig, UrlHasParams } from '@navios/builder'\nimport type { DataTag, InfiniteData } from '@tanstack/react-query'\n\nimport { bindUrlParams } from '@navios/builder'\n\nimport type { Split } from '../common/types.mjs'\nimport type { QueryKeyCreatorResult, QueryParams } from './types.mjs'\n\n/**\n * Creates a query key generator for a given endpoint configuration.\n *\n * The returned object provides methods to generate query keys that can be used\n * with TanStack Query for caching, invalidation, and data tagging.\n *\n * @param config - The endpoint configuration\n * @param options - Query parameters including processResponse and key prefix/suffix\n * @param isInfinite - Whether this is for an infinite query\n * @returns An object with methods to generate query keys\n */\nexport function createQueryKey<\n Config extends AnyEndpointConfig,\n Options extends QueryParams<Config>,\n IsInfinite extends boolean,\n Url extends Config['url'] = Config['url'],\n HasParams extends UrlHasParams<Url> = UrlHasParams<Url>,\n>(\n config: Config,\n options: Options,\n _isInfinite: IsInfinite,\n): QueryKeyCreatorResult<\n Config['querySchema'],\n Url,\n Options['processResponse'] extends (...args: any[]) => infer Result\n ? Result\n : never,\n IsInfinite,\n HasParams\n> {\n const url = config.url as Url\n const urlParts = url.split('/').filter(Boolean) as Split<Url, '/'>\n return {\n template: urlParts,\n // @ts-expect-error We have correct types in return type\n dataTag: (params) => {\n const queryParams =\n params && 'querySchema' in config && 'params' in params\n ? config.querySchema?.parse(params.params)\n : []\n return [\n ...(options.keyPrefix ?? []),\n ...urlParts.map((part) =>\n part.startsWith('$')\n ? // @ts-expect-error TS2339 We know that the urlParams are defined only if the url has params\n params.urlParams[part.slice(1)].toString()\n : part,\n ),\n ...(options.keySuffix ?? []),\n queryParams ?? [],\n ] as unknown as DataTag<\n Split<Url, '/'>,\n Options['processResponse'] extends (...args: any[]) => infer Result\n ? IsInfinite extends true\n ? InfiniteData<Result>\n : Result\n : never,\n Error\n >\n },\n // @ts-expect-error We have correct types in return type\n filterKey: (params) => {\n return [\n ...(options.keyPrefix ?? []),\n ...urlParts.map((part) =>\n part.startsWith('$')\n ? // @ts-expect-error TS2339 We know that the urlParams are defined only if the url has params\n params.urlParams[part.slice(1)].toString()\n : part,\n ),\n ...(options.keySuffix ?? []),\n ] as unknown as DataTag<\n Split<Url, '/'>,\n Options['processResponse'] extends (...args: any[]) => infer Result\n ? IsInfinite extends true\n ? InfiniteData<Result>\n : Result\n : never,\n Error\n >\n },\n\n bindToUrl: (params) => {\n return bindUrlParams<Url>(url, params ?? ({} as never))\n },\n }\n}\n\n// Legacy export for backwards compatibility\n/** @deprecated Use createQueryKey instead */\nexport const queryKeyCreator = createQueryKey\n","import type { AbstractEndpoint, AnyEndpointConfig } from '@navios/builder'\nimport type {\n DataTag,\n QueryClient,\n UseQueryOptions,\n UseSuspenseQueryOptions,\n} from '@tanstack/react-query'\n\nimport { queryOptions, useQuery, useSuspenseQuery } from '@tanstack/react-query'\n\nimport type { Split } from '../common/types.mjs'\nimport type { QueryArgs, QueryParams } from './types.mjs'\n\nimport { createQueryKey } from './key-creator.mjs'\n\n/**\n * Creates query options for a given endpoint.\n *\n * Returns a function that generates TanStack Query options when called with params.\n * The returned function also has helper methods attached (use, useSuspense, invalidate, etc.)\n *\n * @param endpoint - The navios endpoint to create query options for\n * @param options - Query configuration including processResponse\n * @param baseQuery - Optional base query options to merge\n * @returns A function that generates query options with attached helpers\n */\nexport function makeQueryOptions<\n Config extends AnyEndpointConfig,\n Options extends QueryParams<Config>,\n BaseQuery extends Omit<\n UseQueryOptions<ReturnType<Options['processResponse']>, Error, any>,\n | 'queryKey'\n | 'queryFn'\n | 'getNextPageParam'\n | 'initialPageParam'\n | 'enabled'\n | 'throwOnError'\n | 'placeholderData'\n >,\n>(\n endpoint: AbstractEndpoint<Config>,\n options: Options,\n baseQuery: BaseQuery = {} as BaseQuery,\n) {\n const config = endpoint.config\n const queryKey = createQueryKey(config, options, false)\n const processResponse = options.processResponse\n\n const result = (\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ): Options['processResponse'] extends (...args: any[]) => infer Result\n ? UseSuspenseQueryOptions<\n Result,\n Error,\n BaseQuery['select'] extends (...args: any[]) => infer T ? T : Result,\n DataTag<Split<Config['url'], '/'>, Result, Error>\n >\n : never => {\n // @ts-expect-error TS2322 We know that the processResponse is defined\n return queryOptions({\n queryKey: queryKey.dataTag(params),\n queryFn: async ({ signal }): Promise<ReturnType<Options['processResponse']>> => {\n let result\n try {\n result = await endpoint({\n signal,\n ...params,\n })\n } catch (err) {\n if (options.onFail) {\n options.onFail(err)\n }\n throw err\n }\n\n return processResponse(result) as ReturnType<Options['processResponse']>\n },\n ...baseQuery,\n })\n }\n result.queryKey = queryKey\n result.use = (params: QueryArgs<Config['url'], Config['querySchema']>) => {\n return useQuery(result(params))\n }\n\n result.useSuspense = (params: QueryArgs<Config['url'], Config['querySchema']>) => {\n return useSuspenseQuery(result(params))\n }\n\n result.invalidate = (\n queryClient: QueryClient,\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ) => {\n return queryClient.invalidateQueries({\n queryKey: result.queryKey.dataTag(params),\n })\n }\n\n result.invalidateAll = (\n queryClient: QueryClient,\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ) => {\n return queryClient.invalidateQueries({\n queryKey: result.queryKey.filterKey(params),\n exact: false,\n })\n }\n\n return result\n}\n","import type {\n AbstractEndpoint,\n AnyEndpointConfig,\n UrlParams,\n} from '@navios/builder'\nimport type {\n InfiniteData,\n QueryClient,\n UseInfiniteQueryOptions,\n UseSuspenseInfiniteQueryOptions,\n} from '@tanstack/react-query'\nimport type { z } from 'zod/v4'\n\nimport {\n infiniteQueryOptions,\n useInfiniteQuery,\n useSuspenseInfiniteQuery,\n} from '@tanstack/react-query'\n\nimport type { InfiniteQueryOptions, QueryArgs } from './types.mjs'\n\nimport { createQueryKey } from './key-creator.mjs'\n\n/**\n * Creates infinite query options for a given endpoint.\n *\n * Returns a function that generates TanStack Query infinite options when called with params.\n * The returned function also has helper methods attached (use, useSuspense, invalidate, etc.)\n *\n * @param endpoint - The navios endpoint to create infinite query options for\n * @param options - Infinite query configuration including processResponse and pagination params\n * @param baseQuery - Optional base query options to merge\n * @returns A function that generates infinite query options with attached helpers\n */\nexport function makeInfiniteQueryOptions<\n Config extends AnyEndpointConfig,\n Options extends InfiniteQueryOptions<Config>,\n BaseQuery extends Omit<\n UseInfiniteQueryOptions<ReturnType<Options['processResponse']>, Error, any>,\n | 'queryKey'\n | 'queryFn'\n | 'getNextPageParam'\n | 'initialPageParam'\n | 'placeholderData'\n | 'throwOnError'\n >,\n>(\n endpoint: AbstractEndpoint<Config>,\n options: Options,\n baseQuery: BaseQuery = {} as BaseQuery,\n) {\n const config = endpoint.config\n const queryKey = createQueryKey(config, options, true)\n\n const processResponse = options.processResponse\n const res = (\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ): Options['processResponse'] extends (...args: any[]) => infer Result\n ? UseSuspenseInfiniteQueryOptions<\n Result,\n Error,\n BaseQuery['select'] extends (...args: any[]) => infer T\n ? T\n : InfiniteData<Result>\n >\n : never => {\n // @ts-expect-error TS2322 We know that the processResponse is defined\n return infiniteQueryOptions({\n queryKey: queryKey.dataTag(params),\n queryFn: async ({ signal, pageParam }): Promise<ReturnType<Options['processResponse']>> => {\n let result\n try {\n result = await endpoint({\n signal,\n // @ts-expect-error TS2345 We bind the url params only if the url has params\n urlParams: params.urlParams as z.infer<UrlParams<Config['url']>>,\n params: {\n ...('params' in params ? params.params : {}),\n ...(pageParam as z.infer<Config['querySchema']>),\n },\n })\n } catch (err) {\n if (options.onFail) {\n options.onFail(err)\n }\n throw err\n }\n\n return processResponse(result) as ReturnType<Options['processResponse']>\n },\n getNextPageParam: options.getNextPageParam,\n getPreviousPageParam: options.getPreviousPageParam,\n initialPageParam:\n options.initialPageParam ??\n config.querySchema.parse('params' in params ? params.params : {}),\n ...baseQuery,\n })\n }\n res.queryKey = queryKey\n\n res.use = (params: QueryArgs<Config['url'], Config['querySchema']>) => {\n return useInfiniteQuery(res(params))\n }\n\n res.useSuspense = (params: QueryArgs<Config['url'], Config['querySchema']>) => {\n return useSuspenseInfiniteQuery(res(params))\n }\n\n res.invalidate = (\n queryClient: QueryClient,\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ) => {\n return queryClient.invalidateQueries({\n queryKey: res.queryKey.dataTag(params),\n })\n }\n\n res.invalidateAll = (\n queryClient: QueryClient,\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ) => {\n return queryClient.invalidateQueries({\n queryKey: res.queryKey.filterKey(params),\n exact: false,\n })\n }\n\n return res\n}\n","import type {\n AnyEndpointConfig,\n UrlHasParams,\n UrlParams,\n} from '@navios/builder'\nimport type { DataTag } from '@tanstack/react-query'\n\nimport type { QueryParams } from '../query/types.mjs'\n\nimport { createQueryKey } from '../query/key-creator.mjs'\n\n/**\n * Creates a mutation key generator for a given endpoint configuration.\n *\n * @param config - The endpoint configuration\n * @param options - Optional query parameters with a default `processResponse` function\n * @returns A function that generates mutation keys\n *\n * @example Basic usage:\n * ```typescript\n * const createMutationKey = createMutationKey(endpoint.config);\n * const mutationKey = createMutationKey({ urlParams: { id: 123 } });\n * ```\n *\n * @example Advanced usage with processResponse:\n * ```ts\n * const createMutationKey = createMutationKey(endpoint.config, {\n * processResponse: (data) => {\n * if (!data.success) {\n * throw new Error(data.message);\n * }\n * return data.data;\n * },\n * });\n * // We create a mutation that will be shared across the project for all passed userId\n * const mutationKey = createMutationKey({ urlParams: { projectId: 123, userId: 'wildcard' } });\n * ```\n */\nexport function createMutationKey<\n Config extends AnyEndpointConfig,\n Options extends QueryParams<Config>,\n Url extends Config['url'] = Config['url'],\n HasParams extends UrlHasParams<Url> = UrlHasParams<Url>,\n>(\n config: Config,\n options: Options = {\n processResponse: (data) => data,\n } as Options,\n): (\n params: HasParams extends true ? { urlParams: UrlParams<Url> } : {},\n) => Options['processResponse'] extends (...args: unknown[]) => infer Result\n ? DataTag<[Config['url']], Result, Error>\n : never {\n const queryKey = createQueryKey(config, options, false)\n\n // @ts-expect-error We have correct types in return type\n return (params) => {\n return queryKey.filterKey(params)\n }\n}\n\n// Legacy export for backwards compatibility\n/** @deprecated Use createMutationKey instead */\nexport const mutationKeyCreator = createMutationKey\n","import type {\n AbstractEndpoint,\n AnyEndpointConfig,\n NaviosZodRequest,\n UrlHasParams,\n UrlParams,\n} from '@navios/builder'\nimport type {\n MutationFunctionContext,\n UseMutationResult,\n} from '@tanstack/react-query'\nimport type { z } from 'zod/v4'\n\nimport { useIsMutating, useMutation } from '@tanstack/react-query'\n\nimport type { MutationParams } from './types.mjs'\n\nimport { createMutationKey } from './key-creator.mjs'\n\n/**\n * Creates a mutation hook for a given endpoint.\n *\n * Returns a function that when called returns a TanStack Query mutation result.\n * The returned function also has helper methods attached (mutationKey, useIsMutating).\n *\n * @param endpoint - The navios endpoint to create a mutation hook for\n * @param options - Mutation configuration including processResponse and callbacks\n * @returns A hook function that returns mutation result with attached helpers\n */\nexport function makeMutation<\n Config extends AnyEndpointConfig,\n TData = unknown,\n TVariables extends NaviosZodRequest<Config> = NaviosZodRequest<Config>,\n TResponse = z.output<Config['responseSchema']>,\n TOnMutateResult = unknown,\n TContext = unknown,\n UseKey extends boolean = false,\n>(\n endpoint: AbstractEndpoint<Config>,\n options: MutationParams<\n Config,\n TData,\n TVariables,\n TResponse,\n TOnMutateResult,\n TContext,\n UseKey\n >,\n) {\n const config = endpoint.config\n\n const mutationKey = createMutationKey(config, {\n ...options,\n processResponse: options.processResponse ?? ((data) => data),\n })\n const result = (\n keyParams: UseKey extends true\n ? UrlHasParams<Config['url']> extends true\n ? { urlParams: UrlParams<Config['url']> }\n : never\n : never,\n ): UseMutationResult<\n TData,\n Error,\n NaviosZodRequest<Config>,\n TOnMutateResult\n > => {\n const {\n useKey,\n useContext,\n onMutate,\n onError,\n onSuccess,\n onSettled,\n keyPrefix: _keyPrefix,\n keySuffix: _keySuffix,\n processResponse,\n ...rest\n } = options\n\n const ownContext = (useContext?.() as TContext) ?? {}\n\n // @ts-expect-error The types match\n return useMutation({\n ...rest,\n mutationKey: useKey ? mutationKey(keyParams) : undefined,\n scope: useKey\n ? {\n id: JSON.stringify(mutationKey(keyParams)),\n }\n : undefined,\n async mutationFn(params: TVariables) {\n const response = await endpoint(params)\n\n return (processResponse ? processResponse(response) : response) as TData\n },\n onSuccess: onSuccess\n ? (\n data: TData,\n variables: TVariables,\n onMutateResult: TOnMutateResult | undefined,\n context: MutationFunctionContext,\n ) => {\n return onSuccess?.(data, variables, {\n ...ownContext,\n ...context,\n onMutateResult,\n } as TContext &\n MutationFunctionContext & {\n onMutateResult: TOnMutateResult | undefined\n })\n }\n : undefined,\n onError: onError\n ? (\n err: Error,\n variables: TVariables,\n onMutateResult: TOnMutateResult | undefined,\n context: MutationFunctionContext,\n ) => {\n return onError?.(err, variables, {\n onMutateResult,\n ...ownContext,\n ...context,\n } as TContext &\n MutationFunctionContext & {\n onMutateResult: TOnMutateResult | undefined\n })\n }\n : undefined,\n onMutate: onMutate\n ? (variables: TVariables, context: MutationFunctionContext) => {\n return onMutate(variables, {\n ...ownContext,\n ...context,\n } as TContext & MutationFunctionContext)\n }\n : undefined,\n onSettled: onSettled\n ? (\n data: TData | undefined,\n error: Error | null,\n variables: TVariables,\n onMutateResult: TOnMutateResult | undefined,\n context: MutationFunctionContext,\n ) => {\n return onSettled(data, error, variables, {\n ...ownContext,\n ...context,\n onMutateResult,\n } as TContext &\n MutationFunctionContext & {\n onMutateResult: TOnMutateResult | undefined\n })\n }\n : undefined,\n })\n }\n result.useIsMutating = (\n keyParams: UseKey extends true\n ? UrlHasParams<Config['url']> extends true\n ? UrlParams<Config['url']>\n : never\n : never,\n ): boolean => {\n if (!options.useKey) {\n throw new Error(\n 'useIsMutating can only be used when useKey is set to true',\n )\n }\n const isMutating = useIsMutating({\n mutationKey: mutationKey({\n urlParams: keyParams,\n }),\n })\n return isMutating > 0\n }\n result.mutationKey = mutationKey\n\n return result\n}\n","import type {\n AbstractEndpoint,\n AbstractStream,\n AnyEndpointConfig,\n AnyStreamConfig,\n HttpMethod,\n} from '@navios/builder'\nimport type {\n InfiniteData,\n MutationFunctionContext,\n} from '@tanstack/react-query'\nimport type { z, ZodObject, ZodType } from 'zod/v4'\n\nimport type {\n ClientOptions,\n ProcessResponseFunction,\n} from '../common/types.mjs'\nimport type { MutationArgs } from '../mutation/types.mjs'\nimport type { ClientInstance } from './types.mjs'\n\nimport { makeMutation } from '../mutation/make-hook.mjs'\nimport { makeInfiniteQueryOptions } from '../query/make-infinite-options.mjs'\nimport { makeQueryOptions } from '../query/make-options.mjs'\n\n/**\n * Configuration for declaring a query endpoint.\n */\nexport interface QueryConfig<\n Method = HttpMethod,\n Url = string,\n QuerySchema = ZodObject,\n Response extends ZodType = ZodType,\n Result = z.output<Response>,\n RequestSchema = unknown,\n> {\n method: Method\n url: Url\n querySchema?: QuerySchema\n responseSchema: Response\n requestSchema?: RequestSchema\n processResponse?: (data: z.output<Response>) => Result\n}\n\n/**\n * Configuration for declaring an infinite query endpoint.\n */\nexport type InfiniteQueryConfig<\n Method = HttpMethod,\n Url = string,\n QuerySchema extends ZodObject = ZodObject,\n Response extends ZodType = ZodType,\n PageResult = z.output<Response>,\n Result = InfiniteData<PageResult>,\n RequestSchema = unknown,\n> = {\n method: Method\n url: Url\n querySchema: QuerySchema\n responseSchema: Response\n requestSchema?: RequestSchema\n processResponse?: (data: z.output<Response>) => PageResult\n select?: (data: InfiniteData<PageResult>) => Result\n getNextPageParam: (\n lastPage: PageResult,\n allPages: PageResult[],\n lastPageParam: z.infer<QuerySchema> | undefined,\n allPageParams: z.infer<QuerySchema>[] | undefined,\n ) => z.input<QuerySchema> | undefined\n getPreviousPageParam?: (\n firstPage: PageResult,\n allPages: PageResult[],\n lastPageParam: z.infer<QuerySchema> | undefined,\n allPageParams: z.infer<QuerySchema>[] | undefined,\n ) => z.input<QuerySchema>\n initialPageParam?: z.input<QuerySchema>\n}\n\n/**\n * Configuration for declaring a mutation endpoint.\n */\nexport interface MutationConfig<\n Method extends 'POST' | 'PUT' | 'PATCH' | 'DELETE' =\n | 'POST'\n | 'PUT'\n | 'PATCH'\n | 'DELETE',\n Url extends string = string,\n RequestSchema = Method extends 'DELETE' ? never : ZodObject,\n QuerySchema = unknown,\n Response extends ZodType = ZodType,\n ReqResult = z.output<Response>,\n Result = unknown,\n TOnMutateResult = unknown,\n Context = unknown,\n UseKey extends boolean = false,\n> {\n method: Method\n url: Url\n querySchema?: QuerySchema\n responseSchema: Response\n requestSchema?: RequestSchema\n processResponse: ProcessResponseFunction<Result, ReqResult>\n useContext?: () => Context\n onSuccess?: (\n data: Result,\n variables: MutationArgs<Url, RequestSchema, QuerySchema>,\n context: Context &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n onError?: (\n err: unknown,\n variables: MutationArgs<Url, RequestSchema, QuerySchema>,\n context: Context &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n onMutate?: (\n variables: MutationArgs<Url, RequestSchema, QuerySchema>,\n context: Context & MutationFunctionContext,\n ) => TOnMutateResult | Promise<TOnMutateResult>\n onSettled?: (\n data: Result | undefined,\n error: Error | null,\n variables: MutationArgs<Url, RequestSchema, QuerySchema>,\n context: Context &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n useKey?: UseKey\n meta?: Record<string, unknown>\n}\n\n/**\n * Creates a client instance for making type-safe queries and mutations.\n *\n * @param options - Client configuration including the API builder and defaults\n * @returns A client instance with query, infiniteQuery, and mutation methods\n *\n * @example\n * ```typescript\n * const api = createBuilder({ baseUrl: '/api' });\n * const client = declareClient({ api });\n *\n * const getUser = client.query({\n * method: 'GET',\n * url: '/users/$id',\n * responseSchema: UserSchema,\n * });\n *\n * // In a component\n * const { data } = useSuspenseQuery(getUser({ urlParams: { id: '123' } }));\n * ```\n */\nexport function declareClient<Options extends ClientOptions>({\n api,\n defaults = {},\n}: Options): ClientInstance {\n function query(config: QueryConfig) {\n const endpoint = api.declareEndpoint({\n // @ts-expect-error we accept only specific methods\n method: config.method,\n url: config.url,\n querySchema: config.querySchema,\n requestSchema: config.requestSchema,\n responseSchema: config.responseSchema,\n })\n\n const queryOptions = makeQueryOptions(endpoint, {\n ...defaults,\n processResponse: config.processResponse ?? ((data) => data),\n })\n // @ts-expect-error We attach the endpoint to the queryOptions\n queryOptions.endpoint = endpoint\n return queryOptions\n }\n\n function queryFromEndpoint(\n endpoint: AbstractEndpoint<AnyEndpointConfig>,\n options?: {\n processResponse?: (\n data: z.output<AnyEndpointConfig['responseSchema']>,\n ) => unknown\n },\n ) {\n return makeQueryOptions(endpoint, {\n ...defaults,\n processResponse: options?.processResponse ?? ((data) => data),\n })\n }\n\n function infiniteQuery(config: InfiniteQueryConfig) {\n const endpoint = api.declareEndpoint({\n // @ts-expect-error we accept only specific methods\n method: config.method,\n url: config.url,\n querySchema: config.querySchema,\n requestSchema: config.requestSchema,\n responseSchema: config.responseSchema,\n })\n const infiniteQueryOptions = makeInfiniteQueryOptions(endpoint, {\n ...defaults,\n processResponse: config.processResponse ?? ((data) => data),\n getNextPageParam: config.getNextPageParam,\n getPreviousPageParam: config.getPreviousPageParam,\n initialPageParam: config.initialPageParam,\n })\n\n // @ts-expect-error We attach the endpoint to the infiniteQueryOptions\n infiniteQueryOptions.endpoint = endpoint\n return infiniteQueryOptions\n }\n\n function infiniteQueryFromEndpoint(\n endpoint: AbstractEndpoint<AnyEndpointConfig>,\n options: {\n processResponse?: (\n data: z.output<AnyEndpointConfig['responseSchema']>,\n ) => unknown\n getNextPageParam: (\n lastPage: z.infer<AnyEndpointConfig['responseSchema']>,\n allPages: z.infer<AnyEndpointConfig['responseSchema']>[],\n lastPageParam: z.infer<AnyEndpointConfig['querySchema']> | undefined,\n allPageParams: z.infer<AnyEndpointConfig['querySchema']>[] | undefined,\n ) => z.input<AnyEndpointConfig['querySchema']> | undefined\n getPreviousPageParam?: (\n firstPage: z.infer<AnyEndpointConfig['responseSchema']>,\n allPages: z.infer<AnyEndpointConfig['responseSchema']>[],\n lastPageParam: z.infer<AnyEndpointConfig['querySchema']> | undefined,\n allPageParams: z.infer<AnyEndpointConfig['querySchema']>[] | undefined,\n ) => z.input<AnyEndpointConfig['querySchema']>\n initialPageParam?: z.input<AnyEndpointConfig['querySchema']>\n },\n ) {\n return makeInfiniteQueryOptions(endpoint, {\n ...defaults,\n processResponse: options?.processResponse ?? ((data) => data),\n getNextPageParam: options.getNextPageParam,\n getPreviousPageParam: options?.getPreviousPageParam,\n initialPageParam: options?.initialPageParam,\n })\n }\n\n function mutation(config: MutationConfig) {\n const endpoint = api.declareEndpoint({\n // @ts-expect-error We forgot about the DELETE method in original makeMutation\n method: config.method,\n url: config.url,\n querySchema: config.querySchema,\n requestSchema: config.requestSchema,\n responseSchema: config.responseSchema,\n })\n\n const useMutation = makeMutation(endpoint, {\n processResponse: config.processResponse ?? ((data) => data),\n useContext: config.useContext,\n // @ts-expect-error We forgot about the DELETE method in original makeMutation\n onSuccess: config.onSuccess,\n // @ts-expect-error We forgot about the DELETE method in original makeMutation\n onError: config.onError,\n useKey: config.useKey,\n meta: config.meta,\n ...defaults,\n })\n\n // @ts-expect-error We attach the endpoint to the useMutation\n useMutation.endpoint = endpoint\n return useMutation\n }\n\n function mutationFromEndpoint(\n endpoint:\n | AbstractEndpoint<AnyEndpointConfig>\n | AbstractStream<AnyStreamConfig>,\n options?: {\n processResponse?: ProcessResponseFunction\n useContext?: () => unknown\n onMutate?: (\n variables: MutationArgs,\n context: MutationFunctionContext & { [key: string]: unknown },\n ) => unknown | Promise<unknown>\n onSuccess?: (\n data: unknown,\n variables: MutationArgs,\n context: MutationFunctionContext & {\n onMutateResult: unknown | undefined\n [key: string]: unknown\n },\n ) => void | Promise<void>\n onError?: (\n err: unknown,\n variables: MutationArgs,\n context: MutationFunctionContext & {\n onMutateResult: unknown | undefined\n [key: string]: unknown\n },\n ) => void | Promise<void>\n onSettled?: (\n data: unknown | undefined,\n error: Error | null,\n variables: MutationArgs,\n context: MutationFunctionContext & {\n onMutateResult: unknown | undefined\n [key: string]: unknown\n },\n ) => void | Promise<void>\n useKey?: boolean\n meta?: Record<string, unknown>\n },\n ) {\n // @ts-expect-error endpoint types are compatible at runtime\n return makeMutation(endpoint, {\n processResponse: options?.processResponse,\n useContext: options?.useContext,\n onMutate: options?.onMutate,\n onSuccess: options?.onSuccess,\n onError: options?.onError,\n onSettled: options?.onSettled,\n useKey: options?.useKey,\n meta: options?.meta,\n ...defaults,\n })\n }\n\n function multipartMutation(config: MutationConfig) {\n const endpoint = api.declareMultipart({\n // @ts-expect-error we accept only specific methods\n method: config.method,\n url: config.url,\n querySchema: config.querySchema,\n requestSchema: config.requestSchema,\n responseSchema: config.responseSchema,\n })\n\n const useMutation = makeMutation(endpoint, {\n processResponse: config.processResponse ?? ((data) => data),\n useContext: config.useContext,\n // @ts-expect-error We forgot about the DELETE method in original makeMutation\n onSuccess: config.onSuccess,\n // @ts-expect-error We forgot about the DELETE method in original makeMutation\n onError: config.onError,\n // @ts-expect-error We forgot about the DELETE method in original makeMutation\n onMutate: config.onMutate,\n // @ts-expect-error We forgot about the DELETE method in original makeMutation\n onSettled: config.onSettled,\n useKey: config.useKey,\n ...defaults,\n })\n\n // @ts-expect-error We attach the endpoint to the useMutation\n useMutation.endpoint = endpoint\n return useMutation\n }\n\n return {\n // @ts-expect-error We simplified types here\n query,\n // @ts-expect-error We simplified types here\n queryFromEndpoint,\n // @ts-expect-error We simplified types here\n infiniteQuery,\n // @ts-expect-error We simplified types here\n infiniteQueryFromEndpoint,\n // @ts-expect-error We simplified types here\n mutation,\n // @ts-expect-error We simplified types here\n mutationFromEndpoint,\n // @ts-expect-error We simplified types here\n multipartMutation,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,eAOd,QACA,SACA,aASA;CACA,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,IAAI,MAAM,IAAI,CAAC,OAAO,QAAQ;AAC/C,QAAO;EACL,UAAU;EAEV,UAAU,WAAW;GACnB,MAAM,cACJ,UAAU,iBAAiB,UAAU,YAAY,SAC7C,OAAO,aAAa,MAAM,OAAO,OAAO,GACxC,EAAE;AACR,UAAO;IACL,GAAI,QAAQ,aAAa,EAAE;IAC3B,GAAG,SAAS,KAAK,SACf,KAAK,WAAW,IAAI,GAEhB,OAAO,UAAU,KAAK,MAAM,EAAE,EAAE,UAAU,GAC1C,KACL;IACD,GAAI,QAAQ,aAAa,EAAE;IAC3B,eAAe,EAAE;IAClB;;EAWH,YAAY,WAAW;AACrB,UAAO;IACL,GAAI,QAAQ,aAAa,EAAE;IAC3B,GAAG,SAAS,KAAK,SACf,KAAK,WAAW,IAAI,GAEhB,OAAO,UAAU,KAAK,MAAM,EAAE,EAAE,UAAU,GAC1C,KACL;IACD,GAAI,QAAQ,aAAa,EAAE;IAC5B;;EAWH,YAAY,WAAW;AACrB,UAAO,cAAmB,KAAK,UAAW,EAAE,CAAW;;EAE1D;;;AAKH,MAAa,kBAAkB;;;;;;;;;;;;;;;ACxE/B,SAAgB,iBAcd,UACA,SACA,YAAuB,EAAE,EACzB;CACA,MAAM,SAAS,SAAS;CACxB,MAAM,WAAW,eAAe,QAAQ,SAAS,MAAM;CACvD,MAAM,kBAAkB,Q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GACpB,eAAe,OAAO;GACtB,gBAAgB,OAAO;GACxB,CAAC;EAEF,MAAMA,gBAAc,aAAa,UAAU;GACzC,iBAAiB,OAAO,qBAAqB,SAAS;GACtD,YAAY,OAAO;GAEnB,WAAW,OAAO;GAElB,SAAS,OAAO;GAEhB,UAAU,OAAO;GAEjB,WAAW,OAAO;GAClB,QAAQ,OAAO;GACf,GAAG;GACJ,CAAC;AAGF,gBAAY,WAAW;AACvB,SAAOA;;AAGT,QAAO;EAEL;EAEA;EAEA;EAEA;EAEA;EAEA;EAEA;EACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["result","queryOptions","infiniteQueryOptions","useMutation"],"sources":["../src/query/key-creator.mts","../src/query/make-options.mts","../src/query/make-infinite-options.mts","../src/query/prefetch.mts","../src/mutation/key-creator.mts","../src/mutation/make-hook.mts","../src/mutation/optimistic.mts","../src/client/declare-client.mts"],"sourcesContent":["import type { AnyEndpointConfig, UrlHasParams } from '@navios/builder'\nimport type { DataTag, InfiniteData } from '@tanstack/react-query'\n\nimport { bindUrlParams } from '@navios/builder'\n\nimport type { Split } from '../common/types.mjs'\nimport type { QueryKeyCreatorResult, QueryParams } from './types.mjs'\n\n/**\n * Creates a query key generator for a given endpoint configuration.\n *\n * The returned object provides methods to generate query keys that can be used\n * with TanStack Query for caching, invalidation, and data tagging.\n *\n * @param config - The endpoint configuration\n * @param options - Query parameters including processResponse and key prefix/suffix\n * @param isInfinite - Whether this is for an infinite query\n * @returns An object with methods to generate query keys\n */\nexport function createQueryKey<\n Config extends AnyEndpointConfig,\n Options extends QueryParams<Config>,\n IsInfinite extends boolean,\n Url extends Config['url'] = Config['url'],\n HasParams extends UrlHasParams<Url> = UrlHasParams<Url>,\n>(\n config: Config,\n options: Options,\n _isInfinite: IsInfinite,\n): QueryKeyCreatorResult<\n Config['querySchema'],\n Url,\n Options['processResponse'] extends (...args: any[]) => infer Result\n ? Result\n : never,\n IsInfinite,\n HasParams\n> {\n const url = config.url as Url\n const urlParts = url.split('/').filter(Boolean) as Split<Url, '/'>\n return {\n template: urlParts,\n // @ts-expect-error We have correct types in return type\n dataTag: (params) => {\n const queryParams =\n params && 'querySchema' in config && 'params' in params\n ? config.querySchema?.parse(params.params)\n : []\n\n // Use bindUrlParams to get the bound URL, then split it to get the parts\n const boundUrl = bindUrlParams<Url>(\n url,\n params && 'urlParams' in params ? params : {},\n config.urlParamsSchema,\n )\n const boundUrlParts = boundUrl.split('/').filter(Boolean)\n\n return [\n ...(options.keyPrefix ?? []),\n ...boundUrlParts,\n ...(options.keySuffix ?? []),\n queryParams ?? [],\n ] as unknown as DataTag<\n Split<Url, '/'>,\n Options['processResponse'] extends (...args: any[]) => infer Result\n ? IsInfinite extends true\n ? InfiniteData<Result>\n : Result\n : never,\n Error\n >\n },\n // @ts-expect-error We have correct types in return type\n filterKey: (params) => {\n // Use bindUrlParams to get the bound URL, then split it to get the parts\n const boundUrl = bindUrlParams<Url>(\n url,\n params && 'urlParams' in params ? params : {},\n config.urlParamsSchema,\n )\n const boundUrlParts = boundUrl.split('/').filter(Boolean)\n\n return [\n ...(options.keyPrefix ?? []),\n ...boundUrlParts,\n ...(options.keySuffix ?? []),\n ] as unknown as DataTag<\n Split<Url, '/'>,\n Options['processResponse'] extends (...args: any[]) => infer Result\n ? IsInfinite extends true\n ? InfiniteData<Result>\n : Result\n : never,\n Error\n >\n },\n\n bindToUrl: (params) => {\n return bindUrlParams<Url>(\n url,\n params && 'urlParams' in params ? params : {},\n config.urlParamsSchema,\n )\n },\n }\n}\n\n// Legacy export for backwards compatibility\n/** @deprecated Use createQueryKey instead */\nexport const queryKeyCreator = createQueryKey\n","import type {\n EndpointHandler,\n EndpointOptions,\n InferEndpointReturn,\n Simplify,\n} from '@navios/builder'\nimport type {\n DataTag,\n QueryClient,\n UseQueryOptions,\n UseSuspenseQueryOptions,\n} from '@tanstack/react-query'\nimport type { ZodObject, ZodType } from 'zod/v4'\n\nimport { queryOptions, useQuery, useSuspenseQuery } from '@tanstack/react-query'\n\nimport type { Split } from '../common/types.mjs'\nimport type { QueryArgs, QueryHelpers, QueryResult } from './types.mjs'\n\nimport { createQueryKey } from './key-creator.mjs'\n\n/**\n * Options for makeQueryOptions.\n */\nexport interface MakeQueryOptionsParams<\n Options extends EndpointOptions,\n UseDiscriminator extends boolean = false,\n Result = QueryResult<Options, UseDiscriminator>,\n> {\n keyPrefix?: string[]\n keySuffix?: string[]\n onFail?: (err: unknown) => void\n processResponse: (\n data: InferEndpointReturn<Options, UseDiscriminator>,\n ) => Result\n}\n\n/**\n * Creates query options for a given endpoint.\n *\n * Returns a function that generates TanStack Query options when called with params.\n * The returned function also has helper methods attached (use, useSuspense, invalidate, etc.)\n *\n * Uses const generics pattern to automatically infer types from the endpoint configuration.\n *\n * @param endpoint - The navios endpoint handler (from builder's declareEndpoint)\n * @param options - Query configuration including processResponse\n * @param baseQuery - Optional base query options to merge\n * @returns A function that generates query options with attached helpers\n *\n * @example\n * ```ts\n * const getUser = api.declareEndpoint({\n * method: 'GET',\n * url: '/users/$userId',\n * responseSchema: userSchema,\n * })\n *\n * const queryOptions = makeQueryOptions(getUser, {\n * processResponse: (data) => data,\n * })\n *\n * const { data } = queryOptions.useSuspense({ urlParams: { userId: '123' } })\n * ```\n */\nexport function makeQueryOptions<\n const Options extends EndpointOptions,\n UseDiscriminator extends boolean = false,\n Result = QueryResult<Options, UseDiscriminator>,\n BaseQuery extends Omit<\n UseQueryOptions<Result, Error, any>,\n | 'queryKey'\n | 'queryFn'\n | 'getNextPageParam'\n | 'initialPageParam'\n | 'enabled'\n | 'throwOnError'\n | 'placeholderData'\n > = Omit<\n UseQueryOptions<Result, Error, any>,\n | 'queryKey'\n | 'queryFn'\n | 'getNextPageParam'\n | 'initialPageParam'\n | 'enabled'\n | 'throwOnError'\n | 'placeholderData'\n >,\n>(\n endpoint: EndpointHandler<Options, UseDiscriminator>,\n options: MakeQueryOptionsParams<Options, UseDiscriminator, Result>,\n baseQuery?: BaseQuery,\n): ((\n params: Simplify<\n QueryArgs<\n Options['url'],\n Options extends { querySchema: infer Q extends ZodObject }\n ? Q\n : undefined,\n Options extends { requestSchema: infer R extends ZodType } ? R : undefined\n >\n >,\n) => UseSuspenseQueryOptions<\n Result,\n Error,\n BaseQuery extends { select: (...args: any[]) => infer T } ? T : Result,\n DataTag<Split<Options['url'], '/'>, Result, Error>\n>) &\n QueryHelpers<\n Options['url'],\n Options extends { querySchema: infer Q extends ZodObject } ? Q : undefined,\n Result,\n false,\n Options extends { requestSchema: infer R extends ZodType } ? R : undefined\n > {\n const config = endpoint.config\n const queryKey = createQueryKey(config as any, options as any, false)\n const processResponse = options.processResponse\n\n const result = (\n params: Simplify<\n QueryArgs<\n Options['url'],\n Options extends { querySchema: infer Q extends ZodObject }\n ? Q\n : undefined,\n Options extends { requestSchema: infer R extends ZodType }\n ? R\n : undefined\n >\n >,\n ): any => {\n return queryOptions({\n queryKey: queryKey.dataTag(params as any),\n queryFn: async ({ signal }): Promise<Result> => {\n let result\n try {\n result = await endpoint({\n signal,\n ...params,\n } as any)\n } catch (err) {\n if (options.onFail) {\n options.onFail(err)\n }\n throw err\n }\n\n return processResponse(result)\n },\n ...baseQuery,\n })\n }\n\n /** The query key creator for this endpoint */\n result.queryKey = queryKey as any\n\n /**\n * React hook that executes the query.\n * Uses `useQuery` from TanStack Query internally.\n *\n * @param params - URL parameters, query parameters, and request body\n * @returns Query result with data, isLoading, error, etc.\n */\n result.use = (params: any) => {\n return useQuery(result(params))\n }\n\n /**\n * React hook that executes the query with Suspense support.\n * Uses `useSuspenseQuery` from TanStack Query internally.\n * The component will suspend while loading and throw on error.\n *\n * @param params - URL parameters, query parameters, and request body\n * @returns Query result with data guaranteed to be defined\n */\n result.useSuspense = (params: any) => {\n return useSuspenseQuery(result(params))\n }\n\n /**\n * Creates a function that invalidates a specific query in the cache.\n * Call the returned function to trigger the invalidation.\n *\n * @param queryClient - The TanStack Query client instance\n * @param params - The exact parameters used for this query\n * @returns A function that when called invalidates the query\n *\n * @example\n * ```ts\n * const invalidate = getUser.invalidate(queryClient, { urlParams: { userId: '123' } })\n * await invalidate() // Invalidates this specific query\n * ```\n */\n result.invalidate = (queryClient: QueryClient, params: any) => {\n return () =>\n queryClient.invalidateQueries({\n queryKey: result.queryKey.dataTag(params),\n })\n }\n\n /**\n * Creates a function that invalidates all queries matching the URL pattern.\n * Useful for invalidating all queries for a resource regardless of query params.\n *\n * @param queryClient - The TanStack Query client instance\n * @param params - URL parameters only (query params are ignored for matching)\n * @returns A function that when called invalidates all matching queries\n *\n * @example\n * ```ts\n * const invalidateAll = getUserPosts.invalidateAll(queryClient, { urlParams: { userId: '123' } })\n * await invalidateAll() // Invalidates all getUserPosts queries for user 123\n * ```\n */\n result.invalidateAll = (queryClient: QueryClient, params: any) => {\n return () =>\n queryClient.invalidateQueries({\n queryKey: result.queryKey.filterKey(params),\n exact: false,\n })\n }\n\n return result as unknown as ((\n params: Simplify<\n QueryArgs<\n Options['url'],\n Options extends { querySchema: infer Q extends ZodObject }\n ? Q\n : undefined,\n Options extends { requestSchema: infer R extends ZodType }\n ? R\n : undefined\n >\n >,\n ) => UseSuspenseQueryOptions<\n Result,\n Error,\n BaseQuery extends { select: (...args: any[]) => infer T } ? T : Result,\n DataTag<Split<Options['url'], '/'>, Result, Error>\n >) &\n QueryHelpers<\n Options['url'],\n Options extends { querySchema: infer Q extends ZodObject }\n ? Q\n : undefined,\n Result,\n false,\n Options extends { requestSchema: infer R extends ZodType } ? R : undefined\n >\n}\n","import type {\n AbstractEndpoint,\n AnyEndpointConfig,\n UrlParams,\n} from '@navios/builder'\nimport type {\n InfiniteData,\n QueryClient,\n UseInfiniteQueryOptions,\n UseSuspenseInfiniteQueryOptions,\n} from '@tanstack/react-query'\nimport type { z } from 'zod/v4'\n\nimport {\n infiniteQueryOptions,\n useInfiniteQuery,\n useSuspenseInfiniteQuery,\n} from '@tanstack/react-query'\n\nimport type { InfiniteQueryOptions, QueryArgs } from './types.mjs'\n\nimport { createQueryKey } from './key-creator.mjs'\n\n/**\n * Creates infinite query options for a given endpoint.\n *\n * Returns a function that generates TanStack Query infinite options when called with params.\n * The returned function also has helper methods attached (use, useSuspense, invalidate, etc.)\n *\n * @param endpoint - The navios endpoint to create infinite query options for\n * @param options - Infinite query configuration including processResponse and pagination params\n * @param baseQuery - Optional base query options to merge\n * @returns A function that generates infinite query options with attached helpers\n */\nexport function makeInfiniteQueryOptions<\n Config extends AnyEndpointConfig,\n Options extends InfiniteQueryOptions<Config>,\n BaseQuery extends Omit<\n UseInfiniteQueryOptions<ReturnType<Options['processResponse']>, Error, any>,\n | 'queryKey'\n | 'queryFn'\n | 'getNextPageParam'\n | 'initialPageParam'\n | 'placeholderData'\n | 'throwOnError'\n >,\n>(\n endpoint: AbstractEndpoint<Config>,\n options: Options,\n baseQuery: BaseQuery = {} as BaseQuery,\n) {\n const config = endpoint.config\n const queryKey = createQueryKey(config, options, true)\n\n const processResponse = options.processResponse\n const res = (\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ): Options['processResponse'] extends (...args: any[]) => infer Result\n ? UseSuspenseInfiniteQueryOptions<\n Result,\n Error,\n BaseQuery['select'] extends (...args: any[]) => infer T\n ? T\n : InfiniteData<Result>\n >\n : never => {\n // @ts-expect-error TS2322 We know that the processResponse is defined\n return infiniteQueryOptions({\n // @ts-expect-error TS2345 We bind the url params only if the url has params\n queryKey: queryKey.dataTag(params),\n queryFn: async ({\n signal,\n pageParam,\n }): Promise<ReturnType<Options['processResponse']>> => {\n let result\n try {\n result = await endpoint({\n signal,\n // @ts-expect-error TS2345 We bind the url params only if the url has params\n urlParams: params.urlParams as z.infer<UrlParams<Config['url']>>,\n params: {\n ...('params' in params ? params.params : {}),\n ...(pageParam as z.infer<Config['querySchema']>),\n },\n })\n } catch (err) {\n if (options.onFail) {\n options.onFail(err)\n }\n throw err\n }\n\n return processResponse(result) as ReturnType<Options['processResponse']>\n },\n getNextPageParam: options.getNextPageParam,\n getPreviousPageParam: options.getPreviousPageParam,\n initialPageParam:\n options.initialPageParam ??\n config.querySchema?.parse('params' in params ? params.params : {}) ??\n ('params' in params ? params.params : {}),\n ...baseQuery,\n })\n }\n /** The query key creator for this infinite query endpoint */\n res.queryKey = queryKey\n\n /**\n * React hook that executes the infinite query.\n * Uses `useInfiniteQuery` from TanStack Query internally.\n *\n * @param params - URL parameters and initial query parameters\n * @returns Infinite query result with pages, fetchNextPage, etc.\n */\n res.use = (params: QueryArgs<Config['url'], Config['querySchema']>) => {\n return useInfiniteQuery(res(params))\n }\n\n /**\n * React hook that executes the infinite query with Suspense support.\n * Uses `useSuspenseInfiniteQuery` from TanStack Query internally.\n * The component will suspend while loading and throw on error.\n *\n * @param params - URL parameters and initial query parameters\n * @returns Infinite query result with pages guaranteed to be defined\n */\n res.useSuspense = (\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ) => {\n return useSuspenseInfiniteQuery(res(params))\n }\n\n /**\n * Creates a function that invalidates this specific infinite query in the cache.\n * Call the returned function to trigger the invalidation.\n *\n * @param queryClient - The TanStack Query client instance\n * @param params - The exact parameters used for this query\n * @returns A function that when called invalidates the query\n */\n res.invalidate = (\n queryClient: QueryClient,\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ) => {\n return () =>\n queryClient.invalidateQueries({\n // @ts-expect-error TS2345 We bind the url params only if the url has params\n queryKey: res.queryKey.dataTag(params),\n })\n }\n\n /**\n * Creates a function that invalidates all infinite queries matching the URL pattern.\n * Useful for invalidating all queries for a resource regardless of query params.\n *\n * @param queryClient - The TanStack Query client instance\n * @param params - URL parameters only (query params are ignored for matching)\n * @returns A function that when called invalidates all matching queries\n */\n res.invalidateAll = (\n queryClient: QueryClient,\n params: QueryArgs<Config['url'], Config['querySchema']>,\n ) => {\n return () =>\n queryClient.invalidateQueries({\n // @ts-expect-error TS2345 We bind the url params only if the url has params\n queryKey: res.queryKey.filterKey(params),\n exact: false,\n })\n }\n\n return res\n}\n","import type {\n FetchQueryOptions,\n QueryClient,\n QueryKey,\n} from '@tanstack/react-query'\n\n/**\n * Type for a query options creator function that returns TanStack Query options.\n *\n * This matches the return type of `client.query()` from the navios react-query client.\n */\nexport type QueryOptionsCreator<TParams, TData, TError = Error> = (\n params: TParams,\n) => FetchQueryOptions<TData, TError, TData, QueryKey>\n\n/**\n * Helper utilities for prefetching queries.\n *\n * @template TParams - The query parameters type\n * @template TData - The query data type\n * @template TError - The error type (defaults to Error)\n */\nexport interface PrefetchHelper<TParams, TData, TError = Error> {\n /**\n * Prefetch query data on the server.\n *\n * Use this in server components or getServerSideProps to\n * prefetch data before rendering.\n *\n * @param queryClient - The QueryClient instance\n * @param params - Parameters for the query\n * @returns Promise that resolves when prefetch is complete\n *\n * @example\n * ```tsx\n * // In a Next.js Server Component\n * const queryClient = new QueryClient()\n * await prefetch.prefetch(queryClient, { urlParams: { userId: '1' } })\n * return (\n * <HydrationBoundary state={dehydrate(queryClient)}>\n * <UserProfile userId=\"1\" />\n * </HydrationBoundary>\n * )\n * ```\n */\n prefetch: (queryClient: QueryClient, params: TParams) => Promise<void>\n\n /**\n * Ensure query data exists in cache. Fetches only if not cached.\n *\n * Returns the cached or fetched data.\n *\n * @param queryClient - The QueryClient instance\n * @param params - Parameters for the query\n * @returns Promise that resolves to the query data\n *\n * @example\n * ```tsx\n * // Ensure data exists before rendering\n * const userData = await prefetch.ensureData(queryClient, {\n * urlParams: { userId: '1' },\n * })\n * console.log('User:', userData.name)\n * ```\n */\n ensureData: (queryClient: QueryClient, params: TParams) => Promise<TData>\n\n /**\n * Get the query options for a given set of parameters.\n *\n * Useful for advanced use cases or when you need to\n * customize the prefetch behavior.\n *\n * @param params - Parameters for the query\n * @returns The query options object\n *\n * @example\n * ```tsx\n * const options = prefetch.getQueryOptions({ urlParams: { userId: '1' } })\n * await queryClient.prefetchQuery({\n * ...options,\n * staleTime: 60000, // Override stale time for prefetch\n * })\n * ```\n */\n getQueryOptions: (\n params: TParams,\n ) => FetchQueryOptions<TData, TError, TData, QueryKey>\n\n /**\n * Prefetch multiple queries in parallel.\n *\n * @param queryClient - The QueryClient instance\n * @param paramsList - Array of parameters for multiple queries\n * @returns Promise that resolves when all prefetches complete\n *\n * @example\n * ```tsx\n * // Prefetch multiple users in parallel\n * await prefetch.prefetchMany(queryClient, [\n * { urlParams: { userId: '1' } },\n * { urlParams: { userId: '2' } },\n * { urlParams: { userId: '3' } },\n * ])\n * ```\n */\n prefetchMany: (\n queryClient: QueryClient,\n paramsList: TParams[],\n ) => Promise<void>\n}\n\n/**\n * Creates a type-safe prefetch helper for SSR/RSC.\n *\n * This utility wraps a query options creator to provide convenient\n * methods for server-side data fetching and hydration.\n *\n * @param queryOptionsCreator - A function that creates query options (from client.query())\n * @returns A prefetch helper object with prefetch, ensureData, and getQueryOptions methods\n *\n * @example\n * ```tsx\n * // 1. Create your query\n * const getUserQuery = client.query({\n * method: 'GET',\n * url: '/users/$userId',\n * responseSchema: userSchema,\n * })\n *\n * // 2. Create prefetch helper\n * const userPrefetch = createPrefetchHelper(getUserQuery)\n *\n * // 3. Use in server component\n * async function UserPage({ userId }: { userId: string }) {\n * const queryClient = new QueryClient()\n *\n * await userPrefetch.prefetch(queryClient, {\n * urlParams: { userId },\n * })\n *\n * return (\n * <HydrationBoundary state={dehydrate(queryClient)}>\n * <UserProfile userId={userId} />\n * </HydrationBoundary>\n * )\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With Next.js App Router\n * import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'\n * import { createPrefetchHelper } from '@navios/react-query'\n *\n * // Define queries\n * const getPostsQuery = client.query({\n * method: 'GET',\n * url: '/posts',\n * querySchema: z.object({ page: z.number() }),\n * responseSchema: postsSchema,\n * })\n *\n * const postsPrefetch = createPrefetchHelper(getPostsQuery)\n *\n * // Server Component\n * export default async function PostsPage() {\n * const queryClient = new QueryClient()\n *\n * await postsPrefetch.prefetch(queryClient, {\n * params: { page: 1 },\n * })\n *\n * return (\n * <HydrationBoundary state={dehydrate(queryClient)}>\n * <PostsList />\n * </HydrationBoundary>\n * )\n * }\n * ```\n */\nexport function createPrefetchHelper<TParams, TData, TError = Error>(\n queryOptionsCreator: QueryOptionsCreator<TParams, TData, TError>,\n): PrefetchHelper<TParams, TData, TError> {\n return {\n prefetch: async (queryClient: QueryClient, params: TParams) => {\n const options = queryOptionsCreator(params)\n await queryClient.prefetchQuery(options)\n },\n\n ensureData: async (queryClient: QueryClient, params: TParams) => {\n const options = queryOptionsCreator(params)\n return queryClient.ensureQueryData(options)\n },\n\n getQueryOptions: (params: TParams) => {\n return queryOptionsCreator(params)\n },\n\n prefetchMany: async (queryClient: QueryClient, paramsList: TParams[]) => {\n await Promise.all(\n paramsList.map((params) => {\n const options = queryOptionsCreator(params)\n return queryClient.prefetchQuery(options)\n }),\n )\n },\n }\n}\n\n/**\n * Creates multiple prefetch helpers from a record of query options creators.\n *\n * Useful when you have multiple queries that need to be prefetched together.\n *\n * @param queries - Record of query options creator functions\n * @returns Record of prefetch helpers with the same keys\n *\n * @example\n * ```tsx\n * // Define all your queries\n * const queries = {\n * user: client.query({\n * method: 'GET',\n * url: '/users/$userId',\n * responseSchema: userSchema,\n * }),\n * posts: client.query({\n * method: 'GET',\n * url: '/users/$userId/posts',\n * responseSchema: postsSchema,\n * }),\n * }\n *\n * // Create all prefetch helpers at once\n * const prefetchers = createPrefetchHelpers(queries)\n *\n * // Use in server component\n * async function UserPage({ userId }: { userId: string }) {\n * const queryClient = new QueryClient()\n *\n * await Promise.all([\n * prefetchers.user.prefetch(queryClient, { urlParams: { userId } }),\n * prefetchers.posts.prefetch(queryClient, { urlParams: { userId } }),\n * ])\n *\n * return (\n * <HydrationBoundary state={dehydrate(queryClient)}>\n * <UserProfileWithPosts userId={userId} />\n * </HydrationBoundary>\n * )\n * }\n * ```\n */\nexport function createPrefetchHelpers<\n T extends Record<string, QueryOptionsCreator<any, any, any>>,\n>(\n queries: T,\n): {\n [K in keyof T]: T[K] extends QueryOptionsCreator<\n infer TParams,\n infer TData,\n infer TError\n >\n ? PrefetchHelper<TParams, TData, TError>\n : never\n} {\n const result = {} as {\n [K in keyof T]: T[K] extends QueryOptionsCreator<\n infer TParams,\n infer TData,\n infer TError\n >\n ? PrefetchHelper<TParams, TData, TError>\n : never\n }\n\n for (const key of Object.keys(queries) as Array<keyof T>) {\n // @ts-expect-error - TypeScript can't infer this properly\n result[key] = createPrefetchHelper(queries[key])\n }\n\n return result\n}\n\n/**\n * Prefetch multiple queries from different query creators in parallel.\n *\n * @param queryClient - The QueryClient instance\n * @param prefetches - Array of { helper, params } objects\n * @returns Promise that resolves when all prefetches complete\n *\n * @example\n * ```tsx\n * const userPrefetch = createPrefetchHelper(getUserQuery)\n * const postsPrefetch = createPrefetchHelper(getPostsQuery)\n *\n * async function DashboardPage({ userId }: { userId: string }) {\n * const queryClient = new QueryClient()\n *\n * await prefetchAll(queryClient, [\n * { helper: userPrefetch, params: { urlParams: { userId } } },\n * { helper: postsPrefetch, params: { urlParams: { userId }, params: { limit: 10 } } },\n * ])\n *\n * return (\n * <HydrationBoundary state={dehydrate(queryClient)}>\n * <Dashboard userId={userId} />\n * </HydrationBoundary>\n * )\n * }\n * ```\n */\nexport async function prefetchAll(\n queryClient: QueryClient,\n prefetches: Array<{\n helper: PrefetchHelper<any, any, any>\n params: unknown\n }>,\n): Promise<void> {\n await Promise.all(\n prefetches.map(({ helper, params }) =>\n helper.prefetch(queryClient, params),\n ),\n )\n}\n","import type {\n AnyEndpointConfig,\n UrlHasParams,\n UrlParams,\n} from '@navios/builder'\nimport type { DataTag } from '@tanstack/react-query'\n\nimport type { QueryParams } from '../query/types.mjs'\n\nimport { createQueryKey } from '../query/key-creator.mjs'\n\n/**\n * Creates a mutation key generator for a given endpoint configuration.\n *\n * @param config - The endpoint configuration\n * @param options - Optional query parameters with a default `processResponse` function\n * @returns A function that generates mutation keys\n *\n * @example Basic usage:\n * ```typescript\n * const createMutationKey = createMutationKey(endpoint.config);\n * const mutationKey = createMutationKey({ urlParams: { id: 123 } });\n * ```\n *\n * @example Advanced usage with processResponse:\n * ```ts\n * const createMutationKey = createMutationKey(endpoint.config, {\n * processResponse: (data) => {\n * if (!data.success) {\n * throw new Error(data.message);\n * }\n * return data.data;\n * },\n * });\n * // We create a mutation that will be shared across the project for all passed userId\n * const mutationKey = createMutationKey({ urlParams: { projectId: 123, userId: 'wildcard' } });\n * ```\n */\nexport function createMutationKey<\n Config extends AnyEndpointConfig,\n Options extends QueryParams<Config>,\n Url extends Config['url'] = Config['url'],\n HasParams extends UrlHasParams<Url> = UrlHasParams<Url>,\n>(\n config: Config,\n options: Options = {\n processResponse: (data) => data,\n } as Options,\n): (\n params: HasParams extends true ? { urlParams: UrlParams<Url> } : {},\n) => Options['processResponse'] extends (...args: unknown[]) => infer Result\n ? DataTag<[Config['url']], Result, Error>\n : never {\n const queryKey = createQueryKey(config, options, false)\n\n // @ts-expect-error We have correct types in return type\n return (params) => {\n return queryKey.filterKey(params)\n }\n}\n\n// Legacy export for backwards compatibility\n/** @deprecated Use createMutationKey instead */\nexport const mutationKeyCreator = createMutationKey\n","import type {\n AnyEndpointConfig,\n BaseEndpointConfig,\n ErrorSchemaRecord,\n HttpMethod,\n InferErrorSchemaOutput,\n UrlHasParams,\n UrlParams,\n} from '@navios/builder'\nimport type {\n MutationFunctionContext,\n UseMutationOptions,\n UseMutationResult,\n} from '@tanstack/react-query'\nimport type { z, ZodObject, ZodType } from 'zod/v4'\n\nimport { useIsMutating, useMutation } from '@tanstack/react-query'\n\nimport type { ProcessResponseFunction } from '../common/types.mjs'\nimport type { MutationHelpers } from './types.mjs'\n\nimport { createMutationKey } from './key-creator.mjs'\n\n/**\n * Helper type for endpoint with config property\n */\ntype EndpointWithConfig<Config extends AnyEndpointConfig> = ((\n params: any,\n) => Promise<any>) & {\n config: Config\n}\n\n/**\n * Helper type for response input when errorSchema is present\n */\ntype ResponseInput<\n ResponseSchema extends ZodType,\n ErrorSchema extends ErrorSchemaRecord | undefined,\n> = ErrorSchema extends ErrorSchemaRecord\n ? z.output<ResponseSchema> | InferErrorSchemaOutput<ErrorSchema>\n : z.output<ResponseSchema>\n\n/**\n * Options type for makeMutation\n */\ntype MakeMutationParams<\n Config extends AnyEndpointConfig,\n ResponseSchema extends ZodType,\n ErrorSchema extends ErrorSchemaRecord | undefined,\n TData,\n TVariables,\n TOnMutateResult,\n TContext,\n UseKey extends boolean,\n> = Omit<\n UseMutationOptions<TData, Error, TVariables>,\n | 'mutationKey'\n | 'mutationFn'\n | 'onMutate'\n | 'onSuccess'\n | 'onError'\n | 'onSettled'\n | 'scope'\n> & {\n processResponse?: ProcessResponseFunction<TData, ResponseInput<ResponseSchema, ErrorSchema>>\n useContext?: () => TContext\n onSuccess?: (\n data: TData,\n variables: TVariables,\n context: TContext &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n onError?: (\n err: unknown,\n variables: TVariables,\n context: TContext &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n onMutate?: (\n variables: TVariables,\n context: TContext & MutationFunctionContext,\n ) => TOnMutateResult | Promise<TOnMutateResult>\n onSettled?: (\n data: TData | undefined,\n error: Error | null,\n variables: TVariables,\n context: TContext &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n useKey?: UseKey\n keyPrefix?: UseKey extends true\n ? UrlHasParams<Config['url']> extends true\n ? string[]\n : never\n : never\n keySuffix?: UseKey extends true\n ? UrlHasParams<Config['url']> extends true\n ? string[]\n : never\n : never\n}\n\n/**\n * Creates a mutation hook for a given endpoint.\n *\n * Returns a function that when called returns a TanStack Query mutation result.\n * The returned function also has helper methods attached (mutationKey, useIsMutating).\n *\n * @param endpoint - The navios endpoint to create a mutation hook for\n * @param options - Mutation configuration including processResponse and callbacks\n * @returns A hook function that returns mutation result with attached helpers\n */\n// Overload: WITH errorSchema\nexport function makeMutation<\n Method extends HttpMethod,\n Url extends string,\n QuerySchema extends ZodObject | undefined,\n ResponseSchema extends ZodType,\n RequestSchema extends ZodType,\n ErrorSchema extends ErrorSchemaRecord,\n TData,\n TOnMutateResult = unknown,\n TContext = unknown,\n UseKey extends boolean = false,\n>(\n endpoint: EndpointWithConfig<\n BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema, ErrorSchema>\n >,\n options: MakeMutationParams<\n BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema, ErrorSchema>,\n ResponseSchema,\n ErrorSchema,\n TData,\n any,\n TOnMutateResult,\n TContext,\n UseKey\n >,\n): ((\n keyParams: UseKey extends true\n ? UrlHasParams<Url> extends true\n ? { urlParams: UrlParams<Url> }\n : never\n : never,\n) => UseMutationResult<TData, Error, any, TOnMutateResult>) &\n MutationHelpers<Url, TData>\n\n// Overload: WITHOUT errorSchema\nexport function makeMutation<\n Method extends HttpMethod,\n Url extends string,\n QuerySchema extends ZodObject | undefined,\n ResponseSchema extends ZodType,\n RequestSchema extends ZodType | undefined,\n TData,\n TOnMutateResult = unknown,\n TContext = unknown,\n UseKey extends boolean = false,\n>(\n endpoint: EndpointWithConfig<\n BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema, undefined>\n >,\n options: MakeMutationParams<\n BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema, undefined>,\n ResponseSchema,\n undefined,\n TData,\n any,\n TOnMutateResult,\n TContext,\n UseKey\n >,\n): ((\n keyParams: UseKey extends true\n ? UrlHasParams<Url> extends true\n ? { urlParams: UrlParams<Url> }\n : never\n : never,\n) => UseMutationResult<TData, Error, any, TOnMutateResult>) &\n MutationHelpers<Url, TData>\n\n// Implementation\nexport function makeMutation(\n endpoint: EndpointWithConfig<AnyEndpointConfig>,\n options: any,\n): any {\n const config = endpoint.config\n\n const mutationKey = createMutationKey(config, {\n ...options,\n processResponse: options.processResponse ?? ((data: any) => data),\n })\n const result = (keyParams: any): any => {\n const {\n useKey,\n useContext,\n onMutate,\n onError,\n onSuccess,\n onSettled,\n keyPrefix: _keyPrefix,\n keySuffix: _keySuffix,\n processResponse,\n ...rest\n } = options\n\n const ownContext = useContext?.() ?? {}\n\n return useMutation({\n ...rest,\n mutationKey: useKey ? mutationKey(keyParams) : undefined,\n scope: useKey\n ? {\n id: JSON.stringify(mutationKey(keyParams)),\n }\n : undefined,\n async mutationFn(params: any) {\n const response = await endpoint(params)\n\n return processResponse ? processResponse(response) : response\n },\n onSuccess: onSuccess\n ? (\n data: any,\n variables: any,\n onMutateResult: any,\n context: MutationFunctionContext,\n ) => {\n return onSuccess?.(data, variables, {\n ...ownContext,\n ...context,\n onMutateResult,\n })\n }\n : undefined,\n onError: onError\n ? (\n err: Error,\n variables: any,\n onMutateResult: any,\n context: MutationFunctionContext,\n ) => {\n return onError?.(err, variables, {\n onMutateResult,\n ...ownContext,\n ...context,\n })\n }\n : undefined,\n onMutate: onMutate\n ? (variables: any, context: MutationFunctionContext) => {\n return onMutate(variables, {\n ...ownContext,\n ...context,\n })\n }\n : undefined,\n onSettled: onSettled\n ? (\n data: any,\n error: Error | null,\n variables: any,\n onMutateResult: any,\n context: MutationFunctionContext,\n ) => {\n return onSettled(data, error, variables, {\n ...ownContext,\n ...context,\n onMutateResult,\n })\n }\n : undefined,\n })\n }\n result.useIsMutating = (keyParams: any): boolean => {\n if (!options.useKey) {\n throw new Error(\n 'useIsMutating can only be used when useKey is set to true',\n )\n }\n const isMutating = useIsMutating({\n mutationKey: mutationKey(keyParams),\n })\n return isMutating > 0\n }\n result.mutationKey = mutationKey\n\n return result\n}\n","import type { QueryClient } from '@tanstack/react-query'\n\n/**\n * Configuration for creating optimistic update callbacks.\n *\n * @template TData - The mutation response data type\n * @template TVariables - The mutation variables type\n * @template TQueryData - The query cache data type\n */\nexport interface OptimisticUpdateConfig<\n TData,\n TVariables,\n TQueryData,\n> {\n /**\n * The query key to optimistically update.\n * This should match the query key used for the affected query.\n */\n queryKey: readonly unknown[]\n\n /**\n * Function to compute the optimistic cache value.\n * Receives the current cache data and mutation variables.\n *\n * @param oldData - Current data in the cache (may be undefined if not cached)\n * @param variables - The mutation variables being submitted\n * @returns The new optimistic cache value\n */\n updateFn: (oldData: TQueryData | undefined, variables: TVariables) => TQueryData\n\n /**\n * Whether to rollback on error.\n * Defaults to true.\n */\n rollbackOnError?: boolean\n\n /**\n * Whether to invalidate the query on settlement.\n * Defaults to true.\n */\n invalidateOnSettled?: boolean\n}\n\n/**\n * Return type for optimistic update callbacks.\n */\nexport interface OptimisticUpdateCallbacks<TData, TVariables, TQueryData> {\n /**\n * Called before the mutation starts. Cancels outgoing refetches,\n * snapshots the current cache value, and applies the optimistic update.\n */\n onMutate: (\n variables: TVariables,\n context: { queryClient: QueryClient },\n ) => Promise<{ previousData: TQueryData | undefined }>\n\n /**\n * Called when the mutation fails. Rolls back the cache to the previous\n * value if rollbackOnError is enabled.\n */\n onError: (\n err: Error,\n variables: TVariables,\n context: { previousData?: TQueryData; queryClient: QueryClient },\n ) => void\n\n /**\n * Called when the mutation completes (success or error).\n * Invalidates the query if invalidateOnSettled is enabled.\n */\n onSettled: (\n data: TData | undefined,\n error: Error | null,\n variables: TVariables,\n context: { queryClient: QueryClient },\n ) => void\n}\n\n/**\n * Creates type-safe optimistic update callbacks for mutations.\n *\n * This helper generates the onMutate, onError, and onSettled callbacks\n * that implement the standard optimistic update pattern:\n *\n * 1. onMutate: Cancel refetches, snapshot cache, apply optimistic update\n * 2. onError: Rollback cache to previous value on failure\n * 3. onSettled: Invalidate query to refetch fresh data\n *\n * @param config - Configuration for the optimistic update\n * @returns Object containing onMutate, onError, and onSettled callbacks\n *\n * @example\n * ```ts\n * // Create a mutation with optimistic updates\n * const updateUser = client.mutation({\n * method: 'PATCH',\n * url: '/users/$userId',\n * requestSchema: updateUserSchema,\n * responseSchema: userSchema,\n * processResponse: (data) => data,\n * ...createOptimisticUpdate({\n * queryKey: ['users', userId],\n * updateFn: (oldData, variables) => ({\n * ...oldData,\n * ...variables.data,\n * }),\n * }),\n * })\n * ```\n *\n * @example\n * ```ts\n * // Optimistic update for adding an item to a list\n * const addTodo = client.mutation({\n * method: 'POST',\n * url: '/todos',\n * requestSchema: createTodoSchema,\n * responseSchema: todoSchema,\n * processResponse: (data) => data,\n * ...createOptimisticUpdate({\n * queryKey: ['todos'],\n * updateFn: (oldData, variables) => [\n * ...(oldData ?? []),\n * { id: 'temp-id', ...variables.data, createdAt: new Date() },\n * ],\n * }),\n * })\n * ```\n *\n * @example\n * ```ts\n * // Optimistic delete\n * const deleteTodo = client.mutation({\n * method: 'DELETE',\n * url: '/todos/$todoId',\n * responseSchema: z.object({ success: z.boolean() }),\n * processResponse: (data) => data,\n * ...createOptimisticUpdate({\n * queryKey: ['todos'],\n * updateFn: (oldData, variables) =>\n * (oldData ?? []).filter((t) => t.id !== variables.urlParams.todoId),\n * }),\n * })\n * ```\n */\nexport function createOptimisticUpdate<\n TData,\n TVariables,\n TQueryData,\n>(config: OptimisticUpdateConfig<TData, TVariables, TQueryData>): OptimisticUpdateCallbacks<TData, TVariables, TQueryData> {\n const {\n queryKey,\n updateFn,\n rollbackOnError = true,\n invalidateOnSettled = true,\n } = config\n\n return {\n onMutate: async (\n variables: TVariables,\n context: { queryClient: QueryClient },\n ) => {\n // Cancel any outgoing refetches to prevent overwriting optimistic update\n await context.queryClient.cancelQueries({ queryKey })\n\n // Snapshot the previous value\n const previousData = context.queryClient.getQueryData<TQueryData>(queryKey)\n\n // Optimistically update the cache\n context.queryClient.setQueryData<TQueryData>(\n queryKey,\n (old) => updateFn(old, variables),\n )\n\n // Return context with the previous data for potential rollback\n return { previousData }\n },\n\n onError: (\n _err: Error,\n _variables: TVariables,\n context: { previousData?: TQueryData; queryClient: QueryClient },\n ) => {\n // Rollback to the previous value on error\n if (rollbackOnError && context?.previousData !== undefined) {\n context.queryClient.setQueryData(queryKey, context.previousData)\n }\n },\n\n onSettled: (\n _data: TData | undefined,\n _error: Error | null,\n _variables: TVariables,\n context: { queryClient: QueryClient },\n ) => {\n // Always invalidate to ensure we have the correct server state\n if (invalidateOnSettled) {\n void context.queryClient.invalidateQueries({ queryKey })\n }\n },\n }\n}\n\n/**\n * Creates optimistic update callbacks that work with multiple query keys.\n *\n * Useful when a mutation affects multiple cached queries.\n *\n * @param configs - Array of optimistic update configurations\n * @returns Combined callbacks that handle all specified queries\n *\n * @example\n * ```ts\n * // Updating a user affects both user detail and user list queries\n * const updateUser = client.mutation({\n * method: 'PATCH',\n * url: '/users/$userId',\n * requestSchema: updateUserSchema,\n * responseSchema: userSchema,\n * processResponse: (data) => data,\n * ...createMultiOptimisticUpdate([\n * {\n * queryKey: ['users', userId],\n * updateFn: (oldData, variables) => ({ ...oldData, ...variables.data }),\n * },\n * {\n * queryKey: ['users'],\n * updateFn: (oldList, variables) =>\n * (oldList ?? []).map((u) =>\n * u.id === userId ? { ...u, ...variables.data } : u\n * ),\n * },\n * ]),\n * })\n * ```\n */\nexport function createMultiOptimisticUpdate<TData, TVariables>(\n configs: Array<OptimisticUpdateConfig<TData, TVariables, unknown>>,\n): OptimisticUpdateCallbacks<TData, TVariables, Map<string, unknown>> {\n return {\n onMutate: async (\n variables: TVariables,\n context: { queryClient: QueryClient },\n ) => {\n // Cancel and snapshot all queries\n const previousData = new Map<string, unknown>()\n\n for (const config of configs) {\n await context.queryClient.cancelQueries({ queryKey: config.queryKey })\n const key = JSON.stringify(config.queryKey)\n previousData.set(key, context.queryClient.getQueryData(config.queryKey))\n context.queryClient.setQueryData(\n config.queryKey,\n (old: unknown) => config.updateFn(old, variables),\n )\n }\n\n return { previousData }\n },\n\n onError: (\n _err: Error,\n _variables: TVariables,\n context: { previousData?: Map<string, unknown>; queryClient: QueryClient },\n ) => {\n // Rollback all queries\n if (context?.previousData) {\n for (const config of configs) {\n if (config.rollbackOnError !== false) {\n const key = JSON.stringify(config.queryKey)\n const previous = context.previousData.get(key)\n if (previous !== undefined) {\n context.queryClient.setQueryData(config.queryKey, previous)\n }\n }\n }\n }\n },\n\n onSettled: (\n _data: TData | undefined,\n _error: Error | null,\n _variables: TVariables,\n context: { queryClient: QueryClient },\n ) => {\n // Invalidate all queries\n for (const config of configs) {\n if (config.invalidateOnSettled !== false) {\n void context.queryClient.invalidateQueries({ queryKey: config.queryKey })\n }\n }\n },\n }\n}\n","import type {\n AbstractEndpoint,\n AbstractStream,\n AnyEndpointConfig,\n AnyStreamConfig,\n BaseEndpointOptions,\n EndpointHandler,\n EndpointOptions,\n ErrorSchemaRecord,\n HttpMethod,\n StreamHandler,\n} from '@navios/builder'\nimport type {\n InfiniteData,\n MutationFunctionContext,\n} from '@tanstack/react-query'\nimport type { z, ZodObject, ZodType } from 'zod/v4'\n\nimport type {\n ClientOptions,\n ProcessResponseFunction,\n} from '../common/types.mjs'\nimport type { MutationArgs } from '../mutation/types.mjs'\nimport type { ClientInstance } from './types.mjs'\nimport type { ComputeBaseResult } from './types/helpers.mjs'\n\nimport { makeMutation } from '../mutation/make-hook.mjs'\nimport { makeInfiniteQueryOptions } from '../query/make-infinite-options.mjs'\nimport { makeQueryOptions } from '../query/make-options.mjs'\n\n/**\n * Configuration for declaring a query endpoint.\n */\nexport interface QueryConfig<\n Method extends HttpMethod = HttpMethod,\n Url extends string = string,\n QuerySchema extends ZodObject | undefined = undefined,\n Response extends ZodType = ZodType,\n ErrorSchema extends ErrorSchemaRecord | undefined = undefined,\n Result = ComputeBaseResult<true, Response, ErrorSchema>,\n RequestSchema extends ZodType | undefined = undefined,\n> {\n method: Method\n url: Url\n querySchema?: QuerySchema\n responseSchema: Response\n errorSchema?: ErrorSchema\n requestSchema?: RequestSchema\n processResponse?: (\n data: ComputeBaseResult<true, Response, ErrorSchema>,\n ) => Result\n}\n\n/**\n * Configuration for declaring an infinite query endpoint.\n */\nexport type InfiniteQueryConfig<\n Method extends HttpMethod = HttpMethod,\n Url extends string = string,\n QuerySchema extends ZodObject = ZodObject,\n Response extends ZodType = ZodType,\n ErrorSchema extends ErrorSchemaRecord | undefined = undefined,\n PageResult = ComputeBaseResult<true, Response, ErrorSchema>,\n Result = InfiniteData<PageResult>,\n RequestSchema extends ZodType | undefined = undefined,\n> = {\n method: Method\n url: Url\n querySchema: QuerySchema\n responseSchema: Response\n errorSchema?: ErrorSchema\n requestSchema?: RequestSchema\n processResponse?: (\n data: ComputeBaseResult<true, Response, ErrorSchema>,\n ) => PageResult\n select?: (data: InfiniteData<PageResult>) => Result\n getNextPageParam: (\n lastPage: PageResult,\n allPages: PageResult[],\n lastPageParam: z.infer<QuerySchema> | undefined,\n allPageParams: z.infer<QuerySchema>[] | undefined,\n ) => z.input<QuerySchema> | undefined\n getPreviousPageParam?: (\n firstPage: PageResult,\n allPages: PageResult[],\n lastPageParam: z.infer<QuerySchema> | undefined,\n allPageParams: z.infer<QuerySchema>[] | undefined,\n ) => z.input<QuerySchema>\n initialPageParam?: z.input<QuerySchema>\n}\n\n/**\n * Configuration for declaring a mutation endpoint.\n */\nexport interface MutationConfig<\n Method extends 'POST' | 'PUT' | 'PATCH' | 'DELETE' =\n | 'POST'\n | 'PUT'\n | 'PATCH'\n | 'DELETE',\n Url extends string = string,\n RequestSchema extends ZodType | undefined = Method extends 'DELETE'\n ? undefined\n : ZodType,\n QuerySchema extends ZodObject | undefined = undefined,\n Response extends ZodType = ZodType,\n ErrorSchema extends ErrorSchemaRecord | undefined = undefined,\n ReqResult = ComputeBaseResult<true, Response, ErrorSchema>,\n Result = unknown,\n TOnMutateResult = unknown,\n Context = unknown,\n UseKey extends boolean = false,\n> {\n method: Method\n url: Url\n querySchema?: QuerySchema\n responseSchema: Response\n errorSchema?: ErrorSchema\n requestSchema?: RequestSchema\n processResponse: ProcessResponseFunction<Result, ReqResult>\n useContext?: () => Context\n onSuccess?: (\n data: Result,\n variables: MutationArgs<Url, RequestSchema, QuerySchema>,\n context: Context &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n onError?: (\n err: unknown,\n variables: MutationArgs<Url, RequestSchema, QuerySchema>,\n context: Context &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n onMutate?: (\n variables: MutationArgs<Url, RequestSchema, QuerySchema>,\n context: Context & MutationFunctionContext,\n ) => TOnMutateResult | Promise<TOnMutateResult>\n onSettled?: (\n data: Result | undefined,\n error: Error | null,\n variables: MutationArgs<Url, RequestSchema, QuerySchema>,\n context: Context &\n MutationFunctionContext & { onMutateResult: TOnMutateResult | undefined },\n ) => void | Promise<void>\n useKey?: UseKey\n meta?: Record<string, unknown>\n}\n\n/**\n * Creates a client instance for making type-safe queries and mutations.\n *\n * @template UseDiscriminator - When `true`, errors are returned as union types.\n * When `false` (default), errors are thrown and not included in TData.\n *\n * @param options - Client configuration including the API builder and defaults\n * @returns A client instance with query, infiniteQuery, and mutation methods\n *\n * @example\n * ```typescript\n * const api = builder({});\n * const client = declareClient({ api });\n *\n * const getUser = client.query({\n * method: 'GET',\n * url: '/users/$id',\n * responseSchema: UserSchema,\n * });\n *\n * // In a component\n * const { data } = useSuspenseQuery(getUser({ urlParams: { id: '123' } }));\n * ```\n */\nexport function declareClient<UseDiscriminator extends boolean = false>({\n api,\n defaults = {},\n}: ClientOptions<UseDiscriminator>): ClientInstance<UseDiscriminator> {\n function query(config: QueryConfig) {\n const endpoint = api.declareEndpoint({\n method: config.method,\n url: config.url,\n querySchema: config.querySchema,\n requestSchema: config.requestSchema,\n responseSchema: config.responseSchema,\n errorSchema: config.errorSchema,\n })\n\n const queryOptions = makeQueryOptions(endpoint, {\n ...defaults,\n processResponse: config.processResponse ?? ((data) => data),\n })\n // @ts-expect-error We attach the endpoint to the queryOptions\n queryOptions.endpoint = endpoint\n return queryOptions\n }\n\n function queryFromEndpoint(\n endpoint:\n | AbstractEndpoint<AnyEndpointConfig>\n | EndpointHandler<EndpointOptions, UseDiscriminator>,\n options?: {\n processResponse?: (\n data: z.output<AnyEndpointConfig['responseSchema']>,\n ) => unknown\n },\n ) {\n return makeQueryOptions(endpoint as any, {\n ...defaults,\n processResponse: options?.processResponse ?? ((data) => data),\n })\n }\n\n function infiniteQuery(config: InfiniteQueryConfig) {\n const endpoint = api.declareEndpoint({\n method: config.method,\n url: config.url,\n querySchema: config.querySchema,\n requestSchema: config.requestSchema,\n responseSchema: config.responseSchema,\n errorSchema: config.errorSchema,\n })\n const infiniteQueryOptions = makeInfiniteQueryOptions(endpoint, {\n ...defaults,\n processResponse: config.processResponse ?? ((data: unknown) => data),\n getNextPageParam: config.getNextPageParam,\n getPreviousPageParam: config.getPreviousPageParam,\n initialPageParam: config.initialPageParam,\n })\n\n // @ts-expect-error We attach the endpoint to the infiniteQueryOptions\n infiniteQueryOptions.endpoint = endpoint\n return infiniteQueryOptions\n }\n\n function infiniteQueryFromEndpoint(\n endpoint:\n | AbstractEndpoint<AnyEndpointConfig>\n | EndpointHandler<EndpointOptions, UseDiscriminator>,\n options: {\n processResponse?: (\n data: z.output<AnyEndpointConfig['responseSchema']>,\n ) => unknown\n getNextPageParam: (\n lastPage: z.infer<AnyEndpointConfig['responseSchema']>,\n allPages: z.infer<AnyEndpointConfig['responseSchema']>[],\n lastPageParam: z.infer<AnyEndpointConfig['querySchema']> | undefined,\n allPageParams: z.infer<AnyEndpointConfig['querySchema']>[] | undefined,\n ) => z.input<AnyEndpointConfig['querySchema']> | undefined\n getPreviousPageParam?: (\n firstPage: z.infer<AnyEndpointConfig['responseSchema']>,\n allPages: z.infer<AnyEndpointConfig['responseSchema']>[],\n lastPageParam: z.infer<AnyEndpointConfig['querySchema']> | undefined,\n allPageParams: z.infer<AnyEndpointConfig['querySchema']>[] | undefined,\n ) => z.input<AnyEndpointConfig['querySchema']>\n initialPageParam?: z.input<AnyEndpointConfig['querySchema']>\n },\n ) {\n return makeInfiniteQueryOptions(endpoint, {\n ...defaults,\n processResponse: options?.processResponse ?? ((data) => data),\n getNextPageParam: options.getNextPageParam,\n getPreviousPageParam: options?.getPreviousPageParam,\n initialPageParam: options?.initialPageParam,\n })\n }\n\n function mutation(config: MutationConfig) {\n const endpoint = api.declareEndpoint({\n method: config.method,\n url: config.url,\n querySchema: config.querySchema,\n requestSchema: config.requestSchema,\n responseSchema: config.responseSchema,\n errorSchema: config.errorSchema,\n })\n\n // @ts-expect-error Type inference for errorSchema variants\n const useMutation = makeMutation(endpoint, {\n processResponse: config.processResponse ?? ((data: unknown) => data),\n useContext: config.useContext,\n onMutate: config.onMutate,\n onSuccess: config.onSuccess,\n onError: config.onError,\n onSettled: config.onSettled,\n useKey: config.useKey,\n meta: config.meta,\n ...defaults,\n })\n\n // @ts-expect-error We attach the endpoint to the useMutation\n useMutation.endpoint = endpoint\n return useMutation\n }\n\n function mutationFromEndpoint(\n endpoint:\n | AbstractEndpoint<AnyEndpointConfig>\n | AbstractStream<AnyStreamConfig>\n | EndpointHandler<EndpointOptions, UseDiscriminator>\n | StreamHandler<BaseEndpointOptions, UseDiscriminator>,\n options?: {\n processResponse?: ProcessResponseFunction\n useContext?: () => unknown\n onMutate?: (\n variables: MutationArgs,\n context: MutationFunctionContext & { [key: string]: unknown },\n ) => unknown | Promise<unknown>\n onSuccess?: (\n data: unknown,\n variables: MutationArgs,\n context: MutationFunctionContext & {\n onMutateResult: unknown | undefined\n [key: string]: unknown\n },\n ) => void | Promise<void>\n onError?: (\n err: unknown,\n variables: MutationArgs,\n context: MutationFunctionContext & {\n onMutateResult: unknown | undefined\n [key: string]: unknown\n },\n ) => void | Promise<void>\n onSettled?: (\n data: unknown | undefined,\n error: Error | null,\n variables: MutationArgs,\n context: MutationFunctionContext & {\n onMutateResult: unknown | undefined\n [key: string]: unknown\n },\n ) => void | Promise<void>\n useKey?: boolean\n meta?: Record<string, unknown>\n },\n ) {\n // @ts-expect-error endpoint types are compatible at runtime\n return makeMutation(endpoint, {\n processResponse: options?.processResponse,\n useContext: options?.useContext,\n onMutate: options?.onMutate,\n onSuccess: options?.onSuccess,\n onError: options?.onError,\n onSettled: options?.onSettled,\n useKey: options?.useKey,\n meta: options?.meta,\n ...defaults,\n })\n }\n\n function multipartMutation(config: MutationConfig) {\n const endpoint = api.declareMultipart({\n method: config.method,\n url: config.url,\n querySchema: config.querySchema,\n requestSchema: config.requestSchema,\n responseSchema: config.responseSchema,\n errorSchema: config.errorSchema,\n })\n\n // @ts-expect-error Type inference for errorSchema variants\n const useMutation = makeMutation(endpoint, {\n processResponse: config.processResponse ?? ((data: unknown) => data),\n useContext: config.useContext,\n onSuccess: config.onSuccess,\n onError: config.onError,\n onMutate: config.onMutate,\n onSettled: config.onSettled,\n useKey: config.useKey,\n ...defaults,\n })\n\n // @ts-expect-error We attach the endpoint to the useMutation\n useMutation.endpoint = endpoint\n return useMutation\n }\n\n return {\n // @ts-expect-error We simplified types here\n query,\n // @ts-expect-error We simplified types here\n queryFromEndpoint,\n // @ts-expect-error We simplified types here\n infiniteQuery,\n // @ts-expect-error We simplified types here\n infiniteQueryFromEndpoint,\n // @ts-expect-error We simplified types here\n mutation,\n // @ts-expect-error We simplified types here\n mutationFromEndpoint,\n // @ts-expect-error We simplified types here\n multipartMutation,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,eAOd,QACA,SACA,aASA;CACA,MAAM,MAAM,OAAO;AAEnB,QAAO;EACL,UAFe,IAAI,MAAM,IAAI,CAAC,OAAO,QAAQ;EAI7C,UAAU,WAAW;GACnB,MAAM,cACJ,UAAU,iBAAiB,UAAU,YAAY,SAC7C,OAAO,aAAa,MAAM,OAAO,OAAO,GACxC,EAAE;GAQR,MAAM,gBALW,cACf,KACA,UAAU,eAAe,SAAS,SAAS,EAAE,EAC7C,OAAO,gBACR,CAC8B,MAAM,IAAI,CAAC,OAAO,QAAQ;AAEzD,UAAO;IACL,GAAI,QAAQ,aAAa,EAAE;IAC3B,GAAG;IACH,GAAI,QAAQ,aAAa,EAAE;IAC3B,eAAe,EAAE;IAClB;;EAWH,YAAY,WAAW;GAOrB,MAAM,gBALW,cACf,KACA,UAAU,eAAe,SAAS,SAAS,EAAE,EAC7C,OAAO,gBACR,CAC8B,MAAM,IAAI,CAAC,OAAO,QAAQ;AAEzD,UAA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AAO;GAChB,WAAW,OAAO;GAClB,QAAQ,OAAO;GACf,MAAM,OAAO;GACb,GAAG;GACJ,CAAC;AAGF,gBAAY,WAAW;AACvB,SAAOA;;CAGT,SAAS,qBACP,UAKA,SAmCA;AAEA,SAAO,aAAa,UAAU;GAC5B,iBAAiB,SAAS;GAC1B,YAAY,SAAS;GACrB,UAAU,SAAS;GACnB,WAAW,SAAS;GACpB,SAAS,SAAS;GAClB,WAAW,SAAS;GACpB,QAAQ,SAAS;GACjB,MAAM,SAAS;GACf,GAAG;GACJ,CAAC;;CAGJ,SAAS,kBAAkB,QAAwB;EACjD,MAAM,WAAW,IAAI,iBAAiB;GACpC,QAAQ,OAAO;GACf,KAAK,OAAO;GACZ,aAAa,OAAO;GACpB,eAAe,OAAO;GACtB,gBAAgB,OAAO;GACvB,aAAa,OAAO;GACrB,CAAC;EAGF,MAAMA,gBAAc,aAAa,UAAU;GACzC,iBAAiB,OAAO,qBAAqB,SAAkB;GAC/D,YAAY,OAAO;GACnB,WAAW,OAAO;GAClB,SAAS,OAAO;GAChB,UAAU,OAAO;GACjB,WAAW,OAAO;GAClB,QAAQ,OAAO;GACf,GAAG;GACJ,CAAC;AAGF,gBAAY,WAAW;AACvB,SAAOA;;AAGT,QAAO;EAEL;EAEA;EAEA;EAEA;EAEA;EAEA;EAEA;EACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navios/react-query",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Oleksandr Hanzha",
|
|
6
6
|
"email": "alex@granted.name"
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@navios/builder": "^0.
|
|
15
|
+
"@navios/builder": "^1.0.0-alpha.1",
|
|
16
16
|
"@tanstack/react-query": "^5.51.21",
|
|
17
17
|
"zod": "^3.25.0 || ^4.0.0"
|
|
18
18
|
},
|
|
19
19
|
"typings": "./lib/index.d.mts",
|
|
20
|
-
"main": "./lib/index.
|
|
20
|
+
"main": "./lib/index.cjs",
|
|
21
21
|
"module": "./lib/index.mjs",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"default": "./lib/index.mjs"
|
|
27
27
|
},
|
|
28
28
|
"require": {
|
|
29
|
-
"types": "./lib/index.d.
|
|
30
|
-
"default": "./lib/index.
|
|
29
|
+
"types": "./lib/index.d.cts",
|
|
30
|
+
"default": "./lib/index.cjs"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@navios/builder": "^0.
|
|
36
|
-
"@navios/http": "^0.6.
|
|
35
|
+
"@navios/builder": "^1.0.0-alpha.1",
|
|
36
|
+
"@navios/http": "^0.6.1",
|
|
37
37
|
"@tanstack/react-query": "^5.90.12",
|
|
38
38
|
"react": "^19.2.3",
|
|
39
39
|
"typescript": "^5.9.3",
|
|
40
|
-
"zod": "^4.1
|
|
40
|
+
"zod": "^4.2.1"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { builder } from '@navios/builder'
|
|
1
2
|
import { create } from '@navios/http'
|
|
2
3
|
import { makeNaviosFakeAdapter } from '@navios/http/testing'
|
|
3
4
|
|
|
4
|
-
import { builder } from '@navios/builder'
|
|
5
|
-
|
|
6
5
|
import { describe, expect, it, vi } from 'vitest'
|
|
7
6
|
import { z } from 'zod/v4'
|
|
8
7
|
|