@openapi-qraft/react 1.14.0 → 2.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/README.md +3 -6
- package/dist/cjs/Unstable_QraftSecureRequestFn.cjs.map +1 -1
- package/dist/cjs/callbacks/cancelQueries.cjs +1 -1
- package/dist/cjs/callbacks/cancelQueries.cjs.map +1 -1
- package/dist/cjs/callbacks/fetchInfiniteQuery.cjs +2 -2
- package/dist/cjs/callbacks/fetchInfiniteQuery.cjs.map +1 -1
- package/dist/cjs/callbacks/fetchQuery.cjs +2 -2
- package/dist/cjs/callbacks/fetchQuery.cjs.map +1 -1
- package/dist/cjs/callbacks/getInfiniteQueryData.cjs +3 -2
- package/dist/cjs/callbacks/getInfiniteQueryData.cjs.map +1 -1
- package/dist/cjs/callbacks/getInfiniteQueryKey.cjs +1 -1
- package/dist/cjs/callbacks/getInfiniteQueryKey.cjs.map +1 -1
- package/dist/cjs/callbacks/getInfiniteQueryState.cjs +3 -2
- package/dist/cjs/callbacks/getInfiniteQueryState.cjs.map +1 -1
- package/dist/cjs/callbacks/getMutationKey.cjs +1 -1
- package/dist/cjs/callbacks/getMutationKey.cjs.map +1 -1
- package/dist/cjs/callbacks/getQueriesData.cjs +2 -2
- package/dist/cjs/callbacks/getQueriesData.cjs.map +1 -1
- package/dist/cjs/callbacks/getQueryData.cjs +3 -2
- package/dist/cjs/callbacks/getQueryData.cjs.map +1 -1
- package/dist/cjs/callbacks/getQueryKey.cjs +1 -1
- package/dist/cjs/callbacks/getQueryKey.cjs.map +1 -1
- package/dist/cjs/callbacks/getQueryState.cjs +3 -2
- package/dist/cjs/callbacks/getQueryState.cjs.map +1 -1
- package/dist/cjs/callbacks/index.cjs +0 -4
- package/dist/cjs/callbacks/index.cjs.map +1 -1
- package/dist/cjs/callbacks/invalidateQueries.cjs +1 -1
- package/dist/cjs/callbacks/invalidateQueries.cjs.map +1 -1
- package/dist/cjs/callbacks/isFetching.cjs +1 -1
- package/dist/cjs/callbacks/isFetching.cjs.map +1 -1
- package/dist/cjs/callbacks/isMutating.cjs +2 -2
- package/dist/cjs/callbacks/isMutating.cjs.map +1 -1
- package/dist/cjs/callbacks/operationInvokeFn.cjs +7 -5
- package/dist/cjs/callbacks/operationInvokeFn.cjs.map +1 -1
- package/dist/cjs/callbacks/prefetchInfiniteQuery.cjs +2 -2
- package/dist/cjs/callbacks/prefetchInfiniteQuery.cjs.map +1 -1
- package/dist/cjs/callbacks/prefetchQuery.cjs +2 -2
- package/dist/cjs/callbacks/prefetchQuery.cjs.map +1 -1
- package/dist/cjs/callbacks/refetchQueries.cjs +1 -1
- package/dist/cjs/callbacks/refetchQueries.cjs.map +1 -1
- package/dist/cjs/callbacks/removeQueries.cjs +2 -2
- package/dist/cjs/callbacks/removeQueries.cjs.map +1 -1
- package/dist/cjs/callbacks/resetQueries.cjs +1 -1
- package/dist/cjs/callbacks/resetQueries.cjs.map +1 -1
- package/dist/cjs/callbacks/setInfiniteQueryData.cjs +2 -1
- package/dist/cjs/callbacks/setInfiniteQueryData.cjs.map +1 -1
- package/dist/cjs/callbacks/setQueriesData.cjs +2 -2
- package/dist/cjs/callbacks/setQueriesData.cjs.map +1 -1
- package/dist/cjs/callbacks/setQueryData.cjs +3 -2
- package/dist/cjs/callbacks/setQueryData.cjs.map +1 -1
- package/dist/cjs/callbacks/useInfiniteQuery.cjs.map +1 -1
- package/dist/cjs/callbacks/useIsFetching.cjs +2 -3
- package/dist/cjs/callbacks/useIsFetching.cjs.map +1 -1
- package/dist/cjs/callbacks/useIsMutating.cjs +2 -3
- package/dist/cjs/callbacks/useIsMutating.cjs.map +1 -1
- package/dist/cjs/callbacks/useMutation.cjs +10 -14
- package/dist/cjs/callbacks/useMutation.cjs.map +1 -1
- package/dist/cjs/callbacks/useMutationState.cjs +2 -3
- package/dist/cjs/callbacks/useMutationState.cjs.map +1 -1
- package/dist/cjs/callbacks/useQueries.cjs +6 -10
- package/dist/cjs/callbacks/useQueries.cjs.map +1 -1
- package/dist/cjs/callbacks/useQuery.cjs.map +1 -1
- package/dist/cjs/callbacks/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/dist/cjs/callbacks/useSuspenseQueries.cjs +6 -10
- package/dist/cjs/callbacks/useSuspenseQueries.cjs.map +1 -1
- package/dist/cjs/callbacks/useSuspenseQuery.cjs.map +1 -1
- package/dist/cjs/index.cjs +0 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/lib/callQueryClientFetchMethod.cjs +15 -22
- package/dist/cjs/lib/callQueryClientFetchMethod.cjs.map +1 -1
- package/dist/cjs/lib/callQueryClientMethodWithMutationFilters.cjs +4 -6
- package/dist/cjs/lib/callQueryClientMethodWithMutationFilters.cjs.map +1 -1
- package/dist/cjs/lib/callQueryClientMethodWithQueryFilters.cjs +4 -6
- package/dist/cjs/lib/callQueryClientMethodWithQueryFilters.cjs.map +1 -1
- package/dist/cjs/lib/callQueryClientMethodWithQueryKey.cjs +4 -6
- package/dist/cjs/lib/callQueryClientMethodWithQueryKey.cjs.map +1 -1
- package/dist/cjs/lib/requestFn.cjs +35 -21
- package/dist/cjs/lib/requestFn.cjs.map +1 -1
- package/dist/cjs/lib/requestFnResponseResolver.cjs +9 -0
- package/dist/cjs/lib/requestFnResponseResolver.cjs.map +1 -0
- package/dist/cjs/lib/useComposeUseQueryOptions.cjs +6 -10
- package/dist/cjs/lib/useComposeUseQueryOptions.cjs.map +1 -1
- package/dist/cjs/qraftAPIClient.cjs +13 -3
- package/dist/cjs/qraftAPIClient.cjs.map +1 -1
- package/dist/esm/Unstable_QraftSecureRequestFn.js.map +1 -1
- package/dist/esm/callbacks/cancelQueries.js +1 -1
- package/dist/esm/callbacks/cancelQueries.js.map +1 -1
- package/dist/esm/callbacks/fetchInfiniteQuery.js +2 -2
- package/dist/esm/callbacks/fetchInfiniteQuery.js.map +1 -1
- package/dist/esm/callbacks/fetchQuery.js +2 -2
- package/dist/esm/callbacks/fetchQuery.js.map +1 -1
- package/dist/esm/callbacks/getInfiniteQueryData.js +3 -2
- package/dist/esm/callbacks/getInfiniteQueryData.js.map +1 -1
- package/dist/esm/callbacks/getInfiniteQueryKey.js +1 -1
- package/dist/esm/callbacks/getInfiniteQueryKey.js.map +1 -1
- package/dist/esm/callbacks/getInfiniteQueryState.js +3 -2
- package/dist/esm/callbacks/getInfiniteQueryState.js.map +1 -1
- package/dist/esm/callbacks/getMutationKey.js +1 -1
- package/dist/esm/callbacks/getMutationKey.js.map +1 -1
- package/dist/esm/callbacks/getQueriesData.js +2 -2
- package/dist/esm/callbacks/getQueriesData.js.map +1 -1
- package/dist/esm/callbacks/getQueryData.js +3 -2
- package/dist/esm/callbacks/getQueryData.js.map +1 -1
- package/dist/esm/callbacks/getQueryKey.js +1 -1
- package/dist/esm/callbacks/getQueryKey.js.map +1 -1
- package/dist/esm/callbacks/getQueryState.js +3 -2
- package/dist/esm/callbacks/getQueryState.js.map +1 -1
- package/dist/esm/callbacks/index.js +0 -2
- package/dist/esm/callbacks/index.js.map +1 -1
- package/dist/esm/callbacks/invalidateQueries.js +1 -1
- package/dist/esm/callbacks/invalidateQueries.js.map +1 -1
- package/dist/esm/callbacks/isFetching.js +1 -1
- package/dist/esm/callbacks/isFetching.js.map +1 -1
- package/dist/esm/callbacks/isMutating.js +2 -2
- package/dist/esm/callbacks/isMutating.js.map +1 -1
- package/dist/esm/callbacks/operationInvokeFn.js +7 -5
- package/dist/esm/callbacks/operationInvokeFn.js.map +1 -1
- package/dist/esm/callbacks/prefetchInfiniteQuery.js +2 -2
- package/dist/esm/callbacks/prefetchInfiniteQuery.js.map +1 -1
- package/dist/esm/callbacks/prefetchQuery.js +2 -2
- package/dist/esm/callbacks/prefetchQuery.js.map +1 -1
- package/dist/esm/callbacks/refetchQueries.js +1 -1
- package/dist/esm/callbacks/refetchQueries.js.map +1 -1
- package/dist/esm/callbacks/removeQueries.js +2 -2
- package/dist/esm/callbacks/removeQueries.js.map +1 -1
- package/dist/esm/callbacks/resetQueries.js +1 -1
- package/dist/esm/callbacks/resetQueries.js.map +1 -1
- package/dist/esm/callbacks/setInfiniteQueryData.js +2 -1
- package/dist/esm/callbacks/setInfiniteQueryData.js.map +1 -1
- package/dist/esm/callbacks/setQueriesData.js +2 -2
- package/dist/esm/callbacks/setQueriesData.js.map +1 -1
- package/dist/esm/callbacks/setQueryData.js +3 -2
- package/dist/esm/callbacks/setQueryData.js.map +1 -1
- package/dist/esm/callbacks/useInfiniteQuery.js.map +1 -1
- package/dist/esm/callbacks/useIsFetching.js +2 -3
- package/dist/esm/callbacks/useIsFetching.js.map +1 -1
- package/dist/esm/callbacks/useIsMutating.js +2 -3
- package/dist/esm/callbacks/useIsMutating.js.map +1 -1
- package/dist/esm/callbacks/useMutation.js +10 -14
- package/dist/esm/callbacks/useMutation.js.map +1 -1
- package/dist/esm/callbacks/useMutationState.js +2 -3
- package/dist/esm/callbacks/useMutationState.js.map +1 -1
- package/dist/esm/callbacks/useQueries.js +6 -10
- package/dist/esm/callbacks/useQueries.js.map +1 -1
- package/dist/esm/callbacks/useQuery.js.map +1 -1
- package/dist/esm/callbacks/useSuspenseInfiniteQuery.js.map +1 -1
- package/dist/esm/callbacks/useSuspenseQueries.js +6 -10
- package/dist/esm/callbacks/useSuspenseQueries.js.map +1 -1
- package/dist/esm/callbacks/useSuspenseQuery.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/callQueryClientFetchMethod.js +15 -22
- package/dist/esm/lib/callQueryClientFetchMethod.js.map +1 -1
- package/dist/esm/lib/callQueryClientMethodWithMutationFilters.js +4 -6
- package/dist/esm/lib/callQueryClientMethodWithMutationFilters.js.map +1 -1
- package/dist/esm/lib/callQueryClientMethodWithQueryFilters.js +4 -6
- package/dist/esm/lib/callQueryClientMethodWithQueryFilters.js.map +1 -1
- package/dist/esm/lib/callQueryClientMethodWithQueryKey.js +4 -6
- package/dist/esm/lib/callQueryClientMethodWithQueryKey.js.map +1 -1
- package/dist/esm/lib/requestFn.js +35 -21
- package/dist/esm/lib/requestFn.js.map +1 -1
- package/dist/esm/lib/requestFnResponseResolver.js +7 -0
- package/dist/esm/lib/requestFnResponseResolver.js.map +1 -0
- package/dist/esm/lib/useComposeUseQueryOptions.js +6 -10
- package/dist/esm/lib/useComposeUseQueryOptions.js.map +1 -1
- package/dist/esm/qraftAPIClient.js +13 -3
- package/dist/esm/qraftAPIClient.js.map +1 -1
- package/dist/types/Unstable_QraftSecureRequestFn.d.ts +3 -3
- package/dist/types/Unstable_QraftSecureRequestFn.d.ts.map +1 -1
- package/dist/types/callbacks/cancelQueries.d.ts +3 -3
- package/dist/types/callbacks/cancelQueries.d.ts.map +1 -1
- package/dist/types/callbacks/fetchInfiniteQuery.d.ts +3 -3
- package/dist/types/callbacks/fetchInfiniteQuery.d.ts.map +1 -1
- package/dist/types/callbacks/fetchQuery.d.ts +3 -3
- package/dist/types/callbacks/fetchQuery.d.ts.map +1 -1
- package/dist/types/callbacks/getInfiniteQueryData.d.ts +2 -2
- package/dist/types/callbacks/getInfiniteQueryData.d.ts.map +1 -1
- package/dist/types/callbacks/getInfiniteQueryKey.d.ts +2 -2
- package/dist/types/callbacks/getInfiniteQueryKey.d.ts.map +1 -1
- package/dist/types/callbacks/getInfiniteQueryState.d.ts +2 -2
- package/dist/types/callbacks/getInfiniteQueryState.d.ts.map +1 -1
- package/dist/types/callbacks/getMutationKey.d.ts +3 -3
- package/dist/types/callbacks/getMutationKey.d.ts.map +1 -1
- package/dist/types/callbacks/getQueriesData.d.ts +3 -3
- package/dist/types/callbacks/getQueriesData.d.ts.map +1 -1
- package/dist/types/callbacks/getQueryData.d.ts +2 -2
- package/dist/types/callbacks/getQueryData.d.ts.map +1 -1
- package/dist/types/callbacks/getQueryKey.d.ts +3 -3
- package/dist/types/callbacks/getQueryKey.d.ts.map +1 -1
- package/dist/types/callbacks/getQueryState.d.ts +2 -2
- package/dist/types/callbacks/getQueryState.d.ts.map +1 -1
- package/dist/types/callbacks/index.d.ts +0 -2
- package/dist/types/callbacks/index.d.ts.map +1 -1
- package/dist/types/callbacks/invalidateQueries.d.ts +3 -3
- package/dist/types/callbacks/invalidateQueries.d.ts.map +1 -1
- package/dist/types/callbacks/isFetching.d.ts +3 -3
- package/dist/types/callbacks/isFetching.d.ts.map +1 -1
- package/dist/types/callbacks/isMutating.d.ts +3 -3
- package/dist/types/callbacks/isMutating.d.ts.map +1 -1
- package/dist/types/callbacks/operationInvokeFn.d.ts +5 -5
- package/dist/types/callbacks/operationInvokeFn.d.ts.map +1 -1
- package/dist/types/callbacks/prefetchInfiniteQuery.d.ts +3 -3
- package/dist/types/callbacks/prefetchInfiniteQuery.d.ts.map +1 -1
- package/dist/types/callbacks/prefetchQuery.d.ts +3 -3
- package/dist/types/callbacks/prefetchQuery.d.ts.map +1 -1
- package/dist/types/callbacks/refetchQueries.d.ts +3 -3
- package/dist/types/callbacks/refetchQueries.d.ts.map +1 -1
- package/dist/types/callbacks/removeQueries.d.ts +3 -3
- package/dist/types/callbacks/removeQueries.d.ts.map +1 -1
- package/dist/types/callbacks/resetQueries.d.ts +3 -3
- package/dist/types/callbacks/resetQueries.d.ts.map +1 -1
- package/dist/types/callbacks/setInfiniteQueryData.d.ts +4 -4
- package/dist/types/callbacks/setInfiniteQueryData.d.ts.map +1 -1
- package/dist/types/callbacks/setQueriesData.d.ts +3 -3
- package/dist/types/callbacks/setQueriesData.d.ts.map +1 -1
- package/dist/types/callbacks/setQueryData.d.ts +3 -3
- package/dist/types/callbacks/setQueryData.d.ts.map +1 -1
- package/dist/types/callbacks/useInfiniteQuery.d.ts +2 -2
- package/dist/types/callbacks/useInfiniteQuery.d.ts.map +1 -1
- package/dist/types/callbacks/useIsFetching.d.ts +2 -2
- package/dist/types/callbacks/useIsFetching.d.ts.map +1 -1
- package/dist/types/callbacks/useIsMutating.d.ts +4 -4
- package/dist/types/callbacks/useIsMutating.d.ts.map +1 -1
- package/dist/types/callbacks/useMutation.d.ts +3 -3
- package/dist/types/callbacks/useMutation.d.ts.map +1 -1
- package/dist/types/callbacks/useMutationState.d.ts +4 -4
- package/dist/types/callbacks/useMutationState.d.ts.map +1 -1
- package/dist/types/callbacks/useQueries.d.ts +4 -4
- package/dist/types/callbacks/useQueries.d.ts.map +1 -1
- package/dist/types/callbacks/useQuery.d.ts +2 -2
- package/dist/types/callbacks/useQuery.d.ts.map +1 -1
- package/dist/types/callbacks/useSuspenseInfiniteQuery.d.ts +2 -2
- package/dist/types/callbacks/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/dist/types/callbacks/useSuspenseQueries.d.ts +4 -4
- package/dist/types/callbacks/useSuspenseQueries.d.ts.map +1 -1
- package/dist/types/callbacks/useSuspenseQuery.d.ts +2 -2
- package/dist/types/callbacks/useSuspenseQuery.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/callQueryClientFetchMethod.d.ts +3 -2
- package/dist/types/lib/callQueryClientFetchMethod.d.ts.map +1 -1
- package/dist/types/lib/callQueryClientMethodWithMutationFilters.d.ts +2 -1
- package/dist/types/lib/callQueryClientMethodWithMutationFilters.d.ts.map +1 -1
- package/dist/types/lib/callQueryClientMethodWithQueryFilters.d.ts +2 -1
- package/dist/types/lib/callQueryClientMethodWithQueryFilters.d.ts.map +1 -1
- package/dist/types/lib/callQueryClientMethodWithQueryKey.d.ts +2 -1
- package/dist/types/lib/callQueryClientMethodWithQueryKey.d.ts.map +1 -1
- package/dist/types/lib/requestFn.d.ts +17 -4
- package/dist/types/lib/requestFn.d.ts.map +1 -1
- package/dist/types/lib/requestFnResponseResolver.d.ts +3 -0
- package/dist/types/lib/requestFnResponseResolver.d.ts.map +1 -0
- package/dist/types/lib/useComposeUseQueryOptions.d.ts +2 -2
- package/dist/types/lib/useComposeUseQueryOptions.d.ts.map +1 -1
- package/dist/types/qraftAPIClient.d.ts +40 -9
- package/dist/types/qraftAPIClient.d.ts.map +1 -1
- package/dist/types/qraftPredefinedParametersRequestFn.d.ts +19 -0
- package/dist/types/qraftPredefinedParametersRequestFn.d.ts.map +1 -0
- package/dist/types/service-operation/ServiceOperation.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperation.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationCancelQueries.d.ts +2 -13
- package/dist/types/service-operation/ServiceOperationCancelQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationFetchInfiniteQuery.d.ts +10 -7
- package/dist/types/service-operation/ServiceOperationFetchInfiniteQuery.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationFetchQuery.d.ts +19 -10
- package/dist/types/service-operation/ServiceOperationFetchQuery.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationGetInfiniteQueryData.d.ts +3 -3
- package/dist/types/service-operation/ServiceOperationGetInfiniteQueryData.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationGetQueriesData.d.ts +3 -4
- package/dist/types/service-operation/ServiceOperationGetQueriesData.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationGetQueryData.d.ts +3 -3
- package/dist/types/service-operation/ServiceOperationGetQueryData.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationGetQueryState.d.ts +3 -3
- package/dist/types/service-operation/ServiceOperationGetQueryState.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationInvalidateQueries.d.ts +2 -13
- package/dist/types/service-operation/ServiceOperationInvalidateQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationIsFetchingQueries.d.ts +2 -12
- package/dist/types/service-operation/ServiceOperationIsFetchingQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationIsMutatingQueries.d.ts +2 -12
- package/dist/types/service-operation/ServiceOperationIsMutatingQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationMutationFn.d.ts +16 -33
- package/dist/types/service-operation/ServiceOperationMutationFn.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationQueryFn.d.ts +7 -49
- package/dist/types/service-operation/ServiceOperationQueryFn.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationRefetchQueries.d.ts +2 -23
- package/dist/types/service-operation/ServiceOperationRefetchQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationRemoveQueries.d.ts +2 -12
- package/dist/types/service-operation/ServiceOperationRemoveQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationResetQueries.d.ts +2 -13
- package/dist/types/service-operation/ServiceOperationResetQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationSetInfiniteQueryData.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationSetInfiniteQueryData.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationSetQueriesData.d.ts +3 -14
- package/dist/types/service-operation/ServiceOperationSetQueriesData.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationSetQueryData.d.ts +2 -12
- package/dist/types/service-operation/ServiceOperationSetQueryData.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseInfiniteQuery.d.ts +6 -5
- package/dist/types/service-operation/ServiceOperationUseInfiniteQuery.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseIsFetchingQueries.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationUseIsFetchingQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseIsMutating.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationUseIsMutating.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseMutation.d.ts +4 -4
- package/dist/types/service-operation/ServiceOperationUseMutation.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseMutationState.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationUseMutationState.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseQueries.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationUseQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseQuery.d.ts +5 -5
- package/dist/types/service-operation/ServiceOperationUseQuery.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseSuspenseInfiniteQuery.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationUseSuspenseInfiniteQuery.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseSuspenseQueries.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationUseSuspenseQueries.d.ts.map +1 -1
- package/dist/types/service-operation/ServiceOperationUseSuspenseQuery.d.ts +2 -2
- package/dist/types/service-operation/ServiceOperationUseSuspenseQuery.d.ts.map +1 -1
- package/package.json +10 -5
- package/src/Unstable_QraftSecureRequestFn.ts +3 -2
- package/src/callbacks/cancelQueries.ts +5 -4
- package/src/callbacks/fetchInfiniteQuery.ts +10 -5
- package/src/callbacks/fetchQuery.ts +8 -5
- package/src/callbacks/getInfiniteQueryData.ts +5 -3
- package/src/callbacks/getInfiniteQueryKey.ts +2 -2
- package/src/callbacks/getInfiniteQueryState.ts +5 -3
- package/src/callbacks/getMutationKey.ts +3 -3
- package/src/callbacks/getQueriesData.ts +4 -3
- package/src/callbacks/getQueryData.ts +5 -3
- package/src/callbacks/getQueryKey.ts +3 -3
- package/src/callbacks/getQueryState.ts +5 -3
- package/src/callbacks/index.ts +0 -2
- package/src/callbacks/invalidateQueries.ts +5 -4
- package/src/callbacks/isFetching.ts +5 -4
- package/src/callbacks/isMutating.ts +5 -4
- package/src/callbacks/operationInvokeFn.ts +23 -13
- package/src/callbacks/prefetchInfiniteQuery.ts +10 -5
- package/src/callbacks/prefetchQuery.ts +6 -5
- package/src/callbacks/refetchQueries.ts +5 -4
- package/src/callbacks/removeQueries.ts +5 -4
- package/src/callbacks/resetQueries.ts +5 -4
- package/src/callbacks/setInfiniteQueryData.ts +8 -6
- package/src/callbacks/setQueriesData.ts +5 -4
- package/src/callbacks/setQueryData.ts +7 -5
- package/src/callbacks/useInfiniteQuery.ts +2 -2
- package/src/callbacks/useIsFetching.ts +4 -5
- package/src/callbacks/useIsMutating.ts +7 -10
- package/src/callbacks/useMutation.ts +22 -29
- package/src/callbacks/useMutationState.ts +7 -10
- package/src/callbacks/useQueries.ts +16 -23
- package/src/callbacks/useQuery.ts +2 -2
- package/src/callbacks/useSuspenseInfiniteQuery.ts +2 -2
- package/src/callbacks/useSuspenseQueries.ts +16 -23
- package/src/callbacks/useSuspenseQuery.ts +2 -2
- package/src/index.ts +10 -2
- package/src/lib/callQueryClientFetchMethod.ts +39 -37
- package/src/lib/callQueryClientMethodWithMutationFilters.ts +5 -9
- package/src/lib/callQueryClientMethodWithQueryFilters.ts +5 -9
- package/src/lib/callQueryClientMethodWithQueryKey.ts +10 -10
- package/src/lib/requestFn.ts +104 -50
- package/src/lib/requestFnResponseResolver.ts +8 -0
- package/src/lib/urlSerializer.test.ts +0 -1
- package/src/lib/useComposeUseQueryOptions.ts +16 -24
- package/src/qraftAPIClient.ts +236 -31
- package/src/qraftPredefinedParametersRequestFn.ts +140 -0
- package/src/service-operation/ServiceOperation.ts +2 -2
- package/src/service-operation/ServiceOperationCancelQueries.ts +4 -37
- package/src/service-operation/ServiceOperationFetchInfiniteQuery.ts +12 -11
- package/src/service-operation/ServiceOperationFetchQuery.ts +40 -23
- package/src/service-operation/ServiceOperationGetInfiniteQueryData.ts +5 -4
- package/src/service-operation/ServiceOperationGetQueriesData.ts +5 -6
- package/src/service-operation/ServiceOperationGetQueryData.ts +5 -4
- package/src/service-operation/ServiceOperationGetQueryState.ts +3 -9
- package/src/service-operation/ServiceOperationInvalidateQueries.ts +10 -34
- package/src/service-operation/ServiceOperationIsFetchingQueries.ts +3 -24
- package/src/service-operation/ServiceOperationIsMutatingQueries.ts +2 -37
- package/src/service-operation/ServiceOperationMutationFn.ts +32 -75
- package/src/service-operation/ServiceOperationQueryFn.ts +15 -121
- package/src/service-operation/ServiceOperationRefetchQueries.ts +4 -58
- package/src/service-operation/ServiceOperationRemoveQueries.ts +3 -24
- package/src/service-operation/ServiceOperationResetQueries.ts +4 -37
- package/src/service-operation/ServiceOperationSetInfiniteQueryData.ts +1 -7
- package/src/service-operation/ServiceOperationSetQueriesData.ts +3 -32
- package/src/service-operation/ServiceOperationSetQueryData.ts +3 -31
- package/src/service-operation/ServiceOperationUseInfiniteQuery.ts +13 -11
- package/src/service-operation/ServiceOperationUseIsFetchingQueries.ts +3 -4
- package/src/service-operation/ServiceOperationUseIsMutating.ts +2 -3
- package/src/service-operation/ServiceOperationUseMutation.ts +6 -8
- package/src/service-operation/ServiceOperationUseMutationState.ts +17 -21
- package/src/service-operation/ServiceOperationUseQueries.ts +6 -10
- package/src/service-operation/ServiceOperationUseQuery.ts +7 -9
- package/src/service-operation/ServiceOperationUseSuspenseInfiniteQuery.ts +1 -3
- package/src/service-operation/ServiceOperationUseSuspenseQueries.ts +9 -12
- package/src/service-operation/ServiceOperationUseSuspenseQuery.ts +2 -3
- package/dist/cjs/QraftContext.cjs +0 -9
- package/dist/cjs/QraftContext.cjs.map +0 -1
- package/dist/cjs/callbacks/mutationFn.cjs +0 -12
- package/dist/cjs/callbacks/mutationFn.cjs.map +0 -1
- package/dist/cjs/callbacks/queryFn.cjs +0 -13
- package/dist/cjs/callbacks/queryFn.cjs.map +0 -1
- package/dist/cjs/lib/useQueryClient.cjs +0 -18
- package/dist/cjs/lib/useQueryClient.cjs.map +0 -1
- package/dist/esm/QraftContext.js +0 -7
- package/dist/esm/QraftContext.js.map +0 -1
- package/dist/esm/callbacks/mutationFn.js +0 -10
- package/dist/esm/callbacks/mutationFn.js.map +0 -1
- package/dist/esm/callbacks/queryFn.js +0 -11
- package/dist/esm/callbacks/queryFn.js.map +0 -1
- package/dist/esm/lib/useQueryClient.js +0 -16
- package/dist/esm/lib/useQueryClient.js.map +0 -1
- package/dist/types/QraftContext.d.ts +0 -20
- package/dist/types/QraftContext.d.ts.map +0 -1
- package/dist/types/ServiceOperation.d.ts +0 -44
- package/dist/types/ServiceOperation.d.ts.map +0 -1
- package/dist/types/callbacks/mutationFn.d.ts +0 -4
- package/dist/types/callbacks/mutationFn.d.ts.map +0 -1
- package/dist/types/callbacks/queryFn.d.ts +0 -7
- package/dist/types/callbacks/queryFn.d.ts.map +0 -1
- package/dist/types/lib/useQueryClient.d.ts +0 -9
- package/dist/types/lib/useQueryClient.d.ts.map +0 -1
- package/src/QraftContext.ts +0 -28
- package/src/ServiceOperation.ts +0 -66
- package/src/callbacks/mutationFn.ts +0 -22
- package/src/callbacks/queryFn.ts +0 -26
- package/src/lib/useQueryClient.ts +0 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseInfiniteQuery.js","sources":["../../../src/callbacks/useSuspenseInfiniteQuery.ts"],"sourcesContent":["'use client';\n\nimport type { DefaultError, InfiniteData } from '@tanstack/query-core';\nimport type { UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"useSuspenseInfiniteQuery.js","sources":["../../../src/callbacks/useSuspenseInfiniteQuery.ts"],"sourcesContent":["'use client';\n\nimport type { DefaultError, InfiniteData } from '@tanstack/query-core';\nimport type { UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { CreateAPIQueryClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\nimport { useSuspenseInfiniteQuery as useSuspenseInfiniteQueryTanstack } from '@tanstack/react-query';\nimport { useComposeUseQueryOptions } from '../lib/useComposeUseQueryOptions.js';\n\nexport const useSuspenseInfiniteQuery: <\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n>(\n qraftOptions: CreateAPIQueryClientOptions,\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"],"names":["useSuspenseInfiniteQuery","qraftOptions","schema","args","useSuspenseInfiniteQueryTanstack","useComposeUseQueryOptions"],"mappings":";;;;AAUaA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GAcwC,CACnDC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EACAC,CACAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,IAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AAEA,CAAA,CAAA,CAAA,CAAA,OAAOC;KAEFC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA0BJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAcC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAQC,CAAAA,CAAAA,CAAAA,CAAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAE7D,CAAA,CAAA;;"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useSuspenseQueries as useSuspenseQueries$1 } from '@tanstack/react-query';
|
|
3
|
-
import { useContext } from 'react';
|
|
4
3
|
import { composeQueryKey } from '../lib/composeQueryKey.js';
|
|
5
|
-
import {
|
|
6
|
-
import { QraftContext } from '../QraftContext.js';
|
|
4
|
+
import { requestFnResponseResolver } from '../lib/requestFnResponseResolver.js';
|
|
7
5
|
|
|
8
6
|
const useSuspenseQueries = (qraftOptions, schema, args)=>{
|
|
9
|
-
const [options
|
|
10
|
-
const contextValue = useContext(qraftOptions?.context ?? QraftContext);
|
|
7
|
+
const [options] = args;
|
|
11
8
|
return useSuspenseQueries$1({
|
|
12
9
|
...options,
|
|
13
10
|
queries: options.queries.map((queryOptions)=>{
|
|
@@ -21,17 +18,16 @@ const useSuspenseQueries = (qraftOptions, schema, args)=>{
|
|
|
21
18
|
return {
|
|
22
19
|
...optionsWithQueryKey,
|
|
23
20
|
queryFn: optionsWithQueryKey.queryFn ?? function({ queryKey: [, queryParams], signal, meta }) {
|
|
24
|
-
|
|
25
|
-
return contextValue.requestFn(schema, {
|
|
21
|
+
return qraftOptions.requestFn(schema, {
|
|
26
22
|
parameters: queryParams,
|
|
27
|
-
baseUrl:
|
|
23
|
+
baseUrl: qraftOptions.baseUrl,
|
|
28
24
|
signal,
|
|
29
25
|
meta
|
|
30
|
-
});
|
|
26
|
+
}).then(requestFnResponseResolver, requestFnResponseResolver);
|
|
31
27
|
}
|
|
32
28
|
};
|
|
33
29
|
})
|
|
34
|
-
},
|
|
30
|
+
}, qraftOptions.queryClient);
|
|
35
31
|
};
|
|
36
32
|
|
|
37
33
|
export { useSuspenseQueries };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQueries.js","sources":["../../../src/callbacks/useSuspenseQueries.ts"],"sourcesContent":["'use client';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"useSuspenseQueries.js","sources":["../../../src/callbacks/useSuspenseQueries.ts"],"sourcesContent":["'use client';\n\nimport type { SuspenseQueriesResults } from '@tanstack/react-query';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { CreateAPIQueryClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\nimport { useSuspenseQueries as useSuspenseQueriesTanstack } from '@tanstack/react-query';\nimport { composeQueryKey } from '../lib/composeQueryKey.js';\nimport { requestFnResponseResolver } from '../lib/requestFnResponseResolver.js';\n\nexport const useSuspenseQueries: (\n qraftOptions: CreateAPIQueryClientOptions,\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] = args;\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 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 qraftOptions\n .requestFn(schema, {\n parameters: queryParams as never,\n baseUrl: qraftOptions.baseUrl,\n signal,\n meta,\n })\n .then(requestFnResponseResolver, requestFnResponseResolver);\n },\n };\n }),\n },\n qraftOptions.queryClient\n ) as never;\n};\n"],"names":["useSuspenseQueries","qraftOptions","schema","args","options","useSuspenseQueriesTanstack","queries","map","queryOptions","optionsWithQueryKey","queryOptionsCopy","Object","assign","queryKey","composeQueryKey","parameters","queryFn","queryParams","signal","meta","requestFn","baseUrl","then","requestFnResponseResolver","queryClient"],"mappings":";;;;;AAUaA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA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A,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;CAEDG,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAI,CAAA,CAAA,CAAA,CAACC,yBAA2BA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AACrC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACF,CAAA,CAAA,CAAA,CAAA,CAAA,CACAtB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAauB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAA,CAAA;AAE5B,CAAA,CAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery.js","sources":["../../../src/callbacks/useSuspenseQuery.ts"],"sourcesContent":["'use client';\n\nimport type { DefaultError } from '@tanstack/query-core';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.js","sources":["../../../src/callbacks/useSuspenseQuery.ts"],"sourcesContent":["'use client';\n\nimport type { DefaultError } from '@tanstack/query-core';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport type { OperationSchema } from '../lib/requestFn.js';\nimport type { CreateAPIQueryClientOptions } from '../qraftAPIClient.js';\nimport type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';\nimport { useSuspenseQuery as useSuspenseQueryTanstack } from '@tanstack/react-query';\nimport { useComposeUseQueryOptions } from '../lib/useComposeUseQueryOptions.js';\n\nexport const useSuspenseQuery: <\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n>(\n qraftOptions: CreateAPIQueryClientOptions,\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"],"names":["useSuspenseQuery","qraftOptions","schema","args","useSuspenseQueryTanstack","useComposeUseQueryOptions"],"mappings":";;;;AAUaA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GAUwB,CAACC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAcC,CAAQC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,IAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AAC1D,CAAA,CAAA,CAAA,CAAA,OAAOC;KAEFC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA0BJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAcC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAQC,CAAAA,CAAAA,CAAAA,CAAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAE7D,CAAA,CAAA;;"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,43 +1,36 @@
|
|
|
1
1
|
import { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';
|
|
2
2
|
import { composeQueryKey } from './composeQueryKey.js';
|
|
3
|
+
import { requestFnResponseResolver } from './requestFnResponseResolver.js';
|
|
3
4
|
import { shelfMerge } from './shelfMerge.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Calls a query client fetch method with parameters and options,
|
|
7
8
|
* and automatically composes the `QueryKey` based on the schema and parameters.
|
|
8
|
-
*/ function callQueryClientMethodWithQueryKey(queryFilterMethod, schema, infinite, args) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
*/ function callQueryClientMethodWithQueryKey(qraftOptions, queryFilterMethod, schema, infinite, args) {
|
|
10
|
+
const { requestFn: requestFnOption, baseUrl: baseUrlOption, queryFn: queryFnOption, parameters, ...options } = args[0] ?? {};
|
|
11
|
+
const queryClient = qraftOptions.queryClient;
|
|
12
|
+
const baseUrl = baseUrlOption ?? qraftOptions.baseUrl;
|
|
13
|
+
if (queryFnOption && requestFnOption) {
|
|
14
|
+
throw new Error('callQueryClientMethodWithQueryKey: options.queryFn and options.requestFn are mutually exclusive');
|
|
15
|
+
}
|
|
16
|
+
const requestFn = requestFnOption ?? qraftOptions.requestFn;
|
|
12
17
|
if (options.queryKey && parameters) {
|
|
13
18
|
throw new Error('callQueryClientMethodWithQueryKey: options.queryKey and options.parameters are mutually exclusive');
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
const queryFn = options.queryFn ?? (requestFn ? function({ queryKey: [, queryParams], signal, meta, pageParam }) {
|
|
20
|
+
const queryFn = queryFnOption ?? // @ts-expect-error - Too complex union to type
|
|
21
|
+
function({ queryKey: [, queryParams], signal, meta, pageParam }) {
|
|
19
22
|
return requestFn(schema, {
|
|
20
23
|
parameters: infinite ? shelfMerge(2, queryParams, pageParam) : queryParams,
|
|
21
24
|
baseUrl,
|
|
22
25
|
signal,
|
|
23
26
|
meta
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (parameters) {
|
|
27
|
-
// @ts-expect-error - Too complex union to type
|
|
28
|
-
return queryClient[queryFilterMethod]({
|
|
29
|
-
...options,
|
|
30
|
-
// Event if queryFn is undefined, it will override the default queryFn from `setQueryDefaults(...)`
|
|
31
|
-
...queryFn ? {
|
|
32
|
-
queryFn
|
|
33
|
-
} : {},
|
|
34
|
-
queryKey: infinite ? composeInfiniteQueryKey(schema, parameters) : composeQueryKey(schema, parameters)
|
|
35
|
-
});
|
|
36
|
-
}
|
|
27
|
+
}).then(requestFnResponseResolver, requestFnResponseResolver);
|
|
28
|
+
};
|
|
37
29
|
// @ts-expect-error - Too complex union to type
|
|
38
30
|
return queryClient[queryFilterMethod]({
|
|
39
31
|
...options,
|
|
40
|
-
queryFn
|
|
32
|
+
queryFn,
|
|
33
|
+
queryKey: options.queryKey ?? (infinite ? composeInfiniteQueryKey(schema, parameters) : composeQueryKey(schema, parameters))
|
|
41
34
|
});
|
|
42
35
|
}
|
|
43
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callQueryClientFetchMethod.js","sources":["../../../src/lib/callQueryClientFetchMethod.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type { OperationSchema, RequestFn } from './requestFn.js';\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.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
|
|
1
|
+
{"version":3,"file":"callQueryClientFetchMethod.js","sources":["../../../src/lib/callQueryClientFetchMethod.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type { CreateAPIQueryClientOptions } from '../qraftAPIClient.js';\nimport type { OperationSchema, RequestFn } from './requestFn.js';\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.js';\nimport { requestFnResponseResolver } from './requestFnResponseResolver.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 qraftOptions: CreateAPIQueryClientOptions,\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n infinite: boolean,\n args: QueryClientMethodArgs<QFMethod>\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const {\n requestFn: requestFnOption,\n baseUrl: baseUrlOption,\n queryFn: queryFnOption,\n parameters,\n ...options\n } = args[0] ?? {};\n\n const queryClient = qraftOptions.queryClient;\n const baseUrl = baseUrlOption ?? qraftOptions.baseUrl;\n\n if (queryFnOption && requestFnOption) {\n throw new Error(\n 'callQueryClientMethodWithQueryKey: options.queryFn and options.requestFn are mutually exclusive'\n );\n }\n\n const requestFn = requestFnOption ?? qraftOptions.requestFn;\n\n if (options.queryKey && parameters) {\n throw new Error(\n 'callQueryClientMethodWithQueryKey: options.queryKey and options.parameters are mutually exclusive'\n );\n }\n\n const queryFn =\n queryFnOption ??\n // @ts-expect-error - Too complex union to type\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 }).then(requestFnResponseResolver, requestFnResponseResolver);\n };\n\n // @ts-expect-error - Too complex union to type\n return queryClient[queryFilterMethod]({\n ...options,\n queryFn,\n queryKey:\n options.queryKey ??\n (infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters)),\n });\n}\n\ntype QueryClientMethodArgs<QMethod extends keyof QueryClientPrototype> = [\n options: Parameters<QueryClientPrototype[QMethod]>[0] & {\n parameters?: unknown;\n baseUrl?: string;\n requestFn?: RequestFn<unknown, 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","qraftOptions","queryFilterMethod","schema","infinite","args","requestFn","requestFnOption","baseUrl","baseUrlOption","queryFn","queryFnOption","parameters","options","queryClient","Error","queryKey","queryParams","signal","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IAGF,OAAOT,WAAW,CAACZ,iBAAAA,CAAkB,CAAC;AACpC,QAAA,GAAGW,OAAO;AACVH,QAAAA,OAAAA;QACAM,QACEH,EAAAA,OAAAA,CAAQG,QAAQ,KACfZ,QAAAA,GACGoB,wBAAwBrB,MAAQS,EAAAA,UAAAA,CAAAA,GAChCa,eAAgBtB,CAAAA,MAAAA,EAAQS,UAAU,CAAA,CAAA;AAC1C,KAAA,CAAA,CAAA;AACF;;;;"}
|
|
@@ -3,14 +3,12 @@ import { composeMutationFilters } from './composeMutationFilters.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Calls a query client method with mutation filters and options,
|
|
5
5
|
* and automatically composes the `MutationKey` based on the schema and parameters.
|
|
6
|
-
*/ function callQueryClientMethodWithMutationFilters(queryFilterMethod, schema, args) {
|
|
7
|
-
const filters = args
|
|
8
|
-
const queryClient =
|
|
9
|
-
if (!queryClient) throw new Error('queryClient is required');
|
|
10
|
-
if (!queryClient[queryFilterMethod]) throw new Error(`queryClient is invalid, ${queryFilterMethod} method does not exist`);
|
|
6
|
+
*/ function callQueryClientMethodWithMutationFilters(qraftOptions, queryFilterMethod, schema, args) {
|
|
7
|
+
const filters = args[0];
|
|
8
|
+
const queryClient = qraftOptions.queryClient;
|
|
11
9
|
// @ts-expect-error - Too complex to type
|
|
12
10
|
return queryClient[queryFilterMethod](composeMutationFilters(schema, filters), // @ts-expect-error - Argument types are too complex
|
|
13
|
-
...args.slice(1,
|
|
11
|
+
...args.slice(1, args.length));
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export { callQueryClientMethodWithMutationFilters };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callQueryClientMethodWithMutationFilters.js","sources":["../../../src/lib/callQueryClientMethodWithMutationFilters.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type { OperationSchema } from './requestFn.js';\nimport { composeMutationFilters } from './composeMutationFilters.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
|
|
1
|
+
{"version":3,"file":"callQueryClientMethodWithMutationFilters.js","sources":["../../../src/lib/callQueryClientMethodWithMutationFilters.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type { CreateAPIQueryClientOptions } from '../qraftAPIClient.js';\nimport type { OperationSchema } from './requestFn.js';\nimport { composeMutationFilters } from './composeMutationFilters.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 qraftOptions: CreateAPIQueryClientOptions,\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n args: [...Parameters<(typeof QueryClient.prototype)[QFMethod]>, QueryClient]\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const filters = args[0];\n const queryClient = qraftOptions.queryClient;\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, args.length)\n );\n}\n\ntype QueryFiltersMethod<QFMethod extends keyof typeof QueryClient.prototype> =\n QFMethod;\n\ntype QueryFilterMethods = QueryFiltersMethod<'isMutating'>;\n"],"names":["callQueryClientMethodWithMutationFilters","qraftOptions","queryFilterMethod","schema","args","filters","queryClient","composeMutationFilters","slice","length"],"mappings":";;AAKA;;;IAIO,SAASA,wCAGdC,CAAAA,YAAyC,EACzCC,iBAA2B,EAC3BC,MAAuB,EACvBC,IAA4E,EAAA;IAE5E,MAAMC,OAAAA,GAAUD,IAAI,CAAC,CAAE,CAAA,CAAA;IACvB,MAAME,WAAAA,GAAcL,aAAaK,WAAW,CAAA;;AAG5C,IAAA,OAAOA,WAAW,CAACJ,iBAAAA,CAAkB,CACnCK,sBAAuBJ,CAAAA,MAAAA,EAAQE;AAE5BD,IAAAA,GAAAA,IAAAA,CAAKI,KAAK,CAAC,CAAGJ,EAAAA,IAAAA,CAAKK,MAAM,CAAA,CAAA,CAAA;AAEhC;;;;"}
|
|
@@ -3,14 +3,12 @@ import { composeQueryFilters } from './composeQueryFilters.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Calls a query client method with query filters and options,
|
|
5
5
|
* and automatically composes the `QueryKey` based on the schema and parameters.
|
|
6
|
-
*/ function callQueryClientMethodWithQueryFilters(queryFilterMethod, schema, args) {
|
|
7
|
-
const filters = args
|
|
8
|
-
const queryClient =
|
|
9
|
-
if (!queryClient) throw new Error('queryClient is required');
|
|
10
|
-
if (!queryClient[queryFilterMethod]) throw new Error(`queryClient is invalid, ${queryFilterMethod} method does not exist`);
|
|
6
|
+
*/ function callQueryClientMethodWithQueryFilters(qraftOptions, queryFilterMethod, schema, args) {
|
|
7
|
+
const filters = args[0];
|
|
8
|
+
const queryClient = qraftOptions.queryClient;
|
|
11
9
|
// @ts-expect-error - Too complex to type
|
|
12
10
|
return queryClient[queryFilterMethod](composeQueryFilters(schema, filters), // @ts-expect-error - Argument types are too complex
|
|
13
|
-
...args.slice(1,
|
|
11
|
+
...args.slice(1, args.length));
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export { callQueryClientMethodWithQueryFilters };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callQueryClientMethodWithQueryFilters.js","sources":["../../../src/lib/callQueryClientMethodWithQueryFilters.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type { OperationSchema } from './requestFn.js';\nimport { composeQueryFilters } from './composeQueryFilters.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
|
|
1
|
+
{"version":3,"file":"callQueryClientMethodWithQueryFilters.js","sources":["../../../src/lib/callQueryClientMethodWithQueryFilters.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type { CreateAPIQueryClientOptions } from '../qraftAPIClient.js';\nimport type { OperationSchema } from './requestFn.js';\nimport { composeQueryFilters } from './composeQueryFilters.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 qraftOptions: CreateAPIQueryClientOptions,\n queryFilterMethod: QFMethod,\n schema: OperationSchema,\n args: [...Parameters<(typeof QueryClient.prototype)[QFMethod]>, QueryClient]\n): ReturnType<(typeof QueryClient.prototype)[QFMethod]> {\n const filters = args[0];\n const queryClient = qraftOptions.queryClient;\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, args.length)\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","qraftOptions","queryFilterMethod","schema","args","filters","queryClient","composeQueryFilters","slice","length"],"mappings":";;AAKA;;;IAIO,SAASA,qCAGdC,CAAAA,YAAyC,EACzCC,iBAA2B,EAC3BC,MAAuB,EACvBC,IAA4E,EAAA;IAE5E,MAAMC,OAAAA,GAAUD,IAAI,CAAC,CAAE,CAAA,CAAA;IACvB,MAAME,WAAAA,GAAcL,aAAaK,WAAW,CAAA;;AAG5C,IAAA,OAAOA,WAAW,CAACJ,iBAAAA,CAAkB,CACnCK,mBAAoBJ,CAAAA,MAAAA,EAAQE;AAEzBD,IAAAA,GAAAA,IAAAA,CAAKI,KAAK,CAAC,CAAGJ,EAAAA,IAAAA,CAAKK,MAAM,CAAA,CAAA,CAAA;AAEhC;;;;"}
|
|
@@ -4,14 +4,12 @@ import { composeQueryKey } from './composeQueryKey.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Calls a query client method with parameters and options,
|
|
6
6
|
* and automatically composes the `QueryKey` based on the schema and parameters.
|
|
7
|
-
*/ function callQueryClientMethodWithQueryKey(
|
|
8
|
-
const parameters = args
|
|
9
|
-
const queryClient = args[args.length - 1];
|
|
10
|
-
if (!queryClient) throw new Error('queryClient is required');
|
|
11
|
-
if (!queryClient[queryFilterMethod]) throw new Error(`queryClient is invalid, ${queryFilterMethod} method does not exist`);
|
|
7
|
+
*/ function callQueryClientMethodWithQueryKey(qraftOptions, queryClientMethod, schema, infinite, args) {
|
|
8
|
+
const parameters = args[0];
|
|
12
9
|
const queryKey = Array.isArray(parameters) ? parameters : infinite ? composeInfiniteQueryKey(schema, parameters) : composeQueryKey(schema, parameters);
|
|
10
|
+
const queryClient = qraftOptions.queryClient;
|
|
13
11
|
// @ts-expect-error - Too complex to type
|
|
14
|
-
return queryClient[
|
|
12
|
+
return queryClient[queryClientMethod](queryKey, ...args.slice(1, args.length));
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
export { callQueryClientMethodWithQueryKey };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callQueryClientMethodWithQueryKey.js","sources":["../../../src/lib/callQueryClientMethodWithQueryKey.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type { OperationSchema } from './requestFn.js';\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.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
|
|
1
|
+
{"version":3,"file":"callQueryClientMethodWithQueryKey.js","sources":["../../../src/lib/callQueryClientMethodWithQueryKey.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/query-core';\nimport type { CreateAPIQueryClientOptions } from '../qraftAPIClient.js';\nimport type { OperationSchema } from './requestFn.js';\nimport { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';\nimport { composeQueryKey } from './composeQueryKey.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 qraftOptions: CreateAPIQueryClientOptions,\n queryClientMethod: 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[0];\n\n const queryKey = Array.isArray(parameters)\n ? parameters\n : infinite\n ? composeInfiniteQueryKey(schema, parameters)\n : composeQueryKey(schema, parameters);\n\n const queryClient = qraftOptions.queryClient;\n\n // @ts-expect-error - Too complex to type\n return queryClient[queryClientMethod](\n queryKey,\n ...args.slice(1, args.length)\n );\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","qraftOptions","queryClientMethod","schema","infinite","args","parameters","queryKey","Array","isArray","composeInfiniteQueryKey","composeQueryKey","queryClient","slice","length"],"mappings":";;;AAMA;;;IAIO,SAASA,iCAAAA,CAGdC,YAAyC,EACzCC,iBAA2B,EAC3BC,MAAuB,EACvBC,QAAiB,EACjBC,IAA4E,EAAA;IAE5E,MAAMC,UAAAA,GAAaD,IAAI,CAAC,CAAE,CAAA,CAAA;IAE1B,MAAME,QAAAA,GAAWC,KAAMC,CAAAA,OAAO,CAACH,UAAAA,CAAAA,GAC3BA,UACAF,GAAAA,QAAAA,GACEM,uBAAwBP,CAAAA,MAAAA,EAAQG,UAChCK,CAAAA,GAAAA,eAAAA,CAAgBR,MAAQG,EAAAA,UAAAA,CAAAA,CAAAA;IAE9B,MAAMM,WAAAA,GAAcX,aAAaW,WAAW,CAAA;;IAG5C,OAAOA,WAAW,CAACV,iBAAAA,CAAkB,CACnCK,QAAAA,EAAAA,GACGF,KAAKQ,KAAK,CAAC,CAAGR,EAAAA,IAAAA,CAAKS,MAAM,CAAA,CAAA,CAAA;AAEhC;;;;"}
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
const { parameters, headers, body, ...requestInfoRest } = requestInfo;
|
|
37
37
|
const requestBody = options.bodySerializer(requestSchema, requestInfo);
|
|
38
38
|
const baseFetch = options.fetch ?? fetch;
|
|
39
|
-
|
|
39
|
+
return baseFetch(options.urlSerializer(requestSchema, requestInfo), {
|
|
40
40
|
method: requestSchema.method.toUpperCase(),
|
|
41
41
|
body: requestBody,
|
|
42
42
|
headers: mergeHeaders({
|
|
@@ -46,13 +46,7 @@
|
|
|
46
46
|
'Content-Type': null
|
|
47
47
|
} : undefined),
|
|
48
48
|
...requestInfoRest
|
|
49
|
-
});
|
|
50
|
-
// clone response to allow multiple reads
|
|
51
|
-
const clonedResponse = response.clone();
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
throw await getResponseBody(clonedResponse);
|
|
54
|
-
}
|
|
55
|
-
return await getResponseBody(clonedResponse);
|
|
49
|
+
}).then(processResponse).catch(resolveResponse);
|
|
56
50
|
}
|
|
57
51
|
/**
|
|
58
52
|
* Serializes the given schema and request payload into a URL string.
|
|
@@ -166,20 +160,40 @@ function getBodyContentType(body) {
|
|
|
166
160
|
if (typeof body === 'string') return 'text/plain';
|
|
167
161
|
if (!(body instanceof FormData)) return 'application/json';
|
|
168
162
|
}
|
|
169
|
-
async function
|
|
170
|
-
if (response.status === 204 || response.headers.get('Content-Length') === '0') return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
163
|
+
async function processResponse(response) {
|
|
164
|
+
if (response.status === 204 || response.headers.get('Content-Length') === '0') return response.ok ? {
|
|
165
|
+
data: {},
|
|
166
|
+
response
|
|
167
|
+
} : {
|
|
168
|
+
error: {},
|
|
169
|
+
response
|
|
170
|
+
};
|
|
171
|
+
if (isJsonResponse(response)) {
|
|
172
|
+
// clone response before parsing every time to allow multiple reads
|
|
173
|
+
const jsonResponse = response.clone().json();
|
|
174
|
+
return resolveResponse(response, response.ok ? jsonResponse : Promise.reject(await jsonResponse));
|
|
181
175
|
}
|
|
182
|
-
|
|
176
|
+
const jsonResponse = new Promise((resolve, reject)=>// attempt to parse JSON for successful responses, otherwise fail
|
|
177
|
+
response.clone().text().then(JSON.parse).then(resolve, reject));
|
|
178
|
+
return resolveResponse(response, response.ok ? jsonResponse : Promise.reject(await jsonResponse));
|
|
179
|
+
}
|
|
180
|
+
function isJsonResponse(response) {
|
|
181
|
+
const contentType = response.headers.get('Content-Type')?.toLowerCase();
|
|
182
|
+
return contentType?.includes('/json') || contentType?.includes('+json');
|
|
183
|
+
}
|
|
184
|
+
function resolveResponse(responseToReturn, responsePromise) {
|
|
185
|
+
if (!responsePromise) return Promise.reject({
|
|
186
|
+
error: responseToReturn,
|
|
187
|
+
response: undefined,
|
|
188
|
+
data: undefined
|
|
189
|
+
});
|
|
190
|
+
return responsePromise.then((data)=>({
|
|
191
|
+
data,
|
|
192
|
+
response: responseToReturn
|
|
193
|
+
})).catch((error)=>({
|
|
194
|
+
error,
|
|
195
|
+
response: responseToReturn
|
|
196
|
+
}));
|
|
183
197
|
}
|
|
184
198
|
|
|
185
199
|
export { baseRequestFn, bodySerializer, mergeHeaders, requestFn, urlSerializer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestFn.js","sources":["../../../src/lib/requestFn.ts"],"sourcesContent":["/**\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\n/**\n * Serializes the given schema and request payload into a URL string.\n *\n * This function is implemented according to the URI Template standard\n * defined in RFC 6570. It supports the expansion of path and query parameters,\n * correctly handling empty arrays, `null`, and `undefined` values by ignoring\n * them during the expansion process, as specified by the standard.\n *\n * For more information, refer to the official documentation:\n * https://datatracker.ietf.org/doc/html/rfc6570\n *\n * @param schema - The operation schema containing the URL template and method.\n * @param info - The request payload including baseUrl, path parameters, and query parameters.\n * @returns The fully constructed URL string.\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 // 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"],"names":["requestFn","schema","requestInfo","options","baseRequestFn","urlSerializer","bodySerializer","requestSchema","parameters","headers","body","requestInfoRest","requestBody","baseFetch","fetch","response","method","toUpperCase","mergeHeaders","Accept","mediaType","getBodyContentType","header","FormData","undefined","clonedResponse","clone","ok","getResponseBody","info","path","url","replace","substring","group","Object","prototype","hasOwnProperty","call","encodeURI","String","baseUrl","query","getQueryString","params","qs","append","key","value","push","encodeURIComponent","process","Array","isArray","forEach","v","entries","k","length","join","allHeaders","Headers","headerSet","headersIterator","headerKey","headerValue","delete","set","includes","getRequestBodyFormData","Blob","JSON","stringify","Error","ArrayBuffer","URLSearchParams","ReadableStream","formData","filter","_","type","status","get","contentType","toLowerCase","isJSON","json","errorFallbackResponse","catch","text"],"mappings":"AAAA;;;;;;;;;;;;AAYC,IACM,eAAeA,SAAAA,CACpBC,MAAuB,EACvBC,WAA0B,EAC1BC,OAA0B,EAAA;IAE1B,OAAOC,aAAAA,CAAcH,QAAQC,WA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GAAG,CAAC,cAAiBE,CAAAA,EAAAA,WAAAA,EAAAA,CAAAA;AAC1D,IAAA,MAAMC,MACJF,GAAAA,WAAAA,EAAaf,QAAS,CAAA,OAAA,CAAA,IAAYe,aAAaf,QAAS,CAAA,OAAA,CAAA,CAAA;AAE1D,IAAA,IAAIiB,MAAQ,EAAA;;AAEV,QAAA,IAAItE,QAASY,CAAAA,EAAE,EAAE,OAAOZ,SAASuE,IAAI,EAAA,CAAA;AAErC,QAAA,MAAMC,qBAAwBxE,GAAAA,QAAAA,CAASW,KAAK,EAAA,CAAA;AAE5C,QAAA,OAAOX,QAASuE,CAAAA,IAAI,EAAGE,CAAAA,KAAK,CAAC,IAAA;;AAE3B,YAAA,OAAOD,sBAAsBE,IAAI,EAAA,CAAA;AACnC,SAAA,CAAA,CAAA;AACF,KAAA;AAEA,IAAA,OAAO1E,SAAS0E,IAAI,EAAA,CAAA;AACtB;;;;"}
|
|
1
|
+
{"version":3,"file":"requestFn.js","sources":["../../../src/lib/requestFn.ts"],"sourcesContent":["/**\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<TData, TError>(\n schema: OperationSchema,\n requestInfo: RequestFnInfo,\n options?: RequestFnOptions\n): Promise<RequestFnResponse<TData, TError>> {\n return baseRequestFn<TData, TError>(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<TData, TError>(\n requestSchema: OperationSchema,\n requestInfo: RequestFnInfo,\n options: WithRequired<RequestFnOptions, 'urlSerializer' | 'bodySerializer'>\n): Promise<RequestFnResponse<TData, TError>> {\n const { parameters, headers, body, ...requestInfoRest } = requestInfo;\n\n const requestBody = options.bodySerializer(requestSchema, requestInfo);\n\n const baseFetch = options.fetch ?? fetch;\n\n return baseFetch(options.urlSerializer(requestSchema, requestInfo), {\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 the serialized body is FormData; the browser will correctly set Content-Type & boundary expression\n { 'Content-Type': null }\n : undefined\n ),\n ...requestInfoRest,\n })\n .then(processResponse as typeof processResponse<TData, TError>)\n .catch(resolveResponse as typeof resolveResponse<TData, TError>);\n}\n\n/**\n * Serializes the given schema and request payload into a URL string.\n *\n * This function is implemented according to the URI Template standard\n * defined in RFC 6570. It supports the expansion of path and query parameters,\n * correctly handling empty arrays, `null`, and `undefined` values by ignoring\n * them during the expansion process, as specified by the standard.\n *\n * For more information, refer to the official documentation:\n * https://datatracker.ietf.org/doc/html/rfc6570\n *\n * @param schema - The operation schema containing the URL template and method.\n * @param info - The request payload including baseUrl, path parameters, and query parameters.\n * @returns The fully constructed URL string.\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 processResponse<TData, TError>(\n response: Response\n): Promise<RequestFnResponse<TData, TError>> {\n if (response.status === 204 || response.headers.get('Content-Length') === '0')\n return (\n response.ok ? { data: {}, response } : { error: {}, response }\n ) as RequestFnResponse<TData, TError>;\n\n if (isJsonResponse(response)) {\n // clone response before parsing every time to allow multiple reads\n const jsonResponse = response.clone().json();\n return resolveResponse(\n response,\n response.ok ? jsonResponse : Promise.reject(await jsonResponse)\n );\n }\n\n const jsonResponse = new Promise<TData>((resolve, reject) =>\n // attempt to parse JSON for successful responses, otherwise fail\n response.clone().text().then(JSON.parse).then(resolve, reject)\n );\n\n return resolveResponse(\n response,\n response.ok ? jsonResponse : Promise.reject(await jsonResponse)\n );\n}\n\nfunction isJsonResponse(response: Response) {\n const contentType = response.headers.get('Content-Type')?.toLowerCase();\n return contentType?.includes('/json') || contentType?.includes('+json');\n}\n\nfunction resolveResponse<TData, TError>(\n error: Error\n): Promise<RequestFnResponse<TData, TError>>;\nfunction resolveResponse<TData, TError>(\n responseToReturn: Response,\n responsePromise: Promise<TData>\n): Promise<RequestFnResponse<TData, TError>>;\nfunction resolveResponse<TData, TError>(\n responseToReturn: Response | Error,\n responsePromise?: Promise<TData>\n): Promise<RequestFnResponse<TData, TError>> {\n if (!responsePromise)\n return Promise.reject({\n error: responseToReturn,\n response: undefined,\n data: undefined,\n });\n\n return responsePromise\n .then(\n (data) =>\n ({ data, response: responseToReturn }) as RequestFnResponse<\n TData,\n TError\n >\n )\n .catch(\n (error) =>\n ({ error, response: responseToReturn }) as RequestFnResponse<\n TData,\n TError\n >\n );\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;\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<TData, TError> = typeof requestFn<TData, TError>;\n\nexport type RequestFnResponse<TData, TError> =\n | {\n data?: TData;\n response: Response;\n error?: never;\n }\n | {\n // server error\n error?: TError | Error;\n response: Response;\n data?: never;\n }\n | {\n // network error\n error?: Error;\n data?: never;\n response?: never;\n };\n\ntype WithRequired<T, K extends keyof T> = T & {\n [_ in K]: {};\n};\n"],"names":["requestFn","schema","requestInfo","options","baseRequestFn","urlSerializer","bodySerializer","requestSchema","parameters","headers","body","requestInfoRest","requestBody","baseFetch","fetch","method","toUpperCase","mergeHeaders","Accept","mediaType","getBodyContentType","header","FormData","undefined","then","processResponse","catch","resolveResponse","info","path","url","replace","substring","group","Object","prototype","hasOwnProperty","call","encodeURI","String","baseUrl","query","getQueryString","params","qs","append","key","value","push","encodeURIComponent","process","Array","isArray","forEach","v","entries","k","length","join","allHeaders","Headers","headerSet","headersIterator","headerKey","headerValue","delete","set","includes","getRequestBodyFormData","Blob","JSON","stringify","Error","ArrayBuffer","URLSearchParams","ReadableStream","formData","filter","_","type","response","status","get","ok","data","error","isJsonResponse","jsonResponse","clone","json","Promise","reject","resolve","text","parse","contentType","toLowerCase","responseToReturn","responsePromise"],"mappings":"AAAA;;;;;;;;;;;;AAYC,IACM,eAAeA,SAAAA,CACpBC,MAAuB,EACvBC,WAA0B,EAC1BC,OAA0B,EAAA;IAE1B,OAAOC,aAAAA,CAA6BH,QAAQC,WAAa,EAAA;AACvDG,QAAAA,aAAAA;AACAC,QAAAA,cAAAA;AACA,QAAA,GAAGH,OAAO;AACZ,KAAA,CAAA,CAAA;AACF,CAAA;AA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AA,CAAA,CAAA;AAK7C;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestFnResponseResolver.js","sources":["../../../src/lib/requestFnResponseResolver.ts"],"sourcesContent":["import { RequestFnResponse } from './requestFn.js';\n\nexport function requestFnResponseResolver<TData, TError>(\n requestFnResponse: RequestFnResponse<TData, TError>\n): TData | undefined {\n if ('error' in requestFnResponse) throw requestFnResponse.error;\n return requestFnResponse.data;\n}\n"],"names":["requestFnResponseResolver","requestFnResponse","error","data"],"mappings":"AAEO,SAASA,0BACdC,iBAAmD,EAAA;AAEnD,IAAA,IAAI,OAAWA,IAAAA,iBAAAA,EAAmB,MAAMA,iBAAAA,CAAkBC,KAAK,CAAA;AAC/D,IAAA,OAAOD,kBAAkBE,IAAI,CAAA;AAC/B;;;;"}
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useContext } from 'react';
|
|
3
|
-
import { QraftContext } from '../QraftContext.js';
|
|
4
2
|
import { composeInfiniteQueryKey } from './composeInfiniteQueryKey.js';
|
|
5
3
|
import { composeQueryKey } from './composeQueryKey.js';
|
|
4
|
+
import { requestFnResponseResolver } from './requestFnResponseResolver.js';
|
|
6
5
|
import { shelfMerge } from './shelfMerge.js';
|
|
7
|
-
import { useQueryClient } from './useQueryClient.js';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Composes the options for useQuery, useInfiniteQuery, useSuspenseQuery, and useSuspenseQueries.
|
|
11
9
|
* @internal
|
|
12
10
|
*/ function useComposeUseQueryOptions(qraftOptions, schema, args, infinite) {
|
|
13
|
-
const [parameters, options
|
|
14
|
-
const contextValue = useContext(qraftOptions?.context ?? QraftContext);
|
|
11
|
+
const [parameters, options] = args;
|
|
15
12
|
const queryFn = options?.queryFn ?? // @ts-expect-error - Too complex to type
|
|
16
13
|
function({ queryKey: [, queryParams], signal, meta, pageParam }) {
|
|
17
|
-
|
|
18
|
-
return contextValue.requestFn(schema, {
|
|
14
|
+
return qraftOptions.requestFn(schema, {
|
|
19
15
|
// @ts-expect-error - Too complex to type
|
|
20
16
|
parameters: infinite ? shelfMerge(2, queryParams, pageParam) : queryParams,
|
|
21
|
-
baseUrl:
|
|
17
|
+
baseUrl: qraftOptions.baseUrl,
|
|
22
18
|
signal,
|
|
23
19
|
meta
|
|
24
|
-
});
|
|
20
|
+
}).then(requestFnResponseResolver, requestFnResponseResolver);
|
|
25
21
|
};
|
|
26
22
|
const queryKey = Array.isArray(parameters) ? parameters : infinite ? composeInfiniteQueryKey(schema, parameters) : composeQueryKey(schema, parameters);
|
|
27
23
|
return [
|
|
@@ -30,7 +26,7 @@ import { useQueryClient } from './useQueryClient.js';
|
|
|
30
26
|
queryFn,
|
|
31
27
|
queryKey
|
|
32
28
|
},
|
|
33
|
-
|
|
29
|
+
qraftOptions.queryClient
|
|
34
30
|
];
|
|
35
31
|
}
|
|
36
32
|
|