@navios/react-query 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/index.cjs +11 -11
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +5 -5
- package/package.json +8 -8
- package/dist/src/declare-client.d.mts +0 -31
- package/dist/src/declare-client.d.mts.map +0 -1
- package/dist/src/make-infinite-query-options.d.mts +0 -13
- package/dist/src/make-infinite-query-options.d.mts.map +0 -1
- package/dist/src/make-mutation.d.mts +0 -15
- package/dist/src/make-mutation.d.mts.map +0 -1
- package/dist/src/make-query-options.d.mts +0 -15
- package/dist/src/make-query-options.d.mts.map +0 -1
- package/dist/src/types/client-endpoint-helper.d.mts +0 -8
- package/dist/src/types/client-endpoint-helper.d.mts.map +0 -1
- package/dist/src/types/client-instance.d.mts +0 -211
- package/dist/src/types/client-instance.d.mts.map +0 -1
- package/dist/src/types/index.d.mts +0 -8
- package/dist/src/types/index.d.mts.map +0 -1
- package/dist/src/types/mutation-args.d.mts +0 -10
- package/dist/src/types/mutation-args.d.mts.map +0 -1
- package/dist/src/types/mutation-helpers.d.mts +0 -10
- package/dist/src/types/mutation-helpers.d.mts.map +0 -1
- package/dist/src/types/query-args.d.mts +0 -8
- package/dist/src/types/query-args.d.mts.map +0 -1
- package/dist/src/types/query-helpers.d.mts +0 -14
- package/dist/src/types/query-helpers.d.mts.map +0 -1
- package/dist/src/types/query-url-params-args.d.mts +0 -5
- package/dist/src/types/query-url-params-args.d.mts.map +0 -1
- package/dist/src/types.d.mts +0 -49
- package/dist/src/types.d.mts.map +0 -1
- package/dist/src/utils/mutation-key.creator.d.mts +0 -39
- package/dist/src/utils/mutation-key.creator.d.mts.map +0 -1
- package/dist/src/utils/query-key-creator.d.mts +0 -24
- package/dist/src/utils/query-key-creator.d.mts.map +0 -1
package/lib/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
let
|
|
2
|
-
let
|
|
1
|
+
let _navios_builder = require("@navios/builder");
|
|
2
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
3
3
|
|
|
4
4
|
//#region src/query/key-creator.mts
|
|
5
5
|
/**
|
|
@@ -35,7 +35,7 @@ function createQueryKey(config, options, _isInfinite) {
|
|
|
35
35
|
];
|
|
36
36
|
},
|
|
37
37
|
bindToUrl: (params) => {
|
|
38
|
-
return (0,
|
|
38
|
+
return (0, _navios_builder.bindUrlParams)(url, params ?? {});
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -60,7 +60,7 @@ function makeQueryOptions(endpoint, options, baseQuery = {}) {
|
|
|
60
60
|
const queryKey = createQueryKey(config, options, false);
|
|
61
61
|
const processResponse = options.processResponse;
|
|
62
62
|
const result = (params) => {
|
|
63
|
-
return (0,
|
|
63
|
+
return (0, _tanstack_react_query.queryOptions)({
|
|
64
64
|
queryKey: queryKey.dataTag(params),
|
|
65
65
|
queryFn: async ({ signal }) => {
|
|
66
66
|
let result$1;
|
|
@@ -80,10 +80,10 @@ function makeQueryOptions(endpoint, options, baseQuery = {}) {
|
|
|
80
80
|
};
|
|
81
81
|
result.queryKey = queryKey;
|
|
82
82
|
result.use = (params) => {
|
|
83
|
-
return (0,
|
|
83
|
+
return (0, _tanstack_react_query.useQuery)(result(params));
|
|
84
84
|
};
|
|
85
85
|
result.useSuspense = (params) => {
|
|
86
|
-
return (0,
|
|
86
|
+
return (0, _tanstack_react_query.useSuspenseQuery)(result(params));
|
|
87
87
|
};
|
|
88
88
|
result.invalidate = (queryClient, params) => {
|
|
89
89
|
return queryClient.invalidateQueries({ queryKey: result.queryKey.dataTag(params) });
|
|
@@ -115,7 +115,7 @@ function makeInfiniteQueryOptions(endpoint, options, baseQuery = {}) {
|
|
|
115
115
|
const queryKey = createQueryKey(config, options, true);
|
|
116
116
|
const processResponse = options.processResponse;
|
|
117
117
|
const res = (params) => {
|
|
118
|
-
return (0,
|
|
118
|
+
return (0, _tanstack_react_query.infiniteQueryOptions)({
|
|
119
119
|
queryKey: queryKey.dataTag(params),
|
|
120
120
|
queryFn: async ({ signal, pageParam }) => {
|
|
121
121
|
let result;
|
|
@@ -142,10 +142,10 @@ function makeInfiniteQueryOptions(endpoint, options, baseQuery = {}) {
|
|
|
142
142
|
};
|
|
143
143
|
res.queryKey = queryKey;
|
|
144
144
|
res.use = (params) => {
|
|
145
|
-
return (0,
|
|
145
|
+
return (0, _tanstack_react_query.useInfiniteQuery)(res(params));
|
|
146
146
|
};
|
|
147
147
|
res.useSuspense = (params) => {
|
|
148
|
-
return (0,
|
|
148
|
+
return (0, _tanstack_react_query.useSuspenseInfiniteQuery)(res(params));
|
|
149
149
|
};
|
|
150
150
|
res.invalidate = (queryClient, params) => {
|
|
151
151
|
return queryClient.invalidateQueries({ queryKey: res.queryKey.dataTag(params) });
|
|
@@ -218,7 +218,7 @@ function makeMutation(endpoint, options) {
|
|
|
218
218
|
const result = (keyParams) => {
|
|
219
219
|
const { useKey, useContext, onMutate, onError, onSuccess, onSettled, keyPrefix: _keyPrefix, keySuffix: _keySuffix, processResponse, ...rest } = options;
|
|
220
220
|
const ownContext = useContext?.() ?? {};
|
|
221
|
-
return (0,
|
|
221
|
+
return (0, _tanstack_react_query.useMutation)({
|
|
222
222
|
...rest,
|
|
223
223
|
mutationKey: useKey ? mutationKey(keyParams) : void 0,
|
|
224
224
|
scope: useKey ? { id: JSON.stringify(mutationKey(keyParams)) } : void 0,
|
|
@@ -257,7 +257,7 @@ function makeMutation(endpoint, options) {
|
|
|
257
257
|
};
|
|
258
258
|
result.useIsMutating = (keyParams) => {
|
|
259
259
|
if (!options.useKey) throw new Error("useIsMutating can only be used when useKey is set to true");
|
|
260
|
-
return (0,
|
|
260
|
+
return (0, _tanstack_react_query.useIsMutating)({ mutationKey: mutationKey({ urlParams: keyParams }) }) > 0;
|
|
261
261
|
};
|
|
262
262
|
result.mutationKey = mutationKey;
|
|
263
263
|
return result;
|
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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 multip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A;EAEA;EAEA;EAEA;EACD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","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":";;;;;;;;;;;;;;;AA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CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _navios_builder0 from "@navios/builder";
|
|
2
2
|
import { AbstractEndpoint, AnyEndpointConfig, BaseEndpointConfig, BaseStreamConfig, BuilderInstance, EndpointFunctionArgs, HttpMethod, NaviosZodRequest, UrlHasParams, UrlParams, Util_FlatObject } from "@navios/builder";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _tanstack_react_query1 from "@tanstack/react-query";
|
|
4
4
|
import { DataTag, InfiniteData, MutationFunctionContext, QueryClient, UseInfiniteQueryOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, UseSuspenseInfiniteQueryOptions, UseSuspenseQueryOptions, UseSuspenseQueryResult } from "@tanstack/react-query";
|
|
5
5
|
import { ZodObject, ZodType, z } from "zod/v4";
|
|
6
6
|
|
|
@@ -136,8 +136,8 @@ declare const queryKeyCreator: typeof createQueryKey;
|
|
|
136
136
|
declare function makeQueryOptions<Config extends AnyEndpointConfig, Options extends QueryParams<Config>, BaseQuery extends Omit<UseQueryOptions<ReturnType<Options['processResponse']>, Error, any>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam' | 'enabled' | 'throwOnError' | 'placeholderData'>>(endpoint: AbstractEndpoint<Config>, options: Options, baseQuery?: BaseQuery): {
|
|
137
137
|
(params: QueryArgs<Config["url"], Config["querySchema"]>): Options["processResponse"] extends ((...args: any[]) => infer Result) ? UseSuspenseQueryOptions<Result, Error, BaseQuery["select"] extends ((...args: any[]) => infer T) ? T : Result, DataTag<Split<Config["url"], "/">, Result, Error>> : never;
|
|
138
138
|
queryKey: QueryKeyCreatorResult<Config["querySchema"], Config["url"], Options["processResponse"] extends ((...args: any[]) => infer Result) ? Result : never, false, _navios_builder0.UrlHasParams<Config["url"]>>;
|
|
139
|
-
use(params: QueryArgs<Config["url"], Config["querySchema"]>):
|
|
140
|
-
useSuspense(params: QueryArgs<Config["url"], Config["querySchema"]>):
|
|
139
|
+
use(params: QueryArgs<Config["url"], Config["querySchema"]>): _tanstack_react_query1.UseQueryResult<_tanstack_react_query1.NoInfer<BaseQuery["select"] extends ((...args: any[]) => infer T) ? T : unknown>, Error>;
|
|
140
|
+
useSuspense(params: QueryArgs<Config["url"], Config["querySchema"]>): _tanstack_react_query1.UseSuspenseQueryResult<BaseQuery["select"] extends ((...args: any[]) => infer T) ? T : unknown, Error>;
|
|
141
141
|
invalidate(queryClient: QueryClient, params: QueryArgs<Config["url"], Config["querySchema"]>): Promise<void>;
|
|
142
142
|
invalidateAll(queryClient: QueryClient, params: QueryArgs<Config["url"], Config["querySchema"]>): Promise<void>;
|
|
143
143
|
};
|
|
@@ -157,8 +157,8 @@ declare function makeQueryOptions<Config extends AnyEndpointConfig, Options exte
|
|
|
157
157
|
declare function makeInfiniteQueryOptions<Config extends AnyEndpointConfig, Options extends InfiniteQueryOptions<Config>, BaseQuery extends Omit<UseInfiniteQueryOptions<ReturnType<Options['processResponse']>, Error, any>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam' | 'placeholderData' | 'throwOnError'>>(endpoint: AbstractEndpoint<Config>, options: Options, baseQuery?: BaseQuery): {
|
|
158
158
|
(params: QueryArgs<Config["url"], Config["querySchema"]>): Options["processResponse"] extends ((...args: any[]) => infer Result) ? UseSuspenseInfiniteQueryOptions<Result, Error, BaseQuery["select"] extends ((...args: any[]) => infer T) ? T : InfiniteData<Result>> : never;
|
|
159
159
|
queryKey: QueryKeyCreatorResult<Config["querySchema"], Config["url"], Options["processResponse"] extends ((...args: any[]) => infer Result) ? Result : never, true, _navios_builder0.UrlHasParams<Config["url"]>>;
|
|
160
|
-
use(params: QueryArgs<Config["url"], Config["querySchema"]>):
|
|
161
|
-
useSuspense(params: QueryArgs<Config["url"], Config["querySchema"]>):
|
|
160
|
+
use(params: QueryArgs<Config["url"], Config["querySchema"]>): _tanstack_react_query1.UseInfiniteQueryResult<BaseQuery["select"] extends ((...args: any[]) => infer T) ? T : InfiniteData<unknown, unknown>, Error>;
|
|
161
|
+
useSuspense(params: QueryArgs<Config["url"], Config["querySchema"]>): _tanstack_react_query1.UseSuspenseInfiniteQueryResult<BaseQuery["select"] extends ((...args: any[]) => infer T) ? T : InfiniteData<unknown, unknown>, Error>;
|
|
162
162
|
invalidate(queryClient: QueryClient, params: QueryArgs<Config["url"], Config["querySchema"]>): Promise<void>;
|
|
163
163
|
invalidateAll(queryClient: QueryClient, params: QueryArgs<Config["url"], Config["querySchema"]>): Promise<void>;
|
|
164
164
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navios/react-query",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.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.5.
|
|
15
|
+
"@navios/builder": "^0.5.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.5.
|
|
36
|
-
"@navios/http": "^0.6.
|
|
35
|
+
"@navios/builder": "^0.5.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,31 +0,0 @@
|
|
|
1
|
-
import type { HttpMethod, Util_FlatObject } from '@navios/builder';
|
|
2
|
-
import type { InfiniteData, QueryClient } from '@tanstack/react-query';
|
|
3
|
-
import type { z, ZodObject, ZodType } from 'zod/v4';
|
|
4
|
-
import type { ClientOptions, ProcessResponseFunction } from './types.mjs';
|
|
5
|
-
import type { ClientInstance, ClientMutationArgs } from './types/index.mjs';
|
|
6
|
-
export interface ClientEndpointDefinition<Method = HttpMethod, Url = string, QuerySchema = unknown, Response = ZodType> {
|
|
7
|
-
method: Method;
|
|
8
|
-
url: Url;
|
|
9
|
-
querySchema?: QuerySchema;
|
|
10
|
-
responseSchema: Response;
|
|
11
|
-
}
|
|
12
|
-
export interface ClientQueryConfig<Method = HttpMethod, Url = string, QuerySchema = ZodObject, Response extends ZodType = ZodType, Result = z.output<Response>> extends ClientEndpointDefinition<Method, Url, QuerySchema, Response> {
|
|
13
|
-
processResponse?: (data: z.output<Response>) => Result;
|
|
14
|
-
}
|
|
15
|
-
export type ClientInfiniteQueryConfig<Method = HttpMethod, Url = string, QuerySchema extends ZodObject = ZodObject, Response extends ZodType = ZodType, PageResult = z.output<Response>, Result = InfiniteData<PageResult>> = Required<ClientEndpointDefinition<Method, Url, QuerySchema, Response>> & {
|
|
16
|
-
processResponse?: (data: z.output<Response>) => PageResult;
|
|
17
|
-
select?: (data: InfiniteData<PageResult>) => Result;
|
|
18
|
-
getNextPageParam: (lastPage: PageResult, allPages: PageResult[], lastPageParam: z.infer<QuerySchema> | undefined, allPageParams: z.infer<QuerySchema>[] | undefined) => z.input<QuerySchema> | undefined;
|
|
19
|
-
getPreviousPageParam?: (firstPage: PageResult, allPages: PageResult[], lastPageParam: z.infer<QuerySchema> | undefined, allPageParams: z.infer<QuerySchema>[] | undefined) => z.input<QuerySchema>;
|
|
20
|
-
initialPageParam?: z.input<QuerySchema>;
|
|
21
|
-
};
|
|
22
|
-
export interface ClientMutationDataConfig<Method extends 'POST' | 'PUT' | 'PATCH' | 'DELETE' = 'POST' | 'PUT' | 'PATCH' | 'DELETE', Url extends string = string, RequestSchema = Method extends 'DELETE' ? never : ZodObject, QuerySchema = unknown, Response extends ZodType = ZodType, ReqResult = z.output<Response>, Result = unknown, Context = unknown, UseKey extends boolean = false> extends ClientEndpointDefinition<Method, Url, QuerySchema, Response> {
|
|
23
|
-
requestSchema?: RequestSchema;
|
|
24
|
-
processResponse: ProcessResponseFunction<Result, ReqResult>;
|
|
25
|
-
useContext?: () => Context;
|
|
26
|
-
onSuccess?: (queryClient: QueryClient, data: NoInfer<Result>, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
27
|
-
onError?: (queryClient: QueryClient, error: Error, variables: Util_FlatObject<ClientMutationArgs<Url, RequestSchema, QuerySchema>>, context: Context) => void | Promise<void>;
|
|
28
|
-
useKey?: UseKey;
|
|
29
|
-
}
|
|
30
|
-
export declare function declareClient<Options extends ClientOptions>({ api, defaults, }: Options): ClientInstance;
|
|
31
|
-
//# sourceMappingURL=declare-client.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"declare-client.d.mts","sourceRoot":"","sources":["../../src/declare-client.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,UAAU,EACV,eAAe,EAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,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AE,aAAa,CAAA;IAC7B,eAAe,EAAE,uBAAuB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC3D,UAAU,CAAC,EAAE,MAAM,OAAO,CAAA;IAC1B,SAAS,CAAC,EAAE,CACV,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EACrB,SAAS,EAAE,eAAe,CACxB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,CAAC,CACpD,EACD,OAAO,EAAE,OAAO,KACb,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,OAAO,CAAC,EAAE,CACR,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,eAAe,CACxB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,CAAC,CACpD,EACD,OAAO,EAAE,OAAO,KACb,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,aAAa,CAAC,OAAO,SAAS,aAAa,EAAE,EAC3D,GAAG,EACH,QAAa,GACd,EAAE,OAAO,GAAG,cAAc,CAyJ1B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { AbstractEndpoint, AnyEndpointConfig } from '@navios/builder';
|
|
2
|
-
import type { InfiniteData, QueryClient, UseInfiniteQueryOptions, UseSuspenseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
3
|
-
import type { InfiniteQueryOptions } from './types.mjs';
|
|
4
|
-
import type { ClientQueryArgs } from './types/index.mjs';
|
|
5
|
-
export declare function makeInfiniteQueryOptions<Config extends AnyEndpointConfig, Options extends InfiniteQueryOptions<Config>, BaseQuery extends Omit<UseInfiniteQueryOptions<ReturnType<Options['processResponse']>, Error, any>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam' | 'placeholderData' | 'throwOnError'>>(endpoint: AbstractEndpoint<Config>, options: Options, baseQuery?: BaseQuery): {
|
|
6
|
-
(params: ClientQueryArgs): Options["processResponse"] extends (...args: any[]) => infer Result ? UseSuspenseInfiniteQueryOptions<Result, Error, BaseQuery["select"] extends (...args: any[]) => infer T ? T : InfiniteData<Result>> : never;
|
|
7
|
-
queryKey: import("./utils/query-key-creator.mjs").QueryKeyCreatorResult<Config["querySchema"], Config["url"], Options["processResponse"] extends (...args: any[]) => infer Result ? Result : never, true, import("@navios/builder").UrlHasParams<Config["url"]>>;
|
|
8
|
-
use(params: ClientQueryArgs): import("@tanstack/react-query").UseInfiniteQueryResult<BaseQuery["select"] extends (...args: any[]) => infer T ? T : InfiniteData<unknown, unknown>, Error>;
|
|
9
|
-
useSuspense(params: ClientQueryArgs): import("@tanstack/react-query").UseSuspenseInfiniteQueryResult<BaseQuery["select"] extends (...args: any[]) => infer T ? T : InfiniteData<unknown, unknown>, Error>;
|
|
10
|
-
invalidate(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
11
|
-
invalidateAll(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=make-infinite-query-options.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-infinite-query-options.d.mts","sourceRoot":"","sources":["../../src/make-infinite-query-options.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,uBAAuB,EACvB,+BAA+B,EAChC,MAAM,uBAAuB,CAAA;AAS9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAIxD,wBAAgB,wBAAwB,CACtC,MAAM,SAAS,iBAAiB,EAChC,OAAO,SAAS,oBAAoB,CAAC,MAAM,CAAC,EAC5C,SAAS,SAAS,IAAI,CACpB,uBAAuB,CAAC,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,EACzE,UAAU,GACV,SAAS,GACT,kBAAkB,GAClB,kBAAkB,GAClB,iBAAiB,GACjB,cAAc,CACjB,EAED,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAClC,OAAO,EAAE,OAAO,EAChB,SAAS,GAAE,SAA2B;aAO5B,eAAe,GACtB,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,MAAM,GAClE,+BAA+B,CAC7B,MAAM,EACN,KAAK,EACL,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,GACnD,CAAC,GACD,YAAY,CAAC,MAAM,CAAC,CACzB,GACD,KAAK;;gBAmCU,eAAe,gGAvCU,GAAG,EAAE,KAAK,MAAM,CAAC;wBA2ClC,eAAe,wGA3CE,GAAG,EAAE,KAAK,MAAM,CAAC;4BA+C9B,WAAW,UAAU,eAAe;+BAOjC,WAAW,UAAU,eAAe;EASvE"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AbstractEndpoint, AnyEndpointConfig, UrlHasParams, UrlParams } from '@navios/builder';
|
|
2
|
-
import type { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
import type { z } from 'zod/v4';
|
|
4
|
-
import type { BaseMutationArgs, BaseMutationParams } from './types.mjs';
|
|
5
|
-
export declare function makeMutation<Config extends AnyEndpointConfig, TData = unknown, TVariables extends BaseMutationArgs<Config> = BaseMutationArgs<Config>, TResponse = z.output<Config['responseSchema']>, TContext = unknown, UseKey extends boolean = false>(endpoint: AbstractEndpoint<Config>, options: BaseMutationParams<Config, TData, TVariables, TResponse, TContext, UseKey>): {
|
|
6
|
-
(keyParams: UseKey extends true ? UrlHasParams<Config["url"]> extends true ? UrlParams<Config["url"]> : never : never): UseMutationResult<TData, Error, BaseMutationArgs<Config>>;
|
|
7
|
-
useIsMutating(keyParams: UseKey extends true ? UrlHasParams<Config["url"]> extends true ? UrlParams<Config["url"]> : never : never): boolean;
|
|
8
|
-
mutationKey: (params: UrlHasParams<Config["url"]> extends infer T ? T extends UrlHasParams<Config["url"]> ? T extends true ? {
|
|
9
|
-
urlParams: UrlParams<Config["url"]>;
|
|
10
|
-
} : {} : never : never) => [Config["url"]] & {
|
|
11
|
-
[dataTagSymbol]: TData | Promise<TData>;
|
|
12
|
-
[dataTagErrorSymbol]: Error;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=make-mutation.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-mutation.d.mts","sourceRoot":"","sources":["../../src/make-mutation.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACV,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAQ/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIvE,wBAAgB,YAAY,CAC1B,MAAM,SAAS,iBAAiB,EAChC,KAAK,GAAG,OAAO,EACf,UAAU,SAAS,gBAAgB,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAC,MAAM,CAAC,EACtE,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAC9C,QAAQ,GAAG,OAAO,EAClB,MAAM,SAAS,OAAO,GAAG,KAAK,EAE9B,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAClC,OAAO,EAAE,kBAAkB,CACzB,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,EACR,MAAM,CACP;gBAMY,MAAM,SAAS,IAAI,GAC1B,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,IAAI,GACtC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GACxB,KAAK,GACP,KAAK,GACR,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;6BAqD/C,MAAM,SAAS,IAAI,GAC1B,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,IAAI,GACtC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GACxB,KAAK,GACP,KAAK,GACR,OAAO;;;;;;;EAgBX"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AbstractEndpoint, AnyEndpointConfig } from '@navios/builder';
|
|
2
|
-
import type { DataTag, QueryClient, UseQueryOptions, UseSuspenseQueryOptions } from '@tanstack/react-query';
|
|
3
|
-
import type { BaseQueryArgs, BaseQueryParams } from './types.mjs';
|
|
4
|
-
import type { ClientQueryArgs } from './types/index.mjs';
|
|
5
|
-
type Split<S extends string, D extends string> = string extends S ? string[] : S extends '' ? [] : S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
|
|
6
|
-
export declare function makeQueryOptions<Config extends AnyEndpointConfig, Options extends BaseQueryParams<Config>, BaseQuery extends Omit<UseQueryOptions<ReturnType<Options['processResponse']>, Error, any>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam' | 'enabled' | 'throwOnError' | 'placeholderData'>>(endpoint: AbstractEndpoint<Config>, options: Options, baseQuery?: BaseQuery): {
|
|
7
|
-
(params: BaseQueryArgs<Config>): Options["processResponse"] extends (...args: any[]) => infer Result ? UseSuspenseQueryOptions<Result, Error, BaseQuery["select"] extends (...args: any[]) => infer T ? T : Result, DataTag<Split<Config["url"], "/">, Result, Error>> : never;
|
|
8
|
-
queryKey: import("./utils/query-key-creator.mjs").QueryKeyCreatorResult<Config["querySchema"], Config["url"], Options["processResponse"] extends (...args: any[]) => infer Result ? Result : never, false, import("@navios/builder").UrlHasParams<Config["url"]>>;
|
|
9
|
-
use(params: ClientQueryArgs): import("@tanstack/react-query").UseQueryResult<import("@tanstack/react-query").NoInfer<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown>, Error>;
|
|
10
|
-
useSuspense(params: ClientQueryArgs): import("@tanstack/react-query").UseSuspenseQueryResult<BaseQuery["select"] extends (...args: any[]) => infer T ? T : unknown, Error>;
|
|
11
|
-
invalidate(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
12
|
-
invalidateAll(queryClient: QueryClient, params: ClientQueryArgs): Promise<void>;
|
|
13
|
-
};
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=make-query-options.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-query-options.d.mts","sourceRoot":"","sources":["../../src/make-query-options.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EACX,eAAe,EACf,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAI9B,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAIxD,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,MAAM,SAAS,CAAC,GAC7D,MAAM,EAAE,GACR,CAAC,SAAS,EAAE,GACV,EAAE,GACF,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,EAAE,GAClC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACnB,CAAC,CAAC,CAAC,CAAA;AAEX,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,iBAAiB,EAChC,OAAO,SAAS,eAAe,CAAC,MAAM,CAAC,EACvC,SAAS,SAAS,IAAI,CACpB,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,EACjE,UAAU,GACV,SAAS,GACT,kBAAkB,GAClB,kBAAkB,GAClB,SAAS,GACT,cAAc,GACd,iBAAiB,CACpB,EAED,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAClC,OAAO,EAAE,OAAO,EAChB,SAAS,GAAE,SAA2B;aAQ5B,aAAa,CAAC,MAAM,CAAC,GAC5B,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,MAAM,GAClE,uBAAuB,CACrB,MAAM,EACN,KAAK,EACL,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,EACpE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAClD,GACD,KAAK;;gBAwBa,eAAe,gIA3BO,GAAG,EAAE,KAAK,MAAM,CAAC;wBAgC/B,eAAe,gGAhCD,GAAG,EAAE,KAAK,MAAM,CAAC;4BAqC3B,WAAW,UAAU,eAAe;+BAQvD,WAAW,UAChB,eAAe;EAU1B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BaseEndpointConfig, EndpointFunctionArgs, HttpMethod, Util_FlatObject } from '@navios/builder';
|
|
2
|
-
import type { z } from 'zod/v4';
|
|
3
|
-
export type ClientEndpointHelper<Method extends HttpMethod = HttpMethod, Url extends string = string, RequestSchema = unknown, ResponseSchema extends z.ZodType = z.ZodType, QuerySchema = unknown> = {
|
|
4
|
-
endpoint: ((params: Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, RequestSchema>>) => Promise<z.output<ResponseSchema>>) & {
|
|
5
|
-
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=client-endpoint-helper.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-endpoint-helper.d.mts","sourceRoot":"","sources":["../../../src/types/client-endpoint-helper.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,eAAe,EAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/B,MAAM,MAAM,oBAAoB,CAC9B,MAAM,SAAS,UAAU,GAAG,UAAU,EACtC,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,aAAa,GAAG,OAAO,EACvB,cAAc,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EAC5C,WAAW,GAAG,OAAO,IACnB;IACF,QAAQ,EAAE,CAAC,CACT,MAAM,EAAE,eAAe,CACrB,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,CACtD,KACE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;QACxC,MAAM,EAAE,kBAAkB,CACxB,MAAM,EACN,GAAG,EACH,WAAW,EACX,cAAc,EACd,aAAa,CACd,CAAA;KACF,CAAA;CACF,CAAA"}
|