@openapi-qraft/react 1.11.0-beta.2 → 1.11.0-beta.4
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 +12 -0
- package/dist/cjs/QraftContext.cjs +9 -0
- package/dist/cjs/QraftContext.cjs.map +1 -0
- package/dist/cjs/Unstable_QraftSecureRequestFn.cjs +193 -0
- package/dist/cjs/Unstable_QraftSecureRequestFn.cjs.map +1 -0
- package/dist/cjs/callbacks/cancelQueries.cjs +10 -0
- package/dist/cjs/callbacks/cancelQueries.cjs.map +1 -0
- package/dist/cjs/callbacks/fetchInfiniteQuery.cjs +10 -0
- package/dist/cjs/callbacks/fetchInfiniteQuery.cjs.map +1 -0
- package/dist/cjs/callbacks/fetchQuery.cjs +10 -0
- package/dist/cjs/callbacks/fetchQuery.cjs.map +1 -0
- package/dist/cjs/callbacks/getInfiniteQueryData.cjs +10 -0
- package/dist/cjs/callbacks/getInfiniteQueryData.cjs.map +1 -0
- package/dist/cjs/callbacks/getInfiniteQueryKey.cjs +10 -0
- package/dist/cjs/callbacks/getInfiniteQueryKey.cjs.map +1 -0
- package/dist/cjs/callbacks/getInfiniteQueryState.cjs +10 -0
- package/dist/cjs/callbacks/getInfiniteQueryState.cjs.map +1 -0
- package/dist/cjs/callbacks/getMutationKey.cjs +10 -0
- package/dist/cjs/callbacks/getMutationKey.cjs.map +1 -0
- package/dist/cjs/callbacks/getQueriesData.cjs +10 -0
- package/dist/cjs/callbacks/getQueriesData.cjs.map +1 -0
- package/dist/cjs/callbacks/getQueryData.cjs +10 -0
- package/dist/cjs/callbacks/getQueryData.cjs.map +1 -0
- package/dist/cjs/callbacks/getQueryKey.cjs +10 -0
- package/dist/cjs/callbacks/getQueryKey.cjs.map +1 -0
- package/dist/cjs/callbacks/getQueryState.cjs +10 -0
- package/dist/cjs/callbacks/getQueryState.cjs.map +1 -0
- package/dist/cjs/callbacks/index.cjs +76 -0
- package/dist/cjs/callbacks/index.cjs.map +1 -0
- package/dist/cjs/callbacks/invalidateQueries.cjs +10 -0
- package/dist/cjs/callbacks/invalidateQueries.cjs.map +1 -0
- package/dist/cjs/callbacks/isFetching.cjs +10 -0
- package/dist/cjs/callbacks/isFetching.cjs.map +1 -0
- package/dist/cjs/callbacks/isMutating.cjs +10 -0
- package/dist/cjs/callbacks/isMutating.cjs.map +1 -0
- package/dist/cjs/callbacks/mutationFn.cjs +12 -0
- package/dist/cjs/callbacks/mutationFn.cjs.map +1 -0
- package/dist/cjs/callbacks/operationInvokeFn.cjs +22 -0
- package/dist/cjs/callbacks/operationInvokeFn.cjs.map +1 -0
- package/dist/cjs/callbacks/prefetchInfiniteQuery.cjs +10 -0
- package/dist/cjs/callbacks/prefetchInfiniteQuery.cjs.map +1 -0
- package/dist/cjs/callbacks/prefetchQuery.cjs +10 -0
- package/dist/cjs/callbacks/prefetchQuery.cjs.map +1 -0
- package/dist/cjs/callbacks/queryFn.cjs +13 -0
- package/dist/cjs/callbacks/queryFn.cjs.map +1 -0
- package/dist/cjs/callbacks/refetchQueries.cjs +10 -0
- package/dist/cjs/callbacks/refetchQueries.cjs.map +1 -0
- package/dist/cjs/callbacks/removeQueries.cjs +10 -0
- package/dist/cjs/callbacks/removeQueries.cjs.map +1 -0
- package/dist/cjs/callbacks/resetQueries.cjs +10 -0
- package/dist/cjs/callbacks/resetQueries.cjs.map +1 -0
- package/dist/cjs/callbacks/setInfiniteQueryData.cjs +10 -0
- package/dist/cjs/callbacks/setInfiniteQueryData.cjs.map +1 -0
- package/dist/cjs/callbacks/setQueriesData.cjs +10 -0
- package/dist/cjs/callbacks/setQueriesData.cjs.map +1 -0
- package/dist/cjs/callbacks/setQueryData.cjs +10 -0
- package/dist/cjs/callbacks/setQueryData.cjs.map +1 -0
- package/dist/cjs/callbacks/useInfiniteQuery.cjs +13 -0
- package/dist/cjs/callbacks/useInfiniteQuery.cjs.map +1 -0
- package/dist/cjs/callbacks/useIsFetching.cjs +14 -0
- package/dist/cjs/callbacks/useIsFetching.cjs.map +1 -0
- package/dist/cjs/callbacks/useIsMutating.cjs +14 -0
- package/dist/cjs/callbacks/useIsMutating.cjs.map +1 -0
- package/dist/cjs/callbacks/useMutation.cjs +37 -0
- package/dist/cjs/callbacks/useMutation.cjs.map +1 -0
- package/dist/cjs/callbacks/useMutationState.cjs +17 -0
- package/dist/cjs/callbacks/useMutationState.cjs.map +1 -0
- package/dist/cjs/callbacks/useQueries.cjs +41 -0
- package/dist/cjs/callbacks/useQueries.cjs.map +1 -0
- package/dist/cjs/callbacks/useQuery.cjs +13 -0
- package/dist/cjs/callbacks/useQuery.cjs.map +1 -0
- package/dist/cjs/callbacks/useSuspenseInfiniteQuery.cjs +13 -0
- package/dist/cjs/callbacks/useSuspenseInfiniteQuery.cjs.map +1 -0
- package/dist/cjs/callbacks/useSuspenseQueries.cjs +41 -0
- package/dist/cjs/callbacks/useSuspenseQueries.cjs.map +1 -0
- package/dist/cjs/callbacks/useSuspenseQuery.cjs +13 -0
- package/dist/cjs/callbacks/useSuspenseQuery.cjs.map +1 -0
- package/dist/cjs/index.cjs +22 -1267
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/lib/callQueryClientFetchMethod.cjs +47 -0
- package/dist/cjs/lib/callQueryClientFetchMethod.cjs.map +1 -0
- package/dist/cjs/lib/callQueryClientMethodWithMutationFilters.cjs +19 -0
- package/dist/cjs/lib/callQueryClientMethodWithMutationFilters.cjs.map +1 -0
- package/dist/cjs/lib/callQueryClientMethodWithQueryFilters.cjs +19 -0
- package/dist/cjs/lib/callQueryClientMethodWithQueryFilters.cjs.map +1 -0
- package/dist/cjs/lib/callQueryClientMethodWithQueryKey.cjs +20 -0
- package/dist/cjs/lib/callQueryClientMethodWithQueryKey.cjs.map +1 -0
- package/dist/cjs/lib/composeBaseQueryKey.cjs +14 -0
- package/dist/cjs/lib/composeBaseQueryKey.cjs.map +1 -0
- package/dist/cjs/lib/composeInfiniteQueryKey.cjs +10 -0
- package/dist/cjs/lib/composeInfiniteQueryKey.cjs.map +1 -0
- package/dist/cjs/lib/composeMutationFilters.cjs +36 -0
- package/dist/cjs/lib/composeMutationFilters.cjs.map +1 -0
- package/dist/cjs/lib/composeMutationKey.cjs +29 -0
- package/dist/cjs/lib/composeMutationKey.cjs.map +1 -0
- package/dist/cjs/lib/composeQueryFilters.cjs +38 -0
- package/dist/cjs/lib/composeQueryFilters.cjs.map +1 -0
- package/dist/cjs/lib/composeQueryKey.cjs +10 -0
- package/dist/cjs/lib/composeQueryKey.cjs.map +1 -0
- package/dist/cjs/lib/createRecursiveProxy.cjs +35 -0
- package/dist/cjs/lib/createRecursiveProxy.cjs.map +1 -0
- package/dist/cjs/lib/jwt-decode/index.cjs +62 -0
- package/dist/cjs/lib/jwt-decode/index.cjs.map +1 -0
- package/dist/cjs/lib/requestFn.cjs +181 -0
- package/dist/cjs/lib/requestFn.cjs.map +1 -0
- package/dist/cjs/lib/shelfMerge.cjs +30 -0
- package/dist/cjs/lib/shelfMerge.cjs.map +1 -0
- package/dist/cjs/lib/useComposeUseQueryOptions.cjs +40 -0
- package/dist/cjs/lib/useComposeUseQueryOptions.cjs.map +1 -0
- package/dist/cjs/lib/useQueryClient.cjs +18 -0
- package/dist/cjs/lib/useQueryClient.cjs.map +1 -0
- package/dist/cjs/qraftAPIClient.cjs +48 -0
- package/dist/cjs/qraftAPIClient.cjs.map +1 -0
- package/dist/esm/QraftContext.js +7 -0
- package/dist/esm/QraftContext.js.map +1 -0
- package/dist/esm/Unstable_QraftSecureRequestFn.js +188 -0
- package/dist/esm/Unstable_QraftSecureRequestFn.js.map +1 -0
- package/dist/esm/callbacks/cancelQueries.js +8 -0
- package/dist/esm/callbacks/cancelQueries.js.map +1 -0
- package/dist/esm/callbacks/fetchInfiniteQuery.js +8 -0
- package/dist/esm/callbacks/fetchInfiniteQuery.js.map +1 -0
- package/dist/esm/callbacks/fetchQuery.js +8 -0
- package/dist/esm/callbacks/fetchQuery.js.map +1 -0
- package/dist/esm/callbacks/getInfiniteQueryData.js +8 -0
- package/dist/esm/callbacks/getInfiniteQueryData.js.map +1 -0
- package/dist/esm/callbacks/getInfiniteQueryKey.js +8 -0
- package/dist/esm/callbacks/getInfiniteQueryKey.js.map +1 -0
- package/dist/esm/callbacks/getInfiniteQueryState.js +8 -0
- package/dist/esm/callbacks/getInfiniteQueryState.js.map +1 -0
- package/dist/esm/callbacks/getMutationKey.js +8 -0
- package/dist/esm/callbacks/getMutationKey.js.map +1 -0
- package/dist/esm/callbacks/getQueriesData.js +8 -0
- package/dist/esm/callbacks/getQueriesData.js.map +1 -0
- package/dist/esm/callbacks/getQueryData.js +8 -0
- package/dist/esm/callbacks/getQueryData.js.map +1 -0
- package/dist/esm/callbacks/getQueryKey.js +8 -0
- package/dist/esm/callbacks/getQueryKey.js.map +1 -0
- package/dist/esm/callbacks/getQueryState.js +8 -0
- package/dist/esm/callbacks/getQueryState.js.map +1 -0
- package/dist/esm/callbacks/index.js +36 -0
- package/dist/esm/callbacks/index.js.map +1 -0
- package/dist/esm/callbacks/invalidateQueries.js +8 -0
- package/dist/esm/callbacks/invalidateQueries.js.map +1 -0
- package/dist/esm/callbacks/isFetching.js +8 -0
- package/dist/esm/callbacks/isFetching.js.map +1 -0
- package/dist/esm/callbacks/isMutating.js +8 -0
- package/dist/esm/callbacks/isMutating.js.map +1 -0
- package/dist/esm/callbacks/mutationFn.js +10 -0
- package/dist/esm/callbacks/mutationFn.js.map +1 -0
- package/dist/esm/callbacks/operationInvokeFn.js +20 -0
- package/dist/esm/callbacks/operationInvokeFn.js.map +1 -0
- package/dist/esm/callbacks/prefetchInfiniteQuery.js +8 -0
- package/dist/esm/callbacks/prefetchInfiniteQuery.js.map +1 -0
- package/dist/esm/callbacks/prefetchQuery.js +8 -0
- package/dist/esm/callbacks/prefetchQuery.js.map +1 -0
- package/dist/esm/callbacks/queryFn.js +11 -0
- package/dist/esm/callbacks/queryFn.js.map +1 -0
- package/dist/esm/callbacks/refetchQueries.js +8 -0
- package/dist/esm/callbacks/refetchQueries.js.map +1 -0
- package/dist/esm/callbacks/removeQueries.js +8 -0
- package/dist/esm/callbacks/removeQueries.js.map +1 -0
- package/dist/esm/callbacks/resetQueries.js +8 -0
- package/dist/esm/callbacks/resetQueries.js.map +1 -0
- package/dist/esm/callbacks/setInfiniteQueryData.js +8 -0
- package/dist/esm/callbacks/setInfiniteQueryData.js.map +1 -0
- package/dist/esm/callbacks/setQueriesData.js +8 -0
- package/dist/esm/callbacks/setQueriesData.js.map +1 -0
- package/dist/esm/callbacks/setQueryData.js +8 -0
- package/dist/esm/callbacks/setQueryData.js.map +1 -0
- package/dist/esm/callbacks/useInfiniteQuery.js +11 -0
- package/dist/esm/callbacks/useInfiniteQuery.js.map +1 -0
- package/dist/esm/callbacks/useIsFetching.js +12 -0
- package/dist/esm/callbacks/useIsFetching.js.map +1 -0
- package/dist/esm/callbacks/useIsMutating.js +12 -0
- package/dist/esm/callbacks/useIsMutating.js.map +1 -0
- package/dist/esm/callbacks/useMutation.js +35 -0
- package/dist/esm/callbacks/useMutation.js.map +1 -0
- package/dist/esm/callbacks/useMutationState.js +15 -0
- package/dist/esm/callbacks/useMutationState.js.map +1 -0
- package/dist/esm/callbacks/useQueries.js +39 -0
- package/dist/esm/callbacks/useQueries.js.map +1 -0
- package/dist/esm/callbacks/useQuery.js +11 -0
- package/dist/esm/callbacks/useQuery.js.map +1 -0
- package/dist/esm/callbacks/useSuspenseInfiniteQuery.js +11 -0
- package/dist/esm/callbacks/useSuspenseInfiniteQuery.js.map +1 -0
- package/dist/esm/callbacks/useSuspenseQueries.js +39 -0
- package/dist/esm/callbacks/useSuspenseQueries.js.map +1 -0
- package/dist/esm/callbacks/useSuspenseQuery.js +11 -0
- package/dist/esm/callbacks/useSuspenseQuery.js.map +1 -0
- package/dist/esm/index.js +7 -1220
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/callQueryClientFetchMethod.js +45 -0
- package/dist/esm/lib/callQueryClientFetchMethod.js.map +1 -0
- package/dist/esm/lib/callQueryClientMethodWithMutationFilters.js +17 -0
- package/dist/esm/lib/callQueryClientMethodWithMutationFilters.js.map +1 -0
- package/dist/esm/lib/callQueryClientMethodWithQueryFilters.js +17 -0
- package/dist/esm/lib/callQueryClientMethodWithQueryFilters.js.map +1 -0
- package/dist/esm/lib/callQueryClientMethodWithQueryKey.js +18 -0
- package/dist/esm/lib/callQueryClientMethodWithQueryKey.js.map +1 -0
- package/dist/esm/lib/composeBaseQueryKey.js +12 -0
- package/dist/esm/lib/composeBaseQueryKey.js.map +1 -0
- package/dist/esm/lib/composeInfiniteQueryKey.js +8 -0
- package/dist/esm/lib/composeInfiniteQueryKey.js.map +1 -0
- package/dist/esm/lib/composeMutationFilters.js +34 -0
- package/dist/esm/lib/composeMutationFilters.js.map +1 -0
- package/dist/esm/lib/composeMutationKey.js +26 -0
- package/dist/esm/lib/composeMutationKey.js.map +1 -0
- package/dist/esm/lib/composeQueryFilters.js +36 -0
- package/dist/esm/lib/composeQueryFilters.js.map +1 -0
- package/dist/esm/lib/composeQueryKey.js +8 -0
- package/dist/esm/lib/composeQueryKey.js.map +1 -0
- package/dist/esm/lib/createRecursiveProxy.js +33 -0
- package/dist/esm/lib/createRecursiveProxy.js.map +1 -0
- package/dist/esm/lib/jwt-decode/index.js +58 -0
- package/dist/esm/lib/jwt-decode/index.js.map +1 -0
- package/dist/esm/lib/requestFn.js +175 -0
- package/dist/esm/lib/requestFn.js.map +1 -0
- package/dist/esm/lib/shelfMerge.js +28 -0
- package/dist/esm/lib/shelfMerge.js.map +1 -0
- package/dist/esm/lib/useComposeUseQueryOptions.js +38 -0
- package/dist/esm/lib/useComposeUseQueryOptions.js.map +1 -0
- package/dist/esm/lib/useQueryClient.js +16 -0
- package/dist/esm/lib/useQueryClient.js.map +1 -0
- package/dist/esm/qraftAPIClient.js +46 -0
- package/dist/esm/qraftAPIClient.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +10 -21
- package/src/index.ts +1 -1
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/lib/createRecursiveProxy.ts","../../src/qraftAPIClient.ts","../../src/QraftContext.ts","../../src/lib/requestFn.ts","../../src/lib/composeBaseQueryKey.ts","../../src/lib/composeInfiniteQueryKey.ts","../../src/lib/composeQueryKey.ts","../../src/lib/callQueryClientMethodWithQueryKey.ts","../../src/callbacks/getInfiniteQueryData.ts","../../src/callbacks/getInfiniteQueryKey.ts","../../src/lib/composeMutationKey.ts","../../src/callbacks/getMutationKey.ts","../../src/callbacks/getQueryData.ts","../../src/lib/composeQueryFilters.ts","../../src/lib/callQueryClientMethodWithQueryFilters.ts","../../src/callbacks/getQueriesData.ts","../../src/callbacks/getQueryKey.ts","../../src/callbacks/mutationFn.ts","../../src/callbacks/queryFn.ts","../../src/callbacks/setInfiniteQueryData.ts","../../src/callbacks/setQueryData.ts","../../src/callbacks/setQueriesData.ts","../../src/callbacks/useInfiniteQuery.ts","../../src/lib/useComposeUseQueryOptions.ts","../../src/lib/shelfMerge.ts","../../src/lib/useQueryClient.ts","../../src/callbacks/useMutation.ts","../../src/callbacks/useQuery.ts","../../src/callbacks/useSuspenseQuery.ts","../../src/callbacks/useSuspenseInfiniteQuery.ts","../../src/callbacks/useMutationState.ts","../../src/lib/composeMutationFilters.ts","../../src/callbacks/useIsMutating.ts","../../src/callbacks/useQueries.ts","../../src/callbacks/useSuspenseQueries.ts","../../src/callbacks/invalidateQueries.ts","../../src/callbacks/cancelQueries.ts","../../src/callbacks/resetQueries.ts","../../src/callbacks/removeQueries.ts","../../src/callbacks/refetchQueries.ts","../../src/callbacks/isFetching.ts","../../src/lib/callQueryClientMethodWithMutationFilters.ts","../../src/callbacks/isMutating.ts","../../src/callbacks/useIsFetching.ts","../../src/lib/callQueryClientFetchMethod.ts","../../src/callbacks/fetchQuery.ts","../../src/callbacks/prefetchQuery.ts","../../src/callbacks/fetchInfiniteQuery.ts","../../src/callbacks/prefetchInfiniteQuery.ts","../../src/callbacks/getQueryState.ts","../../src/callbacks/getInfiniteQueryState.ts","../../src/callbacks/operationInvokeFn.ts","../../src/Unstable_QraftSecureRequestFn.ts","../../src/lib/jwt-decode/index.ts"],"sourcesContent":["export { qraftAPIClient, type QraftClientOptions } from './qraftAPIClient.js';\nexport { QraftContext, type QraftContextValue } from './QraftContext.js';\nexport {\n requestFn,\n baseRequestFn,\n urlSerializer,\n bodySerializer,\n mergeHeaders,\n type RequestFn,\n type RequestFnPayload,\n type OperationSchema,\n type RequestFnOptions,\n type HeadersOptions,\n} from './lib/requestFn.js';\nexport type * from './service-operation/index.js';\nexport * from './callbacks/index.js';\nexport {\n QraftSecureRequestFn as Unstable_QraftSecureRequestFn,\n type QraftSecureRequestFnProps,\n useSecuritySchemeAuth,\n createSecureRequestFn,\n type SecuritySchemeHandlers,\n type SecuritySchemeCookie,\n type SecuritySchemeBasic,\n type SecuritySchemeBearer,\n type SecuritySchemeAPIKey,\n} from './Unstable_QraftSecureRequestFn.js';\n","type ProxyApplyCallback = (path: string[], args: unknown[]) => unknown;\n/**\n * @internal\n * If returns `undefined | null`, the proxy will continue to create a new proxy for the next key.\n */\ntype ProxyGetCallback = (path: string[], key: string) => unknown | undefined;\n\n// todo::rename to `qraftRecursiveProxy` with deprecated `createRecursiveProxy`\n/**\n * Creates a recursive proxy that calls the `getCallback` and `applyCallback` functions\n * @param getCallback The callback to call when a proxy property is accessed\n * @param applyCallback The callback to call when a proxy is called as a function\n * @param path The current path of the proxy\n */\nexport function createRecursiveProxy(\n getCallback: ProxyGetCallback,\n applyCallback: ProxyApplyCallback,\n path: string[]\n): unknown {\n return new Proxy(noop, {\n get(_obj, key) {\n if (typeof key !== 'string' || key === 'then') {\n // special case for if the proxy is accidentally treated\n // like a PromiseLike (like in `Promise.resolve(proxy)`)\n return undefined;\n }\n\n return (\n getCallback(path, key) ??\n createRecursiveProxy(getCallback, applyCallback, [...path, key])\n );\n },\n apply(_1, _2, args) {\n const functionName = path[path.length - 1];\n\n const isCall = functionName === 'call';\n const isApply = isCall ? false : functionName === 'apply';\n\n return applyCallback(\n isApply || isCall ? path.slice(0, -1) : path,\n isApply\n ? args.length >= 2\n ? args[1]\n : []\n : isCall\n ? args.slice(1)\n : args\n );\n },\n });\n}\n\nfunction noop() {\n // noop\n}\n","import type { Context } from 'react';\n\nimport type * as operationInvokeModule from './callbacks/operationInvokeFn.js';\nimport { createRecursiveProxy } from './lib/createRecursiveProxy.js';\nimport type { OperationSchema } from './lib/requestFn.js';\nimport type { QraftContextValue } from './QraftContext.js';\n\nexport interface QraftClientOptions {\n context?: Context<QraftContextValue>;\n}\n\nexport const qraftAPIClient = <\n Services extends ServicesBaseDeclaration<Services>,\n Callbacks extends ServicesCallbacks,\n>(\n services: ServicesDeclaration<Services>,\n callbacks: Callbacks,\n options?: QraftClientOptions\n): Services => {\n return createRecursiveProxy(\n function getCallback(getPath, key) {\n if (getPath.length !== 2 || key !== 'schema') return; // todo::maybe return callback?\n\n const serviceOperation = getByPath(services, getPath);\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${getPath.join('.')}`);\n return serviceOperation.schema;\n },\n function applyCallback(applyPath, args) {\n const { path, callbackName } = extractCallbackDetails(applyPath);\n\n if (!(callbackName in callbacks))\n throw new Error(`Function ${callbackName} is not supported`);\n\n const serviceOperation = getByPath(services, path);\n\n if (!isServiceOperation(serviceOperation))\n throw new Error(`Service operation not found: ${path.join('.')}`);\n\n return callbacks[callbackName as keyof Callbacks](\n options,\n serviceOperation.schema,\n args\n );\n },\n []\n ) as never;\n};\n\n/**\n * Extracts Callback details from the applyPath\n * @param applyPath\n */\nfunction extractCallbackDetails(applyPath: string[]) {\n // <service>.<operation>()\n if (applyPath.length === 2) {\n return {\n path: applyPath,\n callbackName: 'operationInvokeFn' satisfies Extract<\n keyof typeof operationInvokeModule,\n 'operationInvokeFn'\n >,\n };\n } else {\n // <service>.<operation>.<method>()\n return {\n path: applyPath.slice(0, -1),\n // The last arg is for instance `.useMutation` or `.useQuery()`\n callbackName: applyPath[applyPath.length - 1],\n };\n }\n}\n\nfunction isServiceOperation(\n input: unknown\n): input is { schema: OperationSchema } {\n return input !== null && typeof input === 'object' && 'schema' in input;\n}\n\nfunction getByPath(obj: Record<string, unknown>, path: string[]) {\n return path.reduce<unknown>((acc, key) => {\n if (acc && typeof acc === 'object' && key in acc)\n return acc[key as keyof typeof acc];\n }, obj);\n}\n\ntype ServicesBaseDeclaration<Services> = {\n [service in keyof Services]: {\n [method in keyof Services[service]]: { schema: OperationSchema };\n };\n};\n\ntype ServicesDeclaration<Services extends ServicesBaseDeclaration<Services>> = {\n [service in keyof Services]: {\n [method in keyof Services[service]]: {\n schema: Services[service][method]['schema'];\n };\n };\n};\n\ntype ServicesCallbacks = Record<string, (...rest: any[]) => unknown>;\n","'use client';\n\nimport { createContext } from 'react';\n\nimport type { QueryClient } from '@tanstack/react-query';\n\nimport type { OperationSchema, RequestFnPayload } from './lib/requestFn.js';\n\ninterface QraftContextValueBase {\n /**\n * Base URL to use for the request\n * @example 'https://api.example.com'\n */\n baseUrl?: string;\n\n /**\n * The `requestFn` will be invoked with every request.\n */\n requestFn<T>(\n requestSchema: OperationSchema,\n requestInfo: RequestFnPayload\n ): Promise<T>;\n\n /** The QueryClient to use in Hooks */\n queryClient?: QueryClient;\n}\n\nexport type QraftContextValue = QraftContextValueBase | undefined;\n\nexport const QraftContext = createContext<QraftContextValue>(undefined);\n","/**\n * This function is used to make a request to a specified endpoint.\n *\n * @template T The expected return type of the request.\n *\n * @param schema The schema of the operation to be performed. It includes the OpenAPI path, HTTP method and media type.\n * @param requestInfo The information required to make the request. It includes parameters, headers, body, etc.\n * @param [options] Optional. Additional options for the request. It includes custom urlSerializer, bodySerializer, and fetch function.\n *\n * @returns {Promise<T>} Returns a promise that resolves with the response of the request.\n *\n * @throws {error: object|string, response: Response} Throws an error if the request fails. The error includes the error message and the response from the server.\n */\nexport async function requestFn<T>(\n schema: OperationSchema,\n requestInfo: RequestFnInfo,\n options?: RequestFnOptions\n): Promise<T> {\n return baseRequestFn(schema, requestInfo, {\n urlSerializer,\n bodySerializer,\n ...options,\n });\n}\n\n/**\n * This function is used to make a request to a specified endpoint.\n * It's needed to create a custom `requestFn` with a custom `urlSerializer`\n * and `bodySerializer`, with the tree-shaking of the default `requestFn`\n * and its serializers.\n *\n * @template T The expected return type of the request.\n *\n * @param requestSchema The schema of the operation to be performed. It includes the OpenAPI path, HTTP method and media type.\n * @param requestInfo The information required to make the request. It includes parameters, headers, body, etc.\n * @param options The options for the request. It includes urlSerializer, bodySerializer, and fetch function. The 'urlSerializer' and 'bodySerializer' are required.\n *\n * @returns {Promise<T>} Returns a promise that resolves with the response of the request.\n *\n * @throws {error: object|string, response: Response} Throws an error if the request fails. The error includes the error message and the response from the server.\n */\nexport async function baseRequestFn<T>(\n requestSchema: OperationSchema,\n requestInfo: RequestFnInfo,\n options: WithRequired<RequestFnOptions, 'urlSerializer' | 'bodySerializer'>\n): Promise<T> {\n const { parameters, headers, body, ...requestInfoRest } = requestInfo;\n\n const requestBody = options.bodySerializer(requestSchema, requestInfo);\n\n const baseFetch = options.fetch ?? fetch;\n\n const response = await baseFetch(\n options.urlSerializer(requestSchema, requestInfo),\n {\n method: requestSchema.method.toUpperCase(),\n body: requestBody,\n headers: mergeHeaders(\n {\n Accept: 'application/json',\n 'Content-Type': requestSchema.mediaType ?? getBodyContentType(body),\n },\n headers,\n parameters?.header,\n requestBody instanceof FormData\n ? // remove `Content-Type` if serialized body is FormData; browser will correctly set Content-Type & boundary expression\n { 'Content-Type': null }\n : undefined\n ),\n ...requestInfoRest,\n }\n );\n\n // clone response to allow multiple reads\n const clonedResponse = response.clone();\n\n if (!response.ok) {\n throw await getResponseBody(clonedResponse);\n }\n\n return (await getResponseBody(clonedResponse)) as T;\n}\n\nexport function urlSerializer(\n schema: OperationSchema,\n info: RequestFnPayload\n): string {\n const path = schema.url.replace(\n /{(.*?)}/g,\n (substring: string, group: string) => {\n if (\n info.parameters?.path &&\n Object.prototype.hasOwnProperty.call(info.parameters.path, group)\n ) {\n return encodeURI(String(info.parameters?.path[group]));\n }\n return substring;\n }\n );\n\n const baseUrl = info.baseUrl ?? '';\n\n if (info.parameters?.query) {\n return `${baseUrl}${path}${getQueryString(info.parameters.query)}`;\n }\n\n return `${baseUrl}${path}`;\n}\n\nfunction getQueryString(params: Record<string, any>): string {\n const qs: string[] = [];\n\n const append = (key: string, value: any) => {\n qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);\n };\n\n const process = (key: string, value: any) => {\n if (typeof value === 'undefined' || value === null) return;\n\n if (Array.isArray(value)) {\n value.forEach((v) => {\n process(key, v);\n });\n } else if (typeof value === 'object') {\n Object.entries(value).forEach(([k, v]) => {\n process(`${key}[${k}]`, v);\n });\n } else {\n append(key, value);\n }\n };\n\n Object.entries(params).forEach(([key, value]) => {\n process(key, value);\n });\n\n if (qs.length > 0) {\n return `?${qs.join('&')}`;\n }\n\n return '';\n}\n\nexport function mergeHeaders(...allHeaders: (HeadersOptions | undefined)[]) {\n const headers = new Headers();\n\n for (const headerSet of allHeaders) {\n if (!headerSet || typeof headerSet !== 'object') {\n continue;\n }\n\n const headersIterator =\n headerSet instanceof Headers\n ? headerSet.entries()\n : Object.entries(headerSet);\n\n for (const [headerKey, headerValue] of headersIterator) {\n if (headerValue === null) {\n headers.delete(headerKey);\n } else if (headerValue !== undefined) {\n headers.set(headerKey, headerValue);\n }\n }\n }\n\n return headers;\n}\n\nexport function bodySerializer(\n schema: OperationSchema,\n info: RequestFnPayload\n) {\n if (info.body === undefined) return;\n\n if (\n schema.method === 'get' ||\n schema.method === 'head' ||\n schema.method === 'options'\n )\n return;\n\n if (schema.mediaType?.includes('/form-data'))\n return getRequestBodyFormData(info);\n\n if (\n !schema.mediaType?.includes('/json') &&\n (typeof info.body === 'string' ||\n info.body instanceof Blob ||\n info.body instanceof FormData)\n ) {\n return info.body;\n }\n\n return JSON.stringify(info.body);\n}\n\nfunction getRequestBodyFormData({\n body,\n}: Pick<RequestFnPayload, 'body'>): FormData | undefined {\n if (body instanceof FormData) return body;\n if (body === null) return;\n\n if (body instanceof Blob) throw new Error('Blob not supported in form-data');\n if (body instanceof ArrayBuffer)\n throw new Error('ArrayBuffer not supported in form-data');\n if (body instanceof URLSearchParams)\n throw new Error('URLSearchParams not supported in form-data');\n if (body instanceof ReadableStream)\n throw new Error('ReadableStream not supported in form-data');\n if (typeof body === 'string')\n throw new Error('String not supported in form-data');\n if (typeof body !== 'object')\n throw new Error(`Unsupported body type ${typeof body} in form-data.`);\n\n const formData = new FormData();\n\n const process = (key: string, value: any) => {\n if (typeof value === 'string' || value instanceof Blob) {\n formData.append(key, value);\n } else {\n formData.append(key, JSON.stringify(value));\n }\n };\n\n Object.entries(body)\n .filter(([_, value]) => typeof value !== 'undefined' && value !== null)\n .forEach(([key, value]) => {\n if (Array.isArray(value)) {\n value.forEach((v) => process(key, v));\n } else {\n process(key, value);\n }\n });\n\n return formData;\n}\n\nfunction getBodyContentType(body: RequestFnPayload['body']) {\n if (!body) return;\n if (body instanceof Blob) return body.type || 'application/octet-stream';\n if (typeof body === 'string') return 'text/plain';\n if (!(body instanceof FormData)) return 'application/json';\n}\n\nasync function getResponseBody<T>(response: Response): Promise<T | undefined> {\n if (response.status === 204 || response.headers.get('Content-Length') === '0')\n return undefined;\n\n const contentType = response.headers.get('Content-Type')?.toLowerCase();\n const isJSON =\n contentType?.includes('/json') || contentType?.includes('+json');\n\n if (isJSON) {\n // attempt to parse JSON for successful responses, otherwise fail\n if (response.ok) return response.json();\n\n const errorFallbackResponse = response.clone(); // clone to allow multiple reads\n\n return response.json().catch(() => {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n 'Failed to parse response body as JSON. Falling back to .text()'\n );\n }\n // falling back to .text() when necessary for error messages\n return errorFallbackResponse.text();\n });\n }\n\n return response.text() as Promise<T>;\n}\n\n// To have definitely typed headers without a conversion to stings\nexport type HeadersOptions =\n | HeadersInit\n | Record<string, string | number | boolean | null | undefined>;\n\nexport interface OperationSchema {\n /**\n * Operation path\n * @example /user/{id}\n */\n readonly url: string; //todo::rename to `path`\n\n /**\n * Operation method\n */\n readonly method:\n | 'get'\n | 'put'\n | 'post'\n | 'patch'\n | 'delete'\n | 'options'\n | 'head'\n | 'trace';\n\n /**\n * Media type of the request body\n * @example application/json\n */\n readonly mediaType?: string;\n\n readonly security?: string[];\n}\n\nexport interface RequestFnPayload {\n /**\n * Base URL to use for the request\n * @example 'https://api.example.com'\n */\n baseUrl: string | undefined;\n\n /**\n * OpenAPI parameters\n * @example\n * ```ts\n * { path: {id: 1}, query: {search: 'hello'} }\n * ```\n */\n readonly parameters?: {\n readonly path?: Record<string, any>;\n readonly header?: Record<string, any>;\n readonly query?: Record<string, any>;\n };\n\n /**\n * Request body\n * @example { name: 'John' }\n */\n readonly body?: BodyInit | Record<string, unknown> | null;\n\n /**\n * Tanstack Query Meta\n */\n meta?: Record<string, unknown>;\n\n /** An AbortSignal to set request's signal. */\n signal?: AbortSignal | null;\n}\n\nexport interface RequestFnInfo\n extends RequestFnPayload,\n Omit<RequestInit, 'headers' | 'method' | 'body' | 'signal'> {\n /**\n * Request headers\n * @example { 'X-Auth': '123' }\n */\n readonly headers?: HeadersOptions;\n}\n\nexport interface RequestFnOptions {\n urlSerializer?: typeof urlSerializer;\n bodySerializer?: typeof bodySerializer;\n fetch?: typeof fetch;\n}\n\nexport type RequestFn<T> = typeof requestFn<T>;\n\ntype WithRequired<T, K extends keyof T> = T & {\n [_ in K]: {};\n};\n","import type {\n ServiceOperationInfiniteQueryKey,\n ServiceOperationQueryKey,\n} from '../service-operation/ServiceOperationKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\nexport function composeBaseQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined,\n infinite: undefined\n): [TSchema, TParams];\nexport function composeBaseQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined,\n infinite: true\n): ServiceOperationInfiniteQueryKey<TSchema, TParams>;\nexport function composeBaseQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined,\n infinite: false\n): ServiceOperationQueryKey<TSchema, TParams>;\nexport function composeBaseQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined,\n infinite: boolean | undefined\n):\n | ServiceOperationQueryKey<TSchema, TParams>\n | ServiceOperationInfiniteQueryKey<TSchema, TParams>\n | [TSchema, TParams] {\n return [\n typeof infinite === 'boolean' ? { ...schema, infinite } : schema,\n parameters ?? ({} as TParams),\n ];\n}\n","import type { ServiceOperationInfiniteQueryKey } from '../service-operation/ServiceOperationKey.js';\nimport { composeBaseQueryKey } from './composeBaseQueryKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\nexport function composeInfiniteQueryKey<\n TSchema extends OperationSchema,\n TParams,\n>(\n schema: TSchema,\n parameters: TParams | undefined\n): ServiceOperationInfiniteQueryKey<TSchema, TParams> {\n return composeBaseQueryKey(schema, parameters, true);\n}\n","import type { ServiceOperationQueryKey } from '../service-operation/ServiceOperationKey.js';\nimport { composeBaseQueryKey } from './composeBaseQueryKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\nexport function composeQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined\n): ServiceOperationQueryKey<TSchema, TParams> {\n return composeBaseQueryKey(schema, parameters, false);\n}\n","import type { QueryClient } from '@tanstack/query-core';\n\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Calls a query client method with parameters and options,\n * and automatically composes the `QueryKey` based on the schema and parameters.\n */\nexport function callQueryClientMethodWithQueryKey<\n QFMethod extends QueryKeyMethods,\n>(\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n infinite: boolean,\n args: [...Parameters<(typeof QueryClient.prototype)[QFMethod]>, QueryClient]\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const parameters = args.length > 1 ? args[0] : undefined;\n const queryClient = args[args.length - 1] as QueryClient | undefined;\n\n if (!queryClient) throw new Error('queryClient is required');\n if (!queryClient[queryFilterMethod])\n throw new Error(\n `queryClient is invalid, ${queryFilterMethod} method does not exist`\n );\n\n const queryKey = Array.isArray(parameters)\n ? parameters\n : infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters);\n\n // @ts-expect-error - Too complex to type\n return queryClient[queryFilterMethod](queryKey, ...args.slice(1, -1));\n}\n\ntype QueryKeyMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n\ntype QueryKeyMethods =\n | QueryKeyMethod<'setQueryData'>\n | QueryKeyMethod<'getQueryData'>\n | QueryKeyMethod<'getQueryState'>\n | QueryKeyMethod<'setQueryDefaults'>\n | QueryKeyMethod<'getQueryDefaults'>;\n","import type { InfiniteData } from '@tanstack/query-core';\n\nimport { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport function getInfiniteQueryData<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<\n OperationSchema,\n unknown,\n TData\n >['getInfiniteQueryData']\n >\n): InfiniteData<TData> | undefined {\n return callQueryClientMethodWithQueryKey(\n 'getQueryData',\n schema,\n true,\n args as never\n ) as never;\n}\n","import { composeInfiniteQueryKey } from '../lib/composeInfiniteQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const getInfiniteQueryKey = (\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<\n OperationSchema,\n unknown,\n unknown\n >['getInfiniteQueryKey']\n >\n) => {\n return composeInfiniteQueryKey(schema, args[0]);\n};\n","import type { ServiceOperationMutationKey } from '../service-operation/ServiceOperationKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Omit `body` or `requestBody` from mutation parameters if exists\n * and return the rest of the parameters\n */\nexport function composeMutationKey<TSchema extends OperationSchema>(\n schema: TSchema,\n parameters: undefined\n): ServiceOperationMutationKey<TSchema, undefined>;\nexport function composeMutationKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams\n): ServiceOperationMutationKey<TSchema, TParams>;\nexport function composeMutationKey<\n TSchema extends OperationSchema,\n TParams = unknown,\n>(schema: TSchema, parameters: TParams | undefined) {\n return parameters === undefined\n ? [{ url: schema.url, method: schema.method }, {}]\n : [\n {\n url: schema.url,\n method: schema.method,\n },\n omitMutationPayload(parameters),\n ];\n}\n\nexport function omitMutationPayload<T>(params: T) {\n if (!params || typeof params !== 'object')\n throw new Error('`params` must be object');\n\n if ('body' in params || 'requestBody' in params) {\n const {\n body: _,\n requestBody: __,\n ...paramsRest\n } = params as Record<'body' | 'requestBody', unknown>;\n return paramsRest;\n }\n\n return params as Omit<T, 'body' | 'requestBody'>;\n}\n","import { composeMutationKey } from '../lib/composeMutationKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationMutation } from '../service-operation/ServiceOperation.js';\n\nexport const getMutationKey = (\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationMutation<\n OperationSchema,\n unknown,\n unknown,\n unknown\n >['getMutationKey']\n >\n) => {\n return composeMutationKey(schema, args[0]);\n};\n","import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport function getQueryData<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<OperationSchema, unknown, TData>['getQueryData']\n >\n): TData | undefined {\n return callQueryClientMethodWithQueryKey(\n 'getQueryData',\n schema,\n false,\n args as never\n ) as never;\n}\n","import { composeBaseQueryKey } from './composeBaseQueryKey.js';\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Replaces the `parameters` field in the filters with a `queryKey` field based on the schema.\n * If no filters are provided, a `queryKey` will be composed schema's base query key.\n * @param schema\n * @param filters\n */\nexport function composeQueryFilters<\n Filters extends {\n infinite: boolean;\n parameters?: object;\n } & Record<string, unknown>,\n>(schema: OperationSchema, filters: Filters | undefined) {\n if (!filters) {\n return {\n queryKey: composeBaseQueryKey(schema, undefined, undefined),\n };\n }\n\n if ('queryKey' in filters && 'parameters' in filters) {\n throw new Error(\n `'composeQueryFilters': 'queryKey' and 'parameters' cannot be used together`\n );\n }\n\n const { infinite, parameters, ...filtersRest } = filters;\n\n if ('queryKey' in filtersRest) {\n return filtersRest;\n }\n\n if (parameters) {\n Object.assign(filtersRest, {\n queryKey: infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters),\n });\n\n return filtersRest;\n }\n\n return {\n ...filtersRest,\n queryKey: infinite\n ? composeInfiniteQueryKey(schema, undefined)\n : composeQueryKey(schema, undefined),\n };\n}\n","import type { QueryClient } from '@tanstack/query-core';\n\nimport { composeQueryFilters } from './composeQueryFilters.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Calls a query client method with query filters and options,\n * and automatically composes the `QueryKey` based on the schema and parameters.\n */\nexport function callQueryClientMethodWithQueryFilters<\n QFMethod extends QueryFilterMethods,\n>(\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n args: [...Parameters<(typeof QueryClient.prototype)[QFMethod]>, QueryClient]\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const filters = args.length > 1 ? args[0] : undefined;\n const queryClient = args[args.length - 1] as QueryClient | undefined;\n\n if (!queryClient) throw new Error('queryClient is required');\n if (!queryClient[queryFilterMethod])\n throw new Error(\n `queryClient is invalid, ${queryFilterMethod} method does not exist`\n );\n\n // @ts-expect-error - Too complex to type\n return queryClient[queryFilterMethod](\n composeQueryFilters(schema, filters as never),\n // @ts-expect-error - Argument types are too complex\n ...args.slice(1, -1)\n );\n}\n\ntype QueryFiltersMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n\ntype QueryFilterMethods =\n | QueryFiltersMethod<'isFetching'>\n | QueryFiltersMethod<'getQueriesData'>\n | QueryFiltersMethod<'setQueriesData'>\n | QueryFiltersMethod<'removeQueries'>\n | QueryFiltersMethod<'resetQueries'>\n | QueryFiltersMethod<'cancelQueries'>\n | QueryFiltersMethod<'invalidateQueries'>\n | QueryFiltersMethod<'refetchQueries'>;\n","import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport function getQueriesData<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<OperationSchema, unknown, TData>['getQueriesData']\n >\n): TData | undefined {\n return callQueryClientMethodWithQueryFilters(\n 'getQueriesData',\n schema,\n args as never\n ) as never;\n}\n","import { composeQueryKey } from '../lib/composeQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const getQueryKey = (\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<OperationSchema, unknown, unknown>['getQueryKey']\n >\n) => {\n return composeQueryKey(schema, args[0]);\n};\n","import type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationMutation } from '../service-operation/ServiceOperation.js';\n\nexport const mutationFn = (\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: unknown\n) => {\n const [client, options] = args as Parameters<\n ServiceOperationMutation<\n OperationSchema,\n unknown,\n unknown,\n never\n >['mutationFn']\n >;\n return client(schema, {\n parameters: options?.parameters,\n body: options?.body,\n });\n};\n","import type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const queryFn: <\n TSchema extends { url: string; method: 'get' | 'head' | 'options' },\n TData,\n TParams,\n>(\n qraftOptions: QraftClientOptions | undefined,\n schema: TSchema,\n args: Parameters<ServiceOperationQuery<TSchema, TData, TParams>['queryFn']>\n) => Promise<TData> = (_, schema, args) => {\n const [options, client] = args;\n\n return client(\n options && 'queryKey' in options ? options.queryKey![0] : schema,\n {\n parameters:\n options && 'queryKey' in options\n ? options.queryKey![1]\n : options.parameters,\n meta: options.meta,\n signal: options.signal,\n }\n ) as Promise<never>;\n};\n","import { InfiniteData } from '@tanstack/query-core';\n\nimport { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport function setInfiniteQueryData<TData>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<\n OperationSchema,\n unknown,\n TData\n >['setInfiniteQueryData']\n >\n): InfiniteData<TData> | undefined {\n return callQueryClientMethodWithQueryKey(\n 'setQueryData',\n schema,\n true,\n args as never\n ) as never;\n}\n","import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationSetQueryDataCallback } from '../service-operation/ServiceOperationSetQueryData.js';\n\nexport function setQueryData<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationSetQueryDataCallback<\n OperationSchema,\n unknown,\n TData\n >['setQueryData']\n >\n): TData | undefined {\n return callQueryClientMethodWithQueryKey(\n 'setQueryData',\n schema,\n false,\n args as never\n ) as never;\n}\n","import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationSetQueriesDataCallback } from '../service-operation/ServiceOperationSetQueriesData.js';\n\nexport function setQueriesData<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationSetQueriesDataCallback<\n OperationSchema,\n unknown,\n TData\n >['setQueriesData']\n >\n): TData | undefined {\n return callQueryClientMethodWithQueryFilters(\n 'setQueriesData',\n schema,\n args as never\n ) as never;\n}\n","'use client';\n\nimport type { DefaultError, InfiniteData } from '@tanstack/query-core';\nimport {\n useInfiniteQuery as useInfiniteQueryBase,\n type UseInfiniteQueryResult,\n} from '@tanstack/react-query';\n\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useComposeUseQueryOptions } from '../lib/useComposeUseQueryOptions.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const useInfiniteQuery: <\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<OperationSchema, unknown, unknown>['useInfiniteQuery']\n >\n) => UseInfiniteQueryResult<TData, TError> = (qraftOptions, schema, args) => {\n return useInfiniteQueryBase(\n // @ts-expect-error - Too complex to type...\n ...useComposeUseQueryOptions(qraftOptions, schema, args, true)\n ) as never;\n};\n","'use client';\n\nimport { useContext } from 'react';\n\nimport type { QueryClient } from '@tanstack/query-core';\nimport type { UseQueryOptions } from '@tanstack/react-query';\n\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { QraftContext } from '../QraftContext.js';\nimport type { ServiceOperationQueryKey } from '../service-operation/ServiceOperationKey.js';\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.js';\nimport type { OperationSchema } from './requestFn.js';\nimport { shelfMerge } from './shelfMerge.js';\nimport { useQueryClient } from './useQueryClient.js';\n\n/**\n * Composes the options for useQuery, useInfiniteQuery, useSuspenseQuery, and useSuspenseQueries.\n * @internal\n */\nexport function useComposeUseQueryOptions(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: UseQueryOptionsArgs,\n infinite: boolean\n): never {\n const [parameters, options, queryClient] = args;\n\n const contextValue = useContext(qraftOptions?.context ?? QraftContext);\n if (!contextValue?.requestFn)\n throw new Error(`QraftContext.requestFn not found`);\n\n const queryFn =\n options?.queryFn ??\n // @ts-expect-error - Too complex to type\n function ({ queryKey: [, queryParams], signal, meta, pageParam }) {\n return contextValue.requestFn(schema, {\n // @ts-expect-error - Too complex to type\n parameters: infinite\n ? (shelfMerge(2, queryParams, pageParam) as never)\n : queryParams,\n baseUrl: contextValue.baseUrl,\n signal,\n meta,\n });\n };\n\n const queryKey = Array.isArray(parameters)\n ? (parameters as ServiceOperationQueryKey<OperationSchema, unknown>)\n : infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters);\n\n return [\n { ...options, queryFn, queryKey },\n useQueryClient(qraftOptions, queryClient),\n ] as never;\n}\n\ntype UseQueryOptionsArgs = [\n parameters: unknown,\n options?: UseQueryOptions,\n queryClient?: QueryClient,\n];\n","/**\n * Merges objects with provided depth\n * @param depth\n * @param args\n */\nexport function shelfMerge<T>(depth = 2, ...args: T[]): T {\n return args.reduce((acc, arg) => {\n if (!arg || typeof arg !== 'object') return acc;\n\n Object.entries(arg).forEach(([key, value]) => {\n if (typeof value !== 'object') {\n acc[key as never] = value as never;\n return;\n }\n\n if (Array.isArray(value)) {\n acc[key as never] = value as never;\n return;\n }\n\n if (depth > 1) {\n acc[key as never] = shelfMerge(\n depth - 1,\n acc[key as never],\n value\n ) as never;\n return;\n }\n\n acc[key as never] = value as never;\n });\n\n return acc;\n }, {} as T);\n}\n","'use client';\n\nimport { useContext } from 'react';\n\nimport {\n QueryClient,\n useQueryClient as useQueryClientTanstack,\n} from '@tanstack/react-query';\n\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { QraftContext } from '../QraftContext.js';\n\n/**\n * Get the QueryClient from the QraftContext or the provided QueryClient argument.\n * @param qraftOptions if `queryClient` is not provided, will be taken from context\n * @param queryClient If not provided, will be taken this instance\n */\nexport function useQueryClient(\n qraftOptions: QraftClientOptions | undefined,\n queryClient: QueryClient | undefined\n) {\n const queryClientByContext = useContext(\n qraftOptions?.context ?? QraftContext\n )?.queryClient;\n\n return useQueryClientTanstack(queryClient ?? queryClientByContext);\n}\n","'use client';\n\nimport { useContext } from 'react';\n\nimport type { DefaultError } from '@tanstack/query-core';\nimport {\n useMutation as useMutationBase,\n UseMutationResult,\n} from '@tanstack/react-query';\n\nimport { composeMutationKey } from '../lib/composeMutationKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useQueryClient } from '../lib/useQueryClient.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { QraftContext } from '../QraftContext.js';\nimport type { ServiceOperationMutation } from '../service-operation/ServiceOperation.js';\nimport type { ServiceOperationMutationKey } from '../service-operation/ServiceOperationKey.js';\n\nexport const useMutation: <\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationMutation<\n OperationSchema,\n object | undefined,\n TVariables,\n TData\n >['useMutation']\n >\n) => UseMutationResult<TData, TError, TVariables, TContext> = (\n qraftOptions,\n schema,\n args\n) => {\n const [parameters, options, queryClientByArg] = args;\n\n if (\n parameters &&\n typeof parameters === 'object' &&\n options &&\n 'mutationKey' in options\n )\n throw new Error(\n `'useMutation': parameters and 'options.mutationKey' cannot be used together`\n );\n\n const contextValue = useContext(qraftOptions?.context ?? QraftContext);\n if (!contextValue?.requestFn)\n throw new Error(`QraftContext.request not found`);\n\n const mutationKey =\n options && 'mutationKey' in options\n ? (options.mutationKey as ServiceOperationMutationKey<\n typeof schema,\n unknown\n >)\n : composeMutationKey(schema, parameters);\n\n return useMutationBase(\n {\n ...options,\n mutationKey,\n mutationFn:\n options?.mutationFn ??\n (parameters\n ? function (bodyPayload) {\n return contextValue.requestFn(schema, {\n parameters,\n baseUrl: contextValue.baseUrl,\n body: bodyPayload as never,\n });\n }\n : function (parametersAndBodyPayload) {\n const { body, ...parameters } = parametersAndBodyPayload as {\n body: unknown;\n };\n\n return contextValue.requestFn(schema, {\n parameters,\n baseUrl: contextValue.baseUrl,\n body,\n } as never);\n }),\n },\n useQueryClient(qraftOptions, queryClientByArg)\n ) as never;\n};\n","'use client';\n\nimport type { DefaultError } from '@tanstack/query-core';\nimport {\n useQuery as useQueryTanstack,\n type UseQueryResult,\n} from '@tanstack/react-query';\n\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useComposeUseQueryOptions } from '../lib/useComposeUseQueryOptions.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const useQuery: <TData = unknown, TError = DefaultError>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<OperationSchema, unknown, unknown>['useQuery']\n >\n) => UseQueryResult<TData, TError> = (qraftOptions, schema, args) => {\n return useQueryTanstack(\n // @ts-expect-error - Too complex to type\n ...useComposeUseQueryOptions(qraftOptions, schema, args, false)\n ) as never;\n};\n","'use client';\n\nimport type { DefaultError } from '@tanstack/query-core';\nimport {\n type UseQueryResult,\n useSuspenseQuery as useSuspenseQueryTanstack,\n} from '@tanstack/react-query';\n\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useComposeUseQueryOptions } from '../lib/useComposeUseQueryOptions.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const useSuspenseQuery: <\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<OperationSchema, unknown, unknown>['useSuspenseQuery']\n >\n) => UseQueryResult<TData, TError> = (qraftOptions, schema, args) => {\n return useSuspenseQueryTanstack(\n // @ts-expect-error - Too complex to type\n ...useComposeUseQueryOptions(qraftOptions, schema, args, false)\n ) as never;\n};\n","'use client';\n\nimport type { DefaultError, InfiniteData } from '@tanstack/query-core';\nimport {\n useSuspenseInfiniteQuery as useSuspenseInfiniteQueryTanstack,\n type UseSuspenseInfiniteQueryResult,\n} from '@tanstack/react-query';\n\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useComposeUseQueryOptions } from '../lib/useComposeUseQueryOptions.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const useSuspenseInfiniteQuery: <\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<\n OperationSchema,\n unknown,\n unknown\n >['useSuspenseInfiniteQuery']\n >\n) => UseSuspenseInfiniteQueryResult<TData, TError> = (\n qraftOptions,\n schema,\n args\n) => {\n return useSuspenseInfiniteQueryTanstack(\n // @ts-expect-error - Too complex to type\n ...useComposeUseQueryOptions(qraftOptions, schema, args, true)\n ) as never;\n};\n","'use client';\n\nimport type { DefaultError } from '@tanstack/query-core';\nimport {\n UseMutationResult,\n useMutationState as useMutationStateTanstack,\n} from '@tanstack/react-query';\n\nimport { composeMutationFilters } from '../lib/composeMutationFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useQueryClient } from '../lib/useQueryClient.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationMutation } from '../service-operation/ServiceOperation.js';\n\nexport const useMutationState: <\n TData = unknown,\n TError = DefaultError,\n TVariables = unknown,\n TContext = unknown,\n>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationMutation<\n OperationSchema,\n object | undefined,\n TVariables,\n TData\n >['useMutationState']\n >\n) => UseMutationResult<TData, TError, TVariables, TContext> = (\n qraftOptions,\n schema,\n args\n) => {\n const [options, queryClientByArg] = args;\n\n return useMutationStateTanstack(\n {\n ...options,\n filters: composeMutationFilters(schema, options?.filters),\n } as never,\n useQueryClient(qraftOptions, queryClientByArg)\n ) as never;\n};\n","import { composeMutationKey } from './composeMutationKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Replaces the `parameters` field in the filters with a `mutationKey` field based on the schema.\n * If no filters are provided, a `mutationKey` will be composed schema's base query key.\n * @param schema\n * @param filters\n */\nexport function composeMutationFilters<Filters extends object>(\n schema: OperationSchema,\n filters: Filters | undefined\n) {\n if (!filters) {\n return {\n mutationKey: composeMutationKey(schema, undefined),\n };\n }\n\n if (filters && 'mutationKey' in filters && 'parameters' in filters) {\n throw new Error(\n `'composeMutationFilters': 'mutationKey' and 'parameters' cannot be used together`\n );\n }\n\n if ('mutationKey' in filters) {\n return filters;\n }\n\n if ('parameters' in filters) {\n const { parameters, ...filtersWithoutParameters } = filters;\n\n Object.assign(filtersWithoutParameters, {\n mutationKey: composeMutationKey(schema, parameters),\n });\n\n return filtersWithoutParameters;\n }\n\n return {\n ...filters,\n mutationKey: composeMutationKey(schema, undefined),\n };\n}\n","'use client';\n\nimport type { DefaultError } from '@tanstack/query-core';\nimport {\n UseMutationResult,\n useIsMutating as useIsMutatingStateTanstack,\n} from '@tanstack/react-query';\n\nimport { composeMutationFilters } from '../lib/composeMutationFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useQueryClient } from '../lib/useQueryClient.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationMutation } from '../service-operation/ServiceOperation.js';\n\nexport const useIsMutating: <\n TData = unknown,\n TError = DefaultError,\n TVariables = unknown,\n TContext = unknown,\n>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationMutation<\n OperationSchema,\n object | undefined,\n TVariables,\n TData\n >['useIsMutating']\n >\n) => UseMutationResult<TData, TError, TVariables, TContext> = (\n qraftOptions,\n schema,\n args\n) => {\n const [filters, queryClientByArg] = args;\n\n return useIsMutatingStateTanstack(\n composeMutationFilters(schema, filters) as never,\n useQueryClient(qraftOptions, queryClientByArg)\n ) as never;\n};\n","'use client';\n\nimport { useContext } from 'react';\n\nimport {\n QueriesResults,\n useQueries as useQueriesTanstack,\n} from '@tanstack/react-query';\n\nimport { composeQueryKey } from '../lib/composeQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useQueryClient } from '../lib/useQueryClient.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { QraftContext } from '../QraftContext.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const useQueries: (\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<OperationSchema, unknown, unknown>['useQueries']\n >\n) => QueriesResults<never> = (qraftOptions, schema, args) => {\n const [options, queryClientByArg] = args;\n\n const contextValue = useContext(qraftOptions?.context ?? QraftContext);\n if (!contextValue?.requestFn)\n throw new Error(`QraftContext.requestFn not found`);\n\n return useQueriesTanstack(\n {\n ...options,\n queries: options.queries.map((queryOptions) => {\n const optionsWithQueryKey =\n 'parameters' in queryOptions\n ? (() => {\n const queryOptionsCopy = Object.assign(\n {\n queryKey: composeQueryKey(schema, queryOptions.parameters),\n },\n queryOptions\n );\n // @ts-expect-error - `parameters` is not inferred as a property of `queryOptionsCopy`\n delete queryOptionsCopy.parameters;\n return queryOptionsCopy;\n })()\n : queryOptions;\n\n return {\n ...optionsWithQueryKey,\n queryFn:\n optionsWithQueryKey.queryFn ??\n function ({ queryKey: [, queryParams], signal, meta }) {\n return contextValue.requestFn(schema, {\n parameters: queryParams as never,\n baseUrl: contextValue.baseUrl,\n signal,\n meta,\n });\n },\n };\n }),\n },\n useQueryClient(qraftOptions, queryClientByArg)\n ) as never;\n};\n","'use client';\n\nimport { useContext } from 'react';\n\nimport {\n SuspenseQueriesResults,\n useSuspenseQueries as useSuspenseQueriesTanstack,\n} from '@tanstack/react-query';\n\nimport { composeQueryKey } from '../lib/composeQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useQueryClient } from '../lib/useQueryClient.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { QraftContext } from '../QraftContext.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const useSuspenseQueries: (\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<\n OperationSchema,\n unknown,\n unknown\n >['useSuspenseQueries']\n >\n) => SuspenseQueriesResults<never> = (qraftOptions, schema, args) => {\n const [options, queryClientByArg] = args;\n\n const contextValue = useContext(qraftOptions?.context ?? QraftContext);\n if (!contextValue?.requestFn)\n throw new Error(`QraftContext.requestFn not found`);\n\n return useSuspenseQueriesTanstack(\n {\n ...options,\n queries: options.queries.map((queryOptions) => {\n const optionsWithQueryKey =\n 'parameters' in queryOptions\n ? (() => {\n const queryOptionsCopy = Object.assign(\n {\n queryKey: composeQueryKey(schema, queryOptions.parameters),\n },\n queryOptions\n );\n // @ts-expect-error - `parameters` is not inferred as a property of `queryOptionsCopy`\n delete queryOptionsCopy.parameters;\n return queryOptionsCopy;\n })()\n : queryOptions;\n\n return {\n ...optionsWithQueryKey,\n queryFn:\n optionsWithQueryKey.queryFn ??\n function ({ queryKey: [, queryParams], signal, meta }) {\n return contextValue.requestFn(schema, {\n parameters: queryParams as never,\n baseUrl: contextValue.baseUrl,\n signal,\n meta,\n });\n },\n };\n }),\n },\n useQueryClient(qraftOptions, queryClientByArg)\n ) as never;\n};\n","import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationInvalidateQueriesCallback } from '../service-operation/ServiceOperationInvalidateQueries.js';\n\nexport function invalidateQueries<TData>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationInvalidateQueriesCallback<\n OperationSchema,\n unknown,\n TData\n >['invalidateQueries']\n >\n): Promise<void> {\n return callQueryClientMethodWithQueryFilters(\n 'invalidateQueries',\n schema,\n args as never\n ) as never;\n}\n","import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationCancelQueriesCallback } from '../service-operation/ServiceOperationCancelQueries.js';\n\nexport function cancelQueries<TData>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationCancelQueriesCallback<\n OperationSchema,\n unknown,\n TData\n >['cancelQueries']\n >\n): Promise<void> {\n return callQueryClientMethodWithQueryFilters(\n 'cancelQueries',\n schema,\n args as never\n ) as never;\n}\n","import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationResetQueriesCallback } from '../service-operation/ServiceOperationResetQueries.js';\n\nexport function resetQueries<TData>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationResetQueriesCallback<\n OperationSchema,\n unknown,\n TData\n >['resetQueries']\n >\n): Promise<void> {\n return callQueryClientMethodWithQueryFilters(\n 'resetQueries',\n schema,\n args as never\n ) as never;\n}\n","import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationRemoveQueriesCallback } from '../service-operation/ServiceOperationRemoveQueries.js';\n\nexport function removeQueries<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationRemoveQueriesCallback<\n OperationSchema,\n unknown,\n TData\n >['removeQueries']\n >\n): Promise<void> {\n return callQueryClientMethodWithQueryFilters(\n 'removeQueries',\n schema,\n args as never\n ) as never;\n}\n","import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationRefetchQueriesCallback } from '../service-operation/ServiceOperationRefetchQueries.js';\n\nexport function refetchQueries<TData>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationRefetchQueriesCallback<\n OperationSchema,\n unknown,\n TData\n >['refetchQueries']\n >\n): Promise<void> {\n return callQueryClientMethodWithQueryFilters(\n 'refetchQueries',\n schema,\n args as never\n ) as never;\n}\n","import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationIsFetchingQueriesCallback } from '../service-operation/ServiceOperationIsFetchingQueries.js';\n\nexport function isFetching<TData>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationIsFetchingQueriesCallback<\n OperationSchema,\n unknown,\n TData\n >['isFetching']\n >\n): Promise<void> {\n return callQueryClientMethodWithQueryFilters(\n 'isFetching',\n schema,\n args as never\n ) as never;\n}\n","import type { QueryClient } from '@tanstack/query-core';\n\nimport { composeMutationFilters } from './composeMutationFilters.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Calls a query client method with mutation filters and options,\n * and automatically composes the `MutationKey` based on the schema and parameters.\n */\nexport function callQueryClientMethodWithMutationFilters<\n QFMethod extends QueryFilterMethods,\n>(\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n args: [...Parameters<(typeof QueryClient.prototype)[QFMethod]>, QueryClient]\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const filters = args.length > 1 ? args[0] : undefined;\n const queryClient = args[args.length - 1] as QueryClient | undefined;\n\n if (!queryClient) throw new Error('queryClient is required');\n if (!queryClient[queryFilterMethod])\n throw new Error(\n `queryClient is invalid, ${queryFilterMethod} method does not exist`\n );\n\n // @ts-expect-error - Too complex to type\n return queryClient[queryFilterMethod](\n composeMutationFilters(schema, filters as never),\n // @ts-expect-error - Argument types are too complex\n ...args.slice(1, -1)\n );\n}\n\ntype QueryFiltersMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n\ntype QueryFilterMethods = QueryFiltersMethod<'isMutating'>;\n","import { callQueryClientMethodWithMutationFilters } from '../lib/callQueryClientMethodWithMutationFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationIsMutatingQueriesCallback } from '../service-operation/ServiceOperationIsMutatingQueries.js';\n\nexport function isMutating<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationIsMutatingQueriesCallback<\n OperationSchema,\n unknown,\n TData\n >['isMutating']\n >\n): Promise<void> {\n return callQueryClientMethodWithMutationFilters(\n 'isMutating',\n schema,\n args as never\n ) as never;\n}\n","'use client';\n\nimport { useIsFetching as useIsFetchingTanstack } from '@tanstack/react-query';\n\nimport { composeQueryFilters } from '../lib/composeQueryFilters.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport { useQueryClient } from '../lib/useQueryClient.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const useIsFetching: <TVariables = unknown>(\n qraftOptions: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<\n OperationSchema,\n object | undefined,\n TVariables,\n unknown\n >['useIsFetching']\n >\n) => number = (qraftOptions, schema, args) => {\n const [filters, queryClientByArg] = args;\n\n return useIsFetchingTanstack(\n composeQueryFilters(schema, filters as never) as never,\n useQueryClient(qraftOptions, queryClientByArg)\n ) as never;\n};\n","import type { QueryClient } from '@tanstack/query-core';\n\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.js';\nimport type { OperationSchema, RequestFn } from './requestFn.js';\nimport { shelfMerge } from './shelfMerge.js';\n\n/**\n * Calls a query client fetch method with parameters and options,\n * and automatically composes the `QueryKey` based on the schema and parameters.\n */\nexport function callQueryClientMethodWithQueryKey<\n QFMethod extends QueryKeyMethods,\n>(\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n infinite: boolean,\n args: QueryClientMethodArgs<QFMethod>\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const [{ requestFn, baseUrl, parameters, ...options }, queryClient] = args;\n\n if (!queryClient) throw new Error('queryClient is required');\n if (!queryClient[queryFilterMethod])\n throw new Error(\n `queryClient is invalid, ${queryFilterMethod} method does not exist`\n );\n\n if (options.queryKey && parameters) {\n throw new Error(\n 'callQueryClientMethodWithQueryKey: options.queryKey and options.parameters are mutually exclusive'\n );\n }\n\n if (options.queryFn && requestFn) {\n throw new Error(\n 'callQueryClientMethodWithQueryKey: options.queryFn and requestFn are mutually exclusive'\n );\n }\n\n const queryFn =\n options.queryFn ??\n (requestFn\n ? // @ts-expect-error - Not inferring the correct type for `queryFn`\n function ({ queryKey: [, queryParams], signal, meta, pageParam }) {\n return requestFn(schema, {\n parameters: infinite\n ? (shelfMerge(2, queryParams, pageParam) as never)\n : queryParams,\n baseUrl,\n signal,\n meta,\n });\n }\n : undefined);\n\n if (parameters) {\n // @ts-expect-error - Too complex union to type\n return queryClient[queryFilterMethod]({\n ...options,\n // Event if queryFn is undefined, it will override the default queryFn from `setQueryDefaults(...)`\n ...(queryFn ? { queryFn } : {}),\n queryKey: infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters),\n });\n }\n\n // @ts-expect-error - Too complex union to type\n return queryClient[queryFilterMethod]({ ...options, queryFn });\n}\n\ntype QueryClientMethodArgs<QMethod extends keyof QueryClientPrototype> = [\n options: Parameters<QueryClientPrototype[QMethod]>[0] & {\n parameters?: unknown;\n baseUrl?: string;\n requestFn?: RequestFn<unknown>;\n },\n queryClient: QueryClient,\n];\n\ntype QueryKeyMethods =\n | QueryKeyMethod<'fetchQuery'>\n | QueryKeyMethod<'prefetchQuery'>\n | QueryKeyMethod<'fetchInfiniteQuery'>\n | QueryKeyMethod<'prefetchInfiniteQuery'>;\n\ntype QueryClientPrototype = typeof QueryClient.prototype;\n\ntype QueryKeyMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n","import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientFetchMethod.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const fetchQuery: <\n TSchema extends { url: string; method: 'get' | 'head' | 'options' },\n TData,\n TParams,\n>(\n _: QraftClientOptions | undefined,\n schema: TSchema,\n args: Parameters<ServiceOperationQuery<TSchema, TData, TParams>['fetchQuery']>\n) => Promise<TData> = (_, schema, args) => {\n return callQueryClientMethodWithQueryKey(\n 'fetchQuery',\n schema,\n false,\n args as never\n ) as never;\n};\n","import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientFetchMethod.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const prefetchQuery: <\n TSchema extends { url: string; method: 'get' | 'head' | 'options' },\n TData,\n TParams,\n>(\n _: QraftClientOptions | undefined,\n schema: TSchema,\n args: Parameters<\n ServiceOperationQuery<TSchema, TData, TParams>['prefetchQuery']\n >\n) => Promise<TData> = (_, schema, args) => {\n return callQueryClientMethodWithQueryKey(\n 'prefetchQuery',\n schema,\n false,\n args as never\n ) as never;\n};\n","import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientFetchMethod.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const fetchInfiniteQuery: <\n TSchema extends { url: string; method: 'get' | 'head' | 'options' },\n TData,\n TParams,\n>(\n _: QraftClientOptions | undefined,\n schema: TSchema,\n args: Parameters<\n ServiceOperationQuery<TSchema, TData, TParams>['fetchInfiniteQuery']\n >\n) => Promise<TData> = (_, schema, args) => {\n return callQueryClientMethodWithQueryKey(\n 'fetchInfiniteQuery',\n schema,\n true,\n args as never\n ) as never;\n};\n","import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientFetchMethod.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport const prefetchInfiniteQuery: <\n TSchema extends { url: string; method: 'get' | 'head' | 'options' },\n TData,\n TParams,\n>(\n _: QraftClientOptions | undefined,\n schema: TSchema,\n args: Parameters<\n ServiceOperationQuery<TSchema, TData, TParams>['prefetchInfiniteQuery']\n >\n) => Promise<TData> = (_, schema, args) => {\n return callQueryClientMethodWithQueryKey(\n 'prefetchInfiniteQuery',\n schema,\n true,\n args as never\n ) as never;\n};\n","import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport function getQueryState<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<OperationSchema, unknown, TData>['getQueryState']\n >\n): TData | undefined {\n return callQueryClientMethodWithQueryKey(\n 'getQueryState',\n schema,\n false,\n args as never\n ) as never;\n}\n","import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\n\nexport function getInfiniteQueryState<TData>(\n _: QraftClientOptions | undefined,\n schema: OperationSchema,\n args: Parameters<\n ServiceOperationQuery<\n OperationSchema,\n unknown,\n TData\n >['getInfiniteQueryState']\n >\n): TData | undefined {\n return callQueryClientMethodWithQueryKey(\n 'getQueryState',\n schema,\n true,\n args as never\n ) as never;\n}\n","import type { OperationSchema } from '../lib/requestFn.js';\nimport type { QraftClientOptions } from '../qraftAPIClient.js';\nimport { ServiceOperationMutationFn } from '../service-operation/ServiceOperationMutationFn.js';\nimport { ServiceOperationQueryFn } from '../service-operation/ServiceOperationQueryFn.js';\n\n/**\n * Called when <service>.<operation>(...) is invoked.\n */\nexport const operationInvokeFn: <\n TSchema extends OperationSchema,\n TBody,\n TData,\n TParams,\n>(\n qraftOptions: QraftClientOptions | undefined,\n schema: TSchema,\n args:\n | Parameters<ServiceOperationQueryFn<TSchema, TData, TParams>>\n | Parameters<ServiceOperationMutationFn<TSchema, TBody, TData, TParams>>\n) => Promise<TData> = (_, schema, args) => {\n const queryOperationMethods = ['get', 'head', 'options'] as const; // todo::make it shared\n\n const isQueryOperationType = queryOperationMethods.includes(\n schema.method as (typeof queryOperationMethods)[number]\n );\n\n const [options, client] = args;\n\n const invokeSchema =\n isQueryOperationType && 'queryKey' in options\n ? options.queryKey![0]\n : schema;\n\n const invokeParameters =\n isQueryOperationType && 'queryKey' in options\n ? options.queryKey![1]\n : 'parameters' in options\n ? options.parameters\n : undefined;\n\n return client(invokeSchema, {\n ...options,\n parameters: invokeParameters,\n } as never);\n};\n","'use client';\n\nimport { createElement, Fragment, ReactNode, useEffect, useMemo } from 'react';\n\nimport {\n QueryClient,\n type QueryFunctionContext,\n type QueryKey,\n useQueries,\n} from '@tanstack/react-query';\n\nimport { jwtDecode } from './lib/jwt-decode/index.js';\nimport type {\n OperationSchema,\n RequestFnInfo,\n RequestFnOptions,\n} from './lib/requestFn.js';\n\ninterface QraftSecureRequestFnBaseProps {\n requestFn<T>(\n schema: OperationSchema,\n requestInfo: RequestFnInfo,\n options?: RequestFnOptions\n ): Promise<T>;\n securitySchemes: SecuritySchemeHandlers<string>;\n}\n\ntype RequestFn = QraftSecureRequestFnBaseProps['requestFn'];\n\nexport interface QraftSecureRequestFnProps\n extends QraftSecureRequestFnBaseProps {\n children(\n secureRequestFn: QraftSecureRequestFnBaseProps['requestFn']\n ): ReactNode;\n queryClient?: QueryClient;\n}\n\nexport function QraftSecureRequestFn({\n children,\n requestFn,\n securitySchemes,\n queryClient: inQueryClient,\n}: QraftSecureRequestFnProps) {\n const queryClient = useMemo(\n () =>\n inQueryClient ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 300_000,\n gcTime: 300_000,\n refetchOnWindowFocus: false,\n refetchOnMount: false,\n refetchOnReconnect: false,\n },\n },\n }),\n [inQueryClient]\n );\n\n useEffect(() => {\n queryClient.mount();\n return () => {\n return void queryClient.unmount();\n };\n }, [queryClient]);\n\n const secureRequestFn = useSecuritySchemeAuth({\n securitySchemes,\n requestFn,\n queryClient,\n });\n\n return createElement(Fragment, {\n children: children(secureRequestFn),\n });\n}\n\nexport const useSecuritySchemeAuth = ({\n securitySchemes,\n requestFn,\n queryClient,\n}: QraftSecureRequestFnBaseProps & {\n queryClient: QueryClient;\n}): RequestFn => {\n useQueries(\n {\n queries: Object.entries(securitySchemes).map(([securitySchemeName]) => {\n const queryKey: QueryKey = [securitySchemeName];\n return {\n enabled: Boolean(queryClient.getQueryData(queryKey)),\n queryKey: queryKey as never,\n queryFn: ({\n signal,\n }: QueryFunctionContext<[keyof typeof securitySchemes]>) => {\n const securitySchemeHandler = securitySchemes[securitySchemeName];\n return securitySchemeHandler({ signal, isRefreshing: true });\n },\n };\n }),\n },\n queryClient\n );\n\n return useMemo(\n () => createSecureRequestFn(securitySchemes, requestFn, queryClient),\n [securitySchemes, requestFn, queryClient]\n );\n};\n\n/**\n * Create a secure `requestFn` that manages security schemes.\n * It will automatically fetch and refresh tokens when needed\n * using QueryClient and the provided security schemes.\n *\n * @param securitySchemes OpenAPI security schemes.\n * @param requestFn Qraft `requestFn`\n * @param queryClient QueryClient instance.\n */\nexport function createSecureRequestFn(\n securitySchemes: SecuritySchemeHandlers<string>,\n requestFn: RequestFn,\n queryClient: QueryClient\n): RequestFn {\n return async function secureRequestFn(\n schema: OperationSchema,\n requestInfo: RequestFnInfo,\n options?: RequestFnOptions\n ) {\n const availableSecuritySchemes = Object.keys(securitySchemes) as Array<\n keyof typeof securitySchemes\n >;\n const securitySchemeName = schema.security?.find(\n (security): security is keyof typeof securitySchemes =>\n availableSecuritySchemes.includes(security)\n );\n\n if (!securitySchemeName) {\n return requestFn(schema, requestInfo, options);\n }\n\n const securitySchemeHandler = securitySchemes[securitySchemeName];\n\n return requestFn(\n schema,\n await createSecureRequestInfo(\n securitySchemeHandler,\n [securitySchemeName],\n requestInfo,\n queryClient\n ),\n options\n );\n };\n}\n\n/**\n * Calculate the interval at which a token should be refreshed.\n */\nfunction getJwtTokenRefreshInterval(token: string) {\n const parsedToken = jwtDecode(token);\n if (!parsedToken.iat || !parsedToken.exp) {\n throw new Error(\"JWT token must contain both 'iat' and 'exp' fields.\");\n }\n\n return (parsedToken.exp - parsedToken.iat) * 1000;\n}\n\n/**\n * Refresh the token if it is about to expire\n * @returns The string to be used as the `Authorization` header or the object to be used in the request.\n */\nasync function createSecureRequestInfo(\n handler: SecuritySchemeHandler,\n queryKey: QueryKey,\n requestInfo: RequestFnInfo,\n queryClient: QueryClient\n): Promise<RequestFnInfo> {\n const prevSecurityResult = queryClient.getQueryData<SecurityScheme>(queryKey);\n\n const securityResult = await queryClient.fetchQuery({\n queryKey,\n queryFn: ({ signal }) =>\n handler({\n signal,\n isRefreshing: Boolean(prevSecurityResult),\n }),\n });\n\n if (!shallowEqualObjects(securityResult, prevSecurityResult)) {\n const securityRefreshInterval = getSecurityRefreshInterval(securityResult);\n\n if (securityRefreshInterval !== undefined && securityRefreshInterval > 0) {\n // remove the already fetched query, before setting new defaults\n queryClient.removeQueries({ queryKey, exact: true });\n\n // set query new defaults (staleTime and gcTime)\n setSecurityQueryDefaults(queryClient, queryKey, securityRefreshInterval);\n\n // Set query data with the new token, since the old one was removed.\n // New query data will follow the new defaults staleTime and gcTime.\n queryClient.setQueryData(queryKey, securityResult);\n }\n }\n\n const securityParameters = createSecureRequestParameters(securityResult);\n\n if (!securityParameters) return requestInfo;\n\n return {\n ...requestInfo,\n parameters: {\n ...requestInfo.parameters,\n [securityParameters.in]: {\n [securityParameters.name]: securityParameters.value,\n ...requestInfo.parameters?.[securityParameters.in],\n },\n },\n };\n}\n\nfunction setSecurityQueryDefaults(\n queryClient: QueryClient,\n queryKey: QueryKey,\n refreshInterval: number\n) {\n // set staleTime and gcTime based on token lifetime\n queryClient.setQueryDefaults(queryKey, {\n // stale the token 90% before it expires\n staleTime: isFinite(refreshInterval)\n ? refreshInterval * 0.9\n : refreshInterval,\n // garbage collect the token after it expires\n gcTime: isFinite(refreshInterval) ? refreshInterval : refreshInterval,\n // refetch the token 80% before it expires\n refetchInterval: isFinite(refreshInterval)\n ? refreshInterval * 0.8\n : refreshInterval,\n // always refetch the token, even in the background\n refetchIntervalInBackground: true,\n });\n}\n\nfunction createSecureRequestParameters(securityResult: SecurityScheme) {\n if (typeof securityResult === 'string' || 'token' in securityResult) {\n return {\n in: 'header',\n name: 'Authorization',\n value: `Bearer ${typeof securityResult === 'string' ? securityResult : securityResult.token}`,\n } as const;\n }\n\n if ('credentials' in securityResult) {\n return {\n in: 'header',\n name: 'Authorization',\n value: `Basic ${securityResult.credentials}`,\n } as const;\n }\n\n if ('in' in securityResult && securityResult.in !== 'cookie') {\n return securityResult;\n }\n\n throw new Error(\n 'Security scheme must be a string, an object with a token property, an object with a credentials property, or an object with an in property that is not equal to \"cookie\".'\n );\n}\n\nfunction getSecurityRefreshInterval(securityResult: SecurityScheme) {\n if (typeof securityResult === 'string') {\n return getJwtTokenRefreshInterval(securityResult);\n }\n\n if ('refreshInterval' in securityResult) {\n return securityResult.refreshInterval;\n }\n}\n\n/**\n * @internal\n */\nexport function shallowEqualObjects(\n newObj: Record<string, any> | string,\n prevObj: Record<string, any> | string | undefined\n) {\n if (typeof newObj !== typeof prevObj) return false;\n if (typeof newObj === 'string') return newObj === prevObj;\n if (\n typeof newObj !== 'object' ||\n newObj === null ||\n typeof prevObj !== 'object' ||\n prevObj === null ||\n prevObj === undefined\n )\n return false;\n if (Object.keys(newObj).length !== Object.keys(prevObj).length) return false;\n\n for (const key in newObj) {\n if (!Object.prototype.hasOwnProperty.call(newObj, key)) return false;\n if (newObj[key] !== prevObj[key]) return false;\n }\n return true;\n}\n\ntype SecurityScheme =\n | SecuritySchemeBearer\n | SecuritySchemeBasic\n | SecuritySchemeAPIKey\n | SecuritySchemeCookie;\n\nexport type SecuritySchemeBearer =\n | string /** JWT Bearer token. **/\n | {\n /** Refresh interval in milliseconds. */\n refreshInterval: number;\n /** Token to be used for authentication. */\n token: string;\n };\n\nexport interface SecuritySchemeBasic {\n /** Credentials to be used for authentication. */\n credentials: string;\n\n /** Refresh interval in milliseconds. */\n refreshInterval: number;\n}\n\nexport type SecuritySchemeAPIKey = {\n /** Where the secret should be placed. */\n in: 'header' | 'query';\n /** Name of the secret key. */\n name: string;\n /** Secret to be used for authentication. */\n value: string;\n /** Refresh interval in milliseconds. */\n refreshInterval?: number;\n};\n\nexport type SecuritySchemeCookie = {\n /** Where the secret should be placed. */\n in: 'cookie';\n /** Refresh interval in milliseconds. */\n refreshInterval?: number;\n};\n\n/**\n * Type definition for a handler function that manages security schemes.\n * This function is invoked when a token needs to be fetched or refreshed.\n *\n * @param props - The properties for the handler function.\n * @param props.isRefreshing - A boolean indicating the state of the token.\n * It's `false` on the initial \"fetch token\" request, and `true` if the token is stale or updating using `refreshInterval`.\n * @param props.signal - An AbortSignal that can be used to abort the request.\n *\n * @returns A SecurityScheme, which contains the necessary data for authentication.\n */\ntype SecuritySchemeHandler = (props: {\n isRefreshing: boolean;\n signal: AbortSignal;\n}) => SecurityScheme | Promise<SecurityScheme>;\n\nexport type SecuritySchemeHandlers<SecuritySchemeName extends string> = {\n [key in SecuritySchemeName]: SecuritySchemeHandler;\n};\n","export interface JwtDecodeOptions {\n header?: boolean;\n}\n\nexport interface JwtHeader {\n typ?: string;\n alg?: string;\n kid?: string;\n}\n\nexport interface JwtPayload {\n iss?: string;\n sub?: string;\n aud?: string[] | string;\n exp?: number;\n nbf?: number;\n iat?: number;\n jti?: string;\n}\n\nexport class InvalidTokenError extends Error {}\n\nInvalidTokenError.prototype.name = 'InvalidTokenError';\n\n/**\n * Decode a base64 string to a UTF-8 string.\n * Could be used in Node.js or in the browser.\n */\nexport function b64DecodeUnicode(data: string): string {\n if (typeof atob === 'function')\n return decodeURIComponent(Array.from(atob(data), byteToPercent).join(''));\n\n return Buffer.from(data, 'base64').toString('utf-8');\n}\n\nfunction base64UrlDecode(str: string) {\n let output = str.replace(/-/g, '+').replace(/_/g, '/');\n switch (output.length % 4) {\n case 0:\n break;\n case 2:\n output += '==';\n break;\n case 3:\n output += '=';\n break;\n default:\n throw new Error('base64 string is not of the correct length');\n }\n\n try {\n return b64DecodeUnicode(output);\n } catch (err) {\n return atob(output);\n }\n}\n\nexport function jwtDecode<T = JwtHeader>(\n token: string,\n options: JwtDecodeOptions & { header: true }\n): T;\nexport function jwtDecode<T = JwtPayload>(\n token: string,\n options?: JwtDecodeOptions\n): T;\nexport function jwtDecode<T = JwtHeader | JwtPayload>(\n token: string,\n options?: JwtDecodeOptions\n): T {\n if (typeof token !== 'string') {\n throw new InvalidTokenError('Invalid token specified: must be a string');\n }\n\n options ||= {};\n\n const pos = options.header === true ? 0 : 1;\n const part = token.split('.')[pos];\n\n if (typeof part !== 'string') {\n throw new InvalidTokenError(\n `Invalid token specified: missing part #${pos + 1}`\n );\n }\n\n let decoded: string;\n try {\n decoded = base64UrlDecode(part);\n } catch (e) {\n throw new InvalidTokenError(\n `Invalid token specified: invalid base64 for part #${pos + 1} (${(e as Error).message})`\n );\n }\n\n try {\n return JSON.parse(decoded) as T;\n } catch (e) {\n throw new InvalidTokenError(\n `Invalid token specified: invalid json for part #${pos + 1} (${(e as Error).message})`\n );\n }\n}\n\nfunction byteToPercent(b: string) {\n return `%${`00${b.charCodeAt(0).toString(16)}`.slice(-2)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,SAAS,qBACd,aACA,eACA,MACS;A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,YAClB,WAAW,QACX,OAAO,YAAY,YACnB,YAAY,QACZ,YAAY;AAEZ,WAAO;AACT,MAAI,OAAO,KAAK,MAAM,EAAE,WAAW,OAAO,KAAK,OAAO,EAAE,OAAQ,QAAO;AAEvE,aAAW,OAAO,QAAQ;AACxB,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,QAAQ,GAAG,EAAG,QAAO;AAC/D,QAAI,OAAO,GAAG,MAAM,QAAQ,GAAG,EAAG,QAAO;AAAA,EAC3C;AACA,SAAO;AACT;","names":["process","import_react_query","import_react","import_react","useQueryClientTanstack","queryFn","useInfiniteQueryBase","import_react","import_react_query","useMutationBase","parameters","import_react_query","useQueryTanstack","import_react_query","useSuspenseQueryTanstack","import_react_query","useSuspenseInfiniteQueryTanstack","import_react_query","useMutationStateTanstack","import_react_query","useIsMutatingStateTanstack","import_react","import_react_query","useQueriesTanstack","import_react","import_react_query","useSuspenseQueriesTanstack","import_react_query","useIsFetchingTanstack","callQueryClientMethodWithQueryKey","requestFn","queryFn","callQueryClientMethodWithQueryKey","callQueryClientMethodWithQueryKey","callQueryClientMethodWithQueryKey","callQueryClientMethodWithQueryKey","import_react","import_react_query","requestFn"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composeInfiniteQueryKey = require('./composeInfiniteQueryKey.cjs');
|
|
4
|
+
var composeQueryKey = require('./composeQueryKey.cjs');
|
|
5
|
+
var shelfMerge = require('./shelfMerge.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Calls a query client fetch method with parameters and options,
|
|
9
|
+
* and automatically composes the `QueryKey` based on the schema and parameters.
|
|
10
|
+
*/ function callQueryClientMethodWithQueryKey(queryFilterMethod, schema, infinite, args) {
|
|
11
|
+
const [{ requestFn, baseUrl, parameters, ...options }, queryClient] = args;
|
|
12
|
+
if (!queryClient) throw new Error('queryClient is required');
|
|
13
|
+
if (!queryClient[queryFilterMethod]) throw new Error(`queryClient is invalid, ${queryFilterMethod} method does not exist`);
|
|
14
|
+
if (options.queryKey && parameters) {
|
|
15
|
+
throw new Error('callQueryClientMethodWithQueryKey: options.queryKey and options.parameters are mutually exclusive');
|
|
16
|
+
}
|
|
17
|
+
if (options.queryFn && requestFn) {
|
|
18
|
+
throw new Error('callQueryClientMethodWithQueryKey: options.queryFn and requestFn are mutually exclusive');
|
|
19
|
+
}
|
|
20
|
+
const queryFn = options.queryFn ?? (requestFn ? function({ queryKey: [, queryParams], signal, meta, pageParam }) {
|
|
21
|
+
return requestFn(schema, {
|
|
22
|
+
parameters: infinite ? shelfMerge.shelfMerge(2, queryParams, pageParam) : queryParams,
|
|
23
|
+
baseUrl,
|
|
24
|
+
signal,
|
|
25
|
+
meta
|
|
26
|
+
});
|
|
27
|
+
} : undefined);
|
|
28
|
+
if (parameters) {
|
|
29
|
+
// @ts-expect-error - Too complex union to type
|
|
30
|
+
return queryClient[queryFilterMethod]({
|
|
31
|
+
...options,
|
|
32
|
+
// Event if queryFn is undefined, it will override the default queryFn from `setQueryDefaults(...)`
|
|
33
|
+
...queryFn ? {
|
|
34
|
+
queryFn
|
|
35
|
+
} : {},
|
|
36
|
+
queryKey: infinite ? composeInfiniteQueryKey.composeInfiniteQueryKey(schema, parameters) : composeQueryKey.composeQueryKey(schema, parameters)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// @ts-expect-error - Too complex union to type
|
|
40
|
+
return queryClient[queryFilterMethod]({
|
|
41
|
+
...options,
|
|
42
|
+
queryFn
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.callQueryClientMethodWithQueryKey = callQueryClientMethodWithQueryKey;
|
|
47
|
+
//# sourceMappingURL=callQueryClientFetchMethod.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callQueryClientFetchMethod.cjs","sources":["../../../src/lib/callQueryClientFetchMethod.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\n\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.js';\nimport type { OperationSchema, RequestFn } from './requestFn.js';\nimport { shelfMerge } from './shelfMerge.js';\n\n/**\n * Calls a query client fetch method with parameters and options,\n * and automatically composes the `QueryKey` based on the schema and parameters.\n */\nexport function callQueryClientMethodWithQueryKey<\n QFMethod extends QueryKeyMethods,\n>(\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n infinite: boolean,\n args: QueryClientMethodArgs<QFMethod>\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const [{ requestFn, baseUrl, parameters, ...options }, queryClient] = args;\n\n if (!queryClient) throw new Error('queryClient is required');\n if (!queryClient[queryFilterMethod])\n throw new Error(\n `queryClient is invalid, ${queryFilterMethod} method does not exist`\n );\n\n if (options.queryKey && parameters) {\n throw new Error(\n 'callQueryClientMethodWithQueryKey: options.queryKey and options.parameters are mutually exclusive'\n );\n }\n\n if (options.queryFn && requestFn) {\n throw new Error(\n 'callQueryClientMethodWithQueryKey: options.queryFn and requestFn are mutually exclusive'\n );\n }\n\n const queryFn =\n options.queryFn ??\n (requestFn\n ? // @ts-expect-error - Not inferring the correct type for `queryFn`\n function ({ queryKey: [, queryParams], signal, meta, pageParam }) {\n return requestFn(schema, {\n parameters: infinite\n ? (shelfMerge(2, queryParams, pageParam) as never)\n : queryParams,\n baseUrl,\n signal,\n meta,\n });\n }\n : undefined);\n\n if (parameters) {\n // @ts-expect-error - Too complex union to type\n return queryClient[queryFilterMethod]({\n ...options,\n // Event if queryFn is undefined, it will override the default queryFn from `setQueryDefaults(...)`\n ...(queryFn ? { queryFn } : {}),\n queryKey: infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters),\n });\n }\n\n // @ts-expect-error - Too complex union to type\n return queryClient[queryFilterMethod]({ ...options, queryFn });\n}\n\ntype QueryClientMethodArgs<QMethod extends keyof QueryClientPrototype> = [\n options: Parameters<QueryClientPrototype[QMethod]>[0] & {\n parameters?: unknown;\n baseUrl?: string;\n requestFn?: RequestFn<unknown>;\n },\n queryClient: QueryClient,\n];\n\ntype QueryKeyMethods =\n | QueryKeyMethod<'fetchQuery'>\n | QueryKeyMethod<'prefetchQuery'>\n | QueryKeyMethod<'fetchInfiniteQuery'>\n | QueryKeyMethod<'prefetchInfiniteQuery'>;\n\ntype QueryClientPrototype = typeof QueryClient.prototype;\n\ntype QueryKeyMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n"],"names":["callQueryClientMethodWithQueryKey","queryFilterMethod","schema","infinite","args","requestFn","baseUrl","parameters","options","queryClient","Error","queryKey","queryFn","queryParams","signal","meta","pageParam","shelfMerge","undefined","composeInfiniteQueryKey","composeQueryKey"],"mappings":";;;;;;AAOA;;;IAIO,SAASA,iCAGdC,CAAAA,iBAA2B,EAC3BC,MAAuB,EACvBC,QAAiB,EACjBC,IAAqC,EAAA;AAErC,IAAA,MAAM,CAAC,EAAEC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAE,GAAGC,OAAAA,EAAS,EAAEC,WAAAA,CAAY,GAAGL,IAAAA,CAAAA;AAEtE,IAAA,IAAI,CAACK,WAAAA,EAAa,MAAM,IAAIC,KAAM,CAAA,yBAAA,CAAA,CAAA;AAClC,IAAA,IAAI,CAACD,WAAW,CAACR,iBAAAA,CAAkB,EACjC,MAAM,IAAIS,KAAAA,CACR,CAAC,wBAAwB,EAAET,iBAAAA,CAAkB,sBAAsB,CAAC,CAAA,CAAA;IAGxE,IAAIO,OAAAA,CAAQG,QAAQ,IAAIJ,UAAY,EAAA;AAClC,QAAA,MAAM,IAAIG,KACR,CAAA,mGAAA,CAAA,CAAA;AAEJ,KAAA;IAEA,IAAIF,OAAAA,CAAQI,OAAO,IAAIP,SAAW,EAAA;AAChC,QAAA,MAAM,IAAIK,KACR,CAAA,yFAAA,CAAA,CAAA;AAEJ,KAAA;AAEA,IAAA,MAAME,UACJJ,OAAQI,CAAAA,OAAO,KACdP,YAEG,SAAU,EAAEM,QAAU,EAAA,GAAGE,YAAY,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAE,EAAA;AAC9D,QAAA,OAAOX,UAAUH,MAAQ,EAAA;AACvBK,YAAAA,UAAAA,EAAYJ,QACPc,GAAAA,qBAAAA,CAAW,CAAGJ,EAAAA,WAAAA,EAAaG,SAC5BH,CAAAA,GAAAA,WAAAA;AACJP,YAAAA,OAAAA;AACAQ,YAAAA,MAAAA;AACAC,YAAAA,IAAAA;AACF,SAAA,CAAA,CAAA;AACF,KAAA,GACAG,SAAQ,CAAA,CAAA;AAEd,IAAA,IAAIX,UAAY,EAAA;;QAEd,OAAOE,WAAW,CAACR,iBAAAA,CAAkB,CAAC;AACpC,YAAA,GAAGO,OAAO;;AAEV,YAAA,GAAII,OAAU,GAAA;AAAEA,gBAAAA,OAAAA;AAAQ,aAAA,GAAI,EAAE;AAC9BD,YAAAA,QAAAA,EAAUR,QACNgB,GAAAA,+CAAAA,CAAwBjB,MAAQK,EAAAA,UAAAA,CAAAA,GAChCa,gCAAgBlB,MAAQK,EAAAA,UAAAA,CAAAA;AAC9B,SAAA,CAAA,CAAA;AACF,KAAA;;IAGA,OAAOE,WAAW,CAACR,iBAAAA,CAAkB,CAAC;AAAE,QAAA,GAAGO,OAAO;AAAEI,QAAAA,OAAAA;AAAQ,KAAA,CAAA,CAAA;AAC9D;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composeMutationFilters = require('./composeMutationFilters.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calls a query client method with mutation filters and options,
|
|
7
|
+
* and automatically composes the `MutationKey` based on the schema and parameters.
|
|
8
|
+
*/ function callQueryClientMethodWithMutationFilters(queryFilterMethod, schema, args) {
|
|
9
|
+
const filters = args.length > 1 ? args[0] : undefined;
|
|
10
|
+
const queryClient = args[args.length - 1];
|
|
11
|
+
if (!queryClient) throw new Error('queryClient is required');
|
|
12
|
+
if (!queryClient[queryFilterMethod]) throw new Error(`queryClient is invalid, ${queryFilterMethod} method does not exist`);
|
|
13
|
+
// @ts-expect-error - Too complex to type
|
|
14
|
+
return queryClient[queryFilterMethod](composeMutationFilters.composeMutationFilters(schema, filters), // @ts-expect-error - Argument types are too complex
|
|
15
|
+
...args.slice(1, -1));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.callQueryClientMethodWithMutationFilters = callQueryClientMethodWithMutationFilters;
|
|
19
|
+
//# sourceMappingURL=callQueryClientMethodWithMutationFilters.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callQueryClientMethodWithMutationFilters.cjs","sources":["../../../src/lib/callQueryClientMethodWithMutationFilters.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\n\nimport { composeMutationFilters } from './composeMutationFilters.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Calls a query client method with mutation filters and options,\n * and automatically composes the `MutationKey` based on the schema and parameters.\n */\nexport function callQueryClientMethodWithMutationFilters<\n QFMethod extends QueryFilterMethods,\n>(\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n args: [...Parameters<(typeof QueryClient.prototype)[QFMethod]>, QueryClient]\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const filters = args.length > 1 ? args[0] : undefined;\n const queryClient = args[args.length - 1] as QueryClient | undefined;\n\n if (!queryClient) throw new Error('queryClient is required');\n if (!queryClient[queryFilterMethod])\n throw new Error(\n `queryClient is invalid, ${queryFilterMethod} method does not exist`\n );\n\n // @ts-expect-error - Too complex to type\n return queryClient[queryFilterMethod](\n composeMutationFilters(schema, filters as never),\n // @ts-expect-error - Argument types are too complex\n ...args.slice(1, -1)\n );\n}\n\ntype QueryFiltersMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n\ntype QueryFilterMethods = QueryFiltersMethod<'isMutating'>;\n"],"names":["callQueryClientMethodWithMutationFilters","queryFilterMethod","schema","args","filters","length","undefined","queryClient","Error","composeMutationFilters","slice"],"mappings":";;;;AAKA;;;AAGC,IACM,SAASA,wCAAAA,CAGdC,iBAA2B,EAC3BC,MAAuB,EACvBC,IAA4E,EAAA;IAE5E,MAAMC,OAAAA,GAAUD,KAAKE,MAAM,GAAG,IAAIF,IAAI,CAAC,EAAE,GAAGG,SAAAA,CAAAA;AAC5C,IAAA,MAAMC,cAAcJ,IAAI,CAACA,IAAKE,CAAAA,MAAM,GAAG,CAAE,CAAA,CAAA;AAEzC,IAAA,IAAI,CAACE,WAAAA,EAAa,MAAM,IAAIC,KAAM,CAAA,yBAAA,CAAA,CAAA;AAClC,IAAA,IAAI,CAACD,WAAW,CAACN,iBAAAA,CAAkB,EACjC,MAAM,IAAIO,KAAAA,CACR,CAAC,wBAAwB,EAAEP,iBAAAA,CAAkB,sBAAsB,CAAC,CAAA,CAAA;;AAIxE,IAAA,OAAOM,WAAW,CAACN,iBAAAA,CAAkB,CACnCQ,6CAAuBP,CAAAA,MAAAA,EAAQE;OAE5BD,IAAKO,CAAAA,KAAK,CAAC,CAAA,EAAG,CAAC,CAAA,CAAA,CAAA,CAAA;AAEtB;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composeQueryFilters = require('./composeQueryFilters.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calls a query client method with query filters and options,
|
|
7
|
+
* and automatically composes the `QueryKey` based on the schema and parameters.
|
|
8
|
+
*/ function callQueryClientMethodWithQueryFilters(queryFilterMethod, schema, args) {
|
|
9
|
+
const filters = args.length > 1 ? args[0] : undefined;
|
|
10
|
+
const queryClient = args[args.length - 1];
|
|
11
|
+
if (!queryClient) throw new Error('queryClient is required');
|
|
12
|
+
if (!queryClient[queryFilterMethod]) throw new Error(`queryClient is invalid, ${queryFilterMethod} method does not exist`);
|
|
13
|
+
// @ts-expect-error - Too complex to type
|
|
14
|
+
return queryClient[queryFilterMethod](composeQueryFilters.composeQueryFilters(schema, filters), // @ts-expect-error - Argument types are too complex
|
|
15
|
+
...args.slice(1, -1));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.callQueryClientMethodWithQueryFilters = callQueryClientMethodWithQueryFilters;
|
|
19
|
+
//# sourceMappingURL=callQueryClientMethodWithQueryFilters.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callQueryClientMethodWithQueryFilters.cjs","sources":["../../../src/lib/callQueryClientMethodWithQueryFilters.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\n\nimport { composeQueryFilters } from './composeQueryFilters.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Calls a query client method with query filters and options,\n * and automatically composes the `QueryKey` based on the schema and parameters.\n */\nexport function callQueryClientMethodWithQueryFilters<\n QFMethod extends QueryFilterMethods,\n>(\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n args: [...Parameters<(typeof QueryClient.prototype)[QFMethod]>, QueryClient]\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const filters = args.length > 1 ? args[0] : undefined;\n const queryClient = args[args.length - 1] as QueryClient | undefined;\n\n if (!queryClient) throw new Error('queryClient is required');\n if (!queryClient[queryFilterMethod])\n throw new Error(\n `queryClient is invalid, ${queryFilterMethod} method does not exist`\n );\n\n // @ts-expect-error - Too complex to type\n return queryClient[queryFilterMethod](\n composeQueryFilters(schema, filters as never),\n // @ts-expect-error - Argument types are too complex\n ...args.slice(1, -1)\n );\n}\n\ntype QueryFiltersMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n\ntype QueryFilterMethods =\n | QueryFiltersMethod<'isFetching'>\n | QueryFiltersMethod<'getQueriesData'>\n | QueryFiltersMethod<'setQueriesData'>\n | QueryFiltersMethod<'removeQueries'>\n | QueryFiltersMethod<'resetQueries'>\n | QueryFiltersMethod<'cancelQueries'>\n | QueryFiltersMethod<'invalidateQueries'>\n | QueryFiltersMethod<'refetchQueries'>;\n"],"names":["callQueryClientMethodWithQueryFilters","queryFilterMethod","schema","args","filters","length","undefined","queryClient","Error","composeQueryFilters","slice"],"mappings":";;;;AAKA;;;AAGC,IACM,SAASA,qCAAAA,CAGdC,iBAA2B,EAC3BC,MAAuB,EACvBC,IAA4E,EAAA;IAE5E,MAAMC,OAAAA,GAAUD,KAAKE,MAAM,GAAG,IAAIF,IAAI,CAAC,EAAE,GAAGG,SAAAA,CAAAA;AAC5C,IAAA,MAAMC,cAAcJ,IAAI,CAACA,IAAKE,CAAAA,MAAM,GAAG,CAAE,CAAA,CAAA;AAEzC,IAAA,IAAI,CAACE,WAAAA,EAAa,MAAM,IAAIC,KAAM,CAAA,yBAAA,CAAA,CAAA;AAClC,IAAA,IAAI,CAACD,WAAW,CAACN,iBAAAA,CAAkB,EACjC,MAAM,IAAIO,KAAAA,CACR,CAAC,wBAAwB,EAAEP,iBAAAA,CAAkB,sBAAsB,CAAC,CAAA,CAAA;;AAIxE,IAAA,OAAOM,WAAW,CAACN,iBAAAA,CAAkB,CACnCQ,uCAAoBP,CAAAA,MAAAA,EAAQE;OAEzBD,IAAKO,CAAAA,KAAK,CAAC,CAAA,EAAG,CAAC,CAAA,CAAA,CAAA,CAAA;AAEtB;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composeInfiniteQueryKey = require('./composeInfiniteQueryKey.cjs');
|
|
4
|
+
var composeQueryKey = require('./composeQueryKey.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calls a query client method with parameters and options,
|
|
8
|
+
* and automatically composes the `QueryKey` based on the schema and parameters.
|
|
9
|
+
*/ function callQueryClientMethodWithQueryKey(queryFilterMethod, schema, infinite, args) {
|
|
10
|
+
const parameters = args.length > 1 ? args[0] : undefined;
|
|
11
|
+
const queryClient = args[args.length - 1];
|
|
12
|
+
if (!queryClient) throw new Error('queryClient is required');
|
|
13
|
+
if (!queryClient[queryFilterMethod]) throw new Error(`queryClient is invalid, ${queryFilterMethod} method does not exist`);
|
|
14
|
+
const queryKey = Array.isArray(parameters) ? parameters : infinite ? composeInfiniteQueryKey.composeInfiniteQueryKey(schema, parameters) : composeQueryKey.composeQueryKey(schema, parameters);
|
|
15
|
+
// @ts-expect-error - Too complex to type
|
|
16
|
+
return queryClient[queryFilterMethod](queryKey, ...args.slice(1, -1));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.callQueryClientMethodWithQueryKey = callQueryClientMethodWithQueryKey;
|
|
20
|
+
//# sourceMappingURL=callQueryClientMethodWithQueryKey.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callQueryClientMethodWithQueryKey.cjs","sources":["../../../src/lib/callQueryClientMethodWithQueryKey.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\n\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Calls a query client method with parameters and options,\n * and automatically composes the `QueryKey` based on the schema and parameters.\n */\nexport function callQueryClientMethodWithQueryKey<\n QFMethod extends QueryKeyMethods,\n>(\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n infinite: boolean,\n args: [...Parameters<(typeof QueryClient.prototype)[QFMethod]>, QueryClient]\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const parameters = args.length > 1 ? args[0] : undefined;\n const queryClient = args[args.length - 1] as QueryClient | undefined;\n\n if (!queryClient) throw new Error('queryClient is required');\n if (!queryClient[queryFilterMethod])\n throw new Error(\n `queryClient is invalid, ${queryFilterMethod} method does not exist`\n );\n\n const queryKey = Array.isArray(parameters)\n ? parameters\n : infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters);\n\n // @ts-expect-error - Too complex to type\n return queryClient[queryFilterMethod](queryKey, ...args.slice(1, -1));\n}\n\ntype QueryKeyMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n\ntype QueryKeyMethods =\n | QueryKeyMethod<'setQueryData'>\n | QueryKeyMethod<'getQueryData'>\n | QueryKeyMethod<'getQueryState'>\n | QueryKeyMethod<'setQueryDefaults'>\n | QueryKeyMethod<'getQueryDefaults'>;\n"],"names":["callQueryClientMethodWithQueryKey","queryFilterMethod","schema","infinite","args","parameters","length","undefined","queryClient","Error","queryKey","Array","isArray","composeInfiniteQueryKey","composeQueryKey","slice"],"mappings":";;;;;AAMA;;;IAIO,SAASA,iCAGdC,CAAAA,iBAA2B,EAC3BC,MAAuB,EACvBC,QAAiB,EACjBC,IAA4E,EAAA;IAE5E,MAAMC,UAAAA,GAAaD,KAAKE,MAAM,GAAG,IAAIF,IAAI,CAAC,EAAE,GAAGG,SAAAA,CAAAA;AAC/C,IAAA,MAAMC,cAAcJ,IAAI,CAACA,IAAKE,CAAAA,MAAM,GAAG,CAAE,CAAA,CAAA;AAEzC,IAAA,IAAI,CAACE,WAAAA,EAAa,MAAM,IAAIC,KAAM,CAAA,yBAAA,CAAA,CAAA;AAClC,IAAA,IAAI,CAACD,WAAW,CAACP,iBAAAA,CAAkB,EACjC,MAAM,IAAIQ,KAAAA,CACR,CAAC,wBAAwB,EAAER,iBAAAA,CAAkB,sBAAsB,CAAC,CAAA,CAAA;IAGxE,MAAMS,QAAAA,GAAWC,KAAMC,CAAAA,OAAO,CAACP,UAAAA,CAAAA,GAC3BA,UACAF,GAAAA,QAAAA,GACEU,+CAAwBX,CAAAA,MAAAA,EAAQG,UAChCS,CAAAA,GAAAA,+BAAAA,CAAgBZ,MAAQG,EAAAA,UAAAA,CAAAA,CAAAA;;IAG9B,OAAOG,WAAW,CAACP,iBAAkB,CAAA,CAACS,aAAaN,IAAKW,CAAAA,KAAK,CAAC,CAAA,EAAG,CAAC,CAAA,CAAA,CAAA,CAAA;AACpE;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function composeBaseQueryKey(schema, parameters, infinite) {
|
|
4
|
+
return [
|
|
5
|
+
typeof infinite === 'boolean' ? {
|
|
6
|
+
...schema,
|
|
7
|
+
infinite
|
|
8
|
+
} : schema,
|
|
9
|
+
parameters ?? {}
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.composeBaseQueryKey = composeBaseQueryKey;
|
|
14
|
+
//# sourceMappingURL=composeBaseQueryKey.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeBaseQueryKey.cjs","sources":["../../../src/lib/composeBaseQueryKey.ts"],"sourcesContent":["import type {\n ServiceOperationInfiniteQueryKey,\n ServiceOperationQueryKey,\n} from '../service-operation/ServiceOperationKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\nexport function composeBaseQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined,\n infinite: undefined\n): [TSchema, TParams];\nexport function composeBaseQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined,\n infinite: true\n): ServiceOperationInfiniteQueryKey<TSchema, TParams>;\nexport function composeBaseQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined,\n infinite: false\n): ServiceOperationQueryKey<TSchema, TParams>;\nexport function composeBaseQueryKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams | undefined,\n infinite: boolean | undefined\n):\n | ServiceOperationQueryKey<TSchema, TParams>\n | ServiceOperationInfiniteQueryKey<TSchema, TParams>\n | [TSchema, TParams] {\n return [\n typeof infinite === 'boolean' ? { ...schema, infinite } : schema,\n parameters ?? ({} as TParams),\n ];\n}\n"],"names":["composeBaseQueryKey","schema","parameters","infinite"],"mappings":";;AAqBO,SAASA,mBACdC,CAAAA,MAAe,EACfC,UAA+B,EAC/BC,QAA6B,EAAA;IAK7B,OAAO;AACL,QAAA,OAAOA,aAAa,SAAY,GAAA;AAAE,YAAA,GAAGF,MAAM;AAAEE,YAAAA,QAAAA;SAAaF,GAAAA,MAAAA;AAC1DC,QAAAA,UAAAA,IAAe,EAAC;AACjB,KAAA,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composeBaseQueryKey = require('./composeBaseQueryKey.cjs');
|
|
4
|
+
|
|
5
|
+
function composeInfiniteQueryKey(schema, parameters) {
|
|
6
|
+
return composeBaseQueryKey.composeBaseQueryKey(schema, parameters, true);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
exports.composeInfiniteQueryKey = composeInfiniteQueryKey;
|
|
10
|
+
//# sourceMappingURL=composeInfiniteQueryKey.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeInfiniteQueryKey.cjs","sources":["../../../src/lib/composeInfiniteQueryKey.ts"],"sourcesContent":["import type { ServiceOperationInfiniteQueryKey } from '../service-operation/ServiceOperationKey.js';\nimport { composeBaseQueryKey } from './composeBaseQueryKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\nexport function composeInfiniteQueryKey<\n TSchema extends OperationSchema,\n TParams,\n>(\n schema: TSchema,\n parameters: TParams | undefined\n): ServiceOperationInfiniteQueryKey<TSchema, TParams> {\n return composeBaseQueryKey(schema, parameters, true);\n}\n"],"names":["composeInfiniteQueryKey","schema","parameters","composeBaseQueryKey"],"mappings":";;;;AAIO,SAASA,uBAAAA,CAIdC,MAAe,EACfC,UAA+B,EAAA;IAE/B,OAAOC,uCAAAA,CAAoBF,QAAQC,UAAY,EAAA,IAAA,CAAA,CAAA;AACjD;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composeMutationKey = require('./composeMutationKey.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Replaces the `parameters` field in the filters with a `mutationKey` field based on the schema.
|
|
7
|
+
* If no filters are provided, a `mutationKey` will be composed schema's base query key.
|
|
8
|
+
* @param schema
|
|
9
|
+
* @param filters
|
|
10
|
+
*/ function composeMutationFilters(schema, filters) {
|
|
11
|
+
if (!filters) {
|
|
12
|
+
return {
|
|
13
|
+
mutationKey: composeMutationKey.composeMutationKey(schema, undefined)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (filters && 'mutationKey' in filters && 'parameters' in filters) {
|
|
17
|
+
throw new Error(`'composeMutationFilters': 'mutationKey' and 'parameters' cannot be used together`);
|
|
18
|
+
}
|
|
19
|
+
if ('mutationKey' in filters) {
|
|
20
|
+
return filters;
|
|
21
|
+
}
|
|
22
|
+
if ('parameters' in filters) {
|
|
23
|
+
const { parameters, ...filtersWithoutParameters } = filters;
|
|
24
|
+
Object.assign(filtersWithoutParameters, {
|
|
25
|
+
mutationKey: composeMutationKey.composeMutationKey(schema, parameters)
|
|
26
|
+
});
|
|
27
|
+
return filtersWithoutParameters;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
...filters,
|
|
31
|
+
mutationKey: composeMutationKey.composeMutationKey(schema, undefined)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.composeMutationFilters = composeMutationFilters;
|
|
36
|
+
//# sourceMappingURL=composeMutationFilters.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeMutationFilters.cjs","sources":["../../../src/lib/composeMutationFilters.ts"],"sourcesContent":["import { composeMutationKey } from './composeMutationKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Replaces the `parameters` field in the filters with a `mutationKey` field based on the schema.\n * If no filters are provided, a `mutationKey` will be composed schema's base query key.\n * @param schema\n * @param filters\n */\nexport function composeMutationFilters<Filters extends object>(\n schema: OperationSchema,\n filters: Filters | undefined\n) {\n if (!filters) {\n return {\n mutationKey: composeMutationKey(schema, undefined),\n };\n }\n\n if (filters && 'mutationKey' in filters && 'parameters' in filters) {\n throw new Error(\n `'composeMutationFilters': 'mutationKey' and 'parameters' cannot be used together`\n );\n }\n\n if ('mutationKey' in filters) {\n return filters;\n }\n\n if ('parameters' in filters) {\n const { parameters, ...filtersWithoutParameters } = filters;\n\n Object.assign(filtersWithoutParameters, {\n mutationKey: composeMutationKey(schema, parameters),\n });\n\n return filtersWithoutParameters;\n }\n\n return {\n ...filters,\n mutationKey: composeMutationKey(schema, undefined),\n };\n}\n"],"names":["composeMutationFilters","schema","filters","mutationKey","composeMutationKey","undefined","Error","parameters","filtersWithoutParameters","Object","assign"],"mappings":";;;;AAGA;;;;;AAKC,IACM,SAASA,sBACdC,CAAAA,MAAuB,EACvBC,OAA4B,EAAA;AAE5B,IAAA,IAAI,CAACA,OAAS,EAAA;QACZ,OAAO;AACLC,YAAAA,WAAAA,EAAaC,sCAAmBH,MAAQI,EAAAA,SAAAA,CAAAA;AAC1C,SAAA,CAAA;AACF,KAAA;AAEA,IAAA,IAAIH,OAAW,IAAA,aAAA,IAAiBA,OAAW,IAAA,YAAA,IAAgBA,OAAS,EAAA;AAClE,QAAA,MAAM,IAAII,KAAAA,CACR,CAAC,gFAAgF,CAAC,CAAA,CAAA;AAEtF,KAAA;AAEA,IAAA,IAAI,iBAAiBJ,OAAS,EAAA;QAC5B,OAAOA,OAAAA,CAAAA;AACT,KAAA;AAEA,IAAA,IAAI,gBAAgBA,OAAS,EAAA;AAC3B,QAAA,MAAM,EAAEK,UAAU,EAAE,GAAGC,0BAA0B,GAAGN,OAAAA,CAAAA;QAEpDO,MAAOC,CAAAA,MAAM,CAACF,wBAA0B,EAAA;AACtCL,YAAAA,WAAAA,EAAaC,sCAAmBH,MAAQM,EAAAA,UAAAA,CAAAA;AAC1C,SAAA,CAAA,CAAA;QAEA,OAAOC,wBAAAA,CAAAA;AACT,KAAA;IAEA,OAAO;AACL,QAAA,GAAGN,OAAO;AACVC,QAAAA,WAAAA,EAAaC,sCAAmBH,MAAQI,EAAAA,SAAAA,CAAAA;AAC1C,KAAA,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function composeMutationKey(schema, parameters) {
|
|
4
|
+
return parameters === undefined ? [
|
|
5
|
+
{
|
|
6
|
+
url: schema.url,
|
|
7
|
+
method: schema.method
|
|
8
|
+
},
|
|
9
|
+
{}
|
|
10
|
+
] : [
|
|
11
|
+
{
|
|
12
|
+
url: schema.url,
|
|
13
|
+
method: schema.method
|
|
14
|
+
},
|
|
15
|
+
omitMutationPayload(parameters)
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
function omitMutationPayload(params) {
|
|
19
|
+
if (!params || typeof params !== 'object') throw new Error('`params` must be object');
|
|
20
|
+
if ('body' in params || 'requestBody' in params) {
|
|
21
|
+
const { body: _, requestBody: __, ...paramsRest } = params;
|
|
22
|
+
return paramsRest;
|
|
23
|
+
}
|
|
24
|
+
return params;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.composeMutationKey = composeMutationKey;
|
|
28
|
+
exports.omitMutationPayload = omitMutationPayload;
|
|
29
|
+
//# sourceMappingURL=composeMutationKey.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeMutationKey.cjs","sources":["../../../src/lib/composeMutationKey.ts"],"sourcesContent":["import type { ServiceOperationMutationKey } from '../service-operation/ServiceOperationKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Omit `body` or `requestBody` from mutation parameters if exists\n * and return the rest of the parameters\n */\nexport function composeMutationKey<TSchema extends OperationSchema>(\n schema: TSchema,\n parameters: undefined\n): ServiceOperationMutationKey<TSchema, undefined>;\nexport function composeMutationKey<TSchema extends OperationSchema, TParams>(\n schema: TSchema,\n parameters: TParams\n): ServiceOperationMutationKey<TSchema, TParams>;\nexport function composeMutationKey<\n TSchema extends OperationSchema,\n TParams = unknown,\n>(schema: TSchema, parameters: TParams | undefined) {\n return parameters === undefined\n ? [{ url: schema.url, method: schema.method }, {}]\n : [\n {\n url: schema.url,\n method: schema.method,\n },\n omitMutationPayload(parameters),\n ];\n}\n\nexport function omitMutationPayload<T>(params: T) {\n if (!params || typeof params !== 'object')\n throw new Error('`params` must be object');\n\n if ('body' in params || 'requestBody' in params) {\n const {\n body: _,\n requestBody: __,\n ...paramsRest\n } = params as Record<'body' | 'requestBody', unknown>;\n return paramsRest;\n }\n\n return params as Omit<T, 'body' | 'requestBody'>;\n}\n"],"names":["composeMutationKey","schema","parameters","undefined","url","method","omitMutationPayload","params","Error","body","_","requestBody","__","paramsRest"],"mappings":";;AAeO,SAASA,kBAAAA,CAGdC,MAAe,EAAEC,UAA+B,EAAA;AAChD,IAAA,OAAOA,eAAeC,SAClB,GAAA;AAAC,QAAA;AAAEC,YAAAA,GAAAA,EAAKH,OAAOG,GAAG;AAAEC,YAAAA,MAAAA,EAAQJ,OAAOI,MAAM;AAAC,SAAA;QAAG,EAAC;KAAE,GAChD;AACE,QAAA;AACED,YAAAA,GAAAA,EAAKH,OAAOG,GAAG;AACfC,YAAAA,MAAAA,EAAQJ,OAAOI,MAAM;AACvB,SAAA;QACAC,mBAAoBJ,CAAAA,UAAAA,CAAAA;AACrB,KAAA,CAAA;AACP,CAAA;AAEO,SAASI,oBAAuBC,MAAS,EAAA;AAC9C,IAAA,IAAI,CAACA,MAAU,IAAA,OAAOA,WAAW,QAC/B,EAAA,MAAM,IAAIC,KAAM,CAAA,yBAAA,CAAA,CAAA;IAElB,IAAI,MAAA,IAAUD,MAAU,IAAA,aAAA,IAAiBA,MAAQ,EAAA;QAC/C,MAAM,EACJE,MAAMC,CAAC,EACPC,aAAaC,EAAE,EACf,GAAGC,UAAAA,EACJ,GAAGN,MAAAA,CAAAA;QACJ,OAAOM,UAAAA,CAAAA;AACT,KAAA;IAEA,OAAON,MAAAA,CAAAA;AACT;;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composeBaseQueryKey = require('./composeBaseQueryKey.cjs');
|
|
4
|
+
var composeInfiniteQueryKey = require('./composeInfiniteQueryKey.cjs');
|
|
5
|
+
var composeQueryKey = require('./composeQueryKey.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Replaces the `parameters` field in the filters with a `queryKey` field based on the schema.
|
|
9
|
+
* If no filters are provided, a `queryKey` will be composed schema's base query key.
|
|
10
|
+
* @param schema
|
|
11
|
+
* @param filters
|
|
12
|
+
*/ function composeQueryFilters(schema, filters) {
|
|
13
|
+
if (!filters) {
|
|
14
|
+
return {
|
|
15
|
+
queryKey: composeBaseQueryKey.composeBaseQueryKey(schema, undefined, undefined)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if ('queryKey' in filters && 'parameters' in filters) {
|
|
19
|
+
throw new Error(`'composeQueryFilters': 'queryKey' and 'parameters' cannot be used together`);
|
|
20
|
+
}
|
|
21
|
+
const { infinite, parameters, ...filtersRest } = filters;
|
|
22
|
+
if ('queryKey' in filtersRest) {
|
|
23
|
+
return filtersRest;
|
|
24
|
+
}
|
|
25
|
+
if (parameters) {
|
|
26
|
+
Object.assign(filtersRest, {
|
|
27
|
+
queryKey: infinite ? composeInfiniteQueryKey.composeInfiniteQueryKey(schema, parameters) : composeQueryKey.composeQueryKey(schema, parameters)
|
|
28
|
+
});
|
|
29
|
+
return filtersRest;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...filtersRest,
|
|
33
|
+
queryKey: infinite ? composeInfiniteQueryKey.composeInfiniteQueryKey(schema, undefined) : composeQueryKey.composeQueryKey(schema, undefined)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.composeQueryFilters = composeQueryFilters;
|
|
38
|
+
//# sourceMappingURL=composeQueryFilters.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeQueryFilters.cjs","sources":["../../../src/lib/composeQueryFilters.ts"],"sourcesContent":["import { composeBaseQueryKey } from './composeBaseQueryKey.js';\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.js';\nimport type { OperationSchema } from './requestFn.js';\n\n/**\n * Replaces the `parameters` field in the filters with a `queryKey` field based on the schema.\n * If no filters are provided, a `queryKey` will be composed schema's base query key.\n * @param schema\n * @param filters\n */\nexport function composeQueryFilters<\n Filters extends {\n infinite: boolean;\n parameters?: object;\n } & Record<string, unknown>,\n>(schema: OperationSchema, filters: Filters | undefined) {\n if (!filters) {\n return {\n queryKey: composeBaseQueryKey(schema, undefined, undefined),\n };\n }\n\n if ('queryKey' in filters && 'parameters' in filters) {\n throw new Error(\n `'composeQueryFilters': 'queryKey' and 'parameters' cannot be used together`\n );\n }\n\n const { infinite, parameters, ...filtersRest } = filters;\n\n if ('queryKey' in filtersRest) {\n return filtersRest;\n }\n\n if (parameters) {\n Object.assign(filtersRest, {\n queryKey: infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters),\n });\n\n return filtersRest;\n }\n\n return {\n ...filtersRest,\n queryKey: infinite\n ? composeInfiniteQueryKey(schema, undefined)\n : composeQueryKey(schema, undefined),\n };\n}\n"],"names":["composeQueryFilters","schema","filters","queryKey","composeBaseQueryKey","undefined","Error","infinite","parameters","filtersRest","Object","assign","composeInfiniteQueryKey","composeQueryKey"],"mappings":";;;;;;AAKA;;;;;AAKC,IACM,SAASA,mBAKdC,CAAAA,MAAuB,EAAEC,OAA4B,EAAA;AACrD,IAAA,IAAI,CAACA,OAAS,EAAA;QACZ,OAAO;YACLC,QAAUC,EAAAA,uCAAAA,CAAoBH,QAAQI,SAAWA,EAAAA,SAAAA,CAAAA;AACnD,SAAA,CAAA;AACF,KAAA;IAEA,IAAI,UAAA,IAAcH,OAAW,IAAA,YAAA,IAAgBA,OAAS,EAAA;AACpD,QAAA,MAAM,IAAII,KAAAA,CACR,CAAC,0EAA0E,CAAC,CAAA,CAAA;AAEhF,KAAA;AAEA,IAAA,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAAGC,aAAa,GAAGP,OAAAA,CAAAA;AAEjD,IAAA,IAAI,cAAcO,WAAa,EAAA;QAC7B,OAAOA,WAAAA,CAAAA;AACT,KAAA;AAEA,IAAA,IAAID,UAAY,EAAA;QACdE,MAAOC,CAAAA,MAAM,CAACF,WAAa,EAAA;AACzBN,YAAAA,QAAAA,EAAUI,QACNK,GAAAA,+CAAAA,CAAwBX,MAAQO,EAAAA,UAAAA,CAAAA,GAChCK,gCAAgBZ,MAAQO,EAAAA,UAAAA,CAAAA;AAC9B,SAAA,CAAA,CAAA;QAEA,OAAOC,WAAAA,CAAAA;AACT,KAAA;IAEA,OAAO;AACL,QAAA,GAAGA,WAAW;AACdN,QAAAA,QAAAA,EAAUI,QACNK,GAAAA,+CAAAA,CAAwBX,MAAQI,EAAAA,SAAAA,CAAAA,GAChCQ,gCAAgBZ,MAAQI,EAAAA,SAAAA,CAAAA;AAC9B,KAAA,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var composeBaseQueryKey = require('./composeBaseQueryKey.cjs');
|
|
4
|
+
|
|
5
|
+
function composeQueryKey(schema, parameters) {
|
|
6
|
+
return composeBaseQueryKey.composeBaseQueryKey(schema, parameters, false);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
exports.composeQueryKey = composeQueryKey;
|
|
10
|
+
//# sourceMappingURL=composeQueryKey.cjs.map
|