@openapi-qraft/react 1.11.0-beta.3 → 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 +6 -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 -0
- package/dist/cjs/index.cjs.map +1 -0
- 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 -7
- package/dist/esm/QraftContext.js.map +1 -1
- package/dist/esm/Unstable_QraftSecureRequestFn.js +174 -176
- package/dist/esm/Unstable_QraftSecureRequestFn.js.map +1 -1
- package/dist/esm/callbacks/cancelQueries.js +6 -10
- package/dist/esm/callbacks/cancelQueries.js.map +1 -1
- package/dist/esm/callbacks/fetchInfiniteQuery.js +7 -12
- package/dist/esm/callbacks/fetchInfiniteQuery.js.map +1 -1
- package/dist/esm/callbacks/fetchQuery.js +7 -12
- package/dist/esm/callbacks/fetchQuery.js.map +1 -1
- package/dist/esm/callbacks/getInfiniteQueryData.js +6 -11
- package/dist/esm/callbacks/getInfiniteQueryData.js.map +1 -1
- package/dist/esm/callbacks/getInfiniteQueryKey.js +7 -7
- package/dist/esm/callbacks/getInfiniteQueryKey.js.map +1 -1
- package/dist/esm/callbacks/getInfiniteQueryState.js +6 -11
- package/dist/esm/callbacks/getInfiniteQueryState.js.map +1 -1
- package/dist/esm/callbacks/getMutationKey.js +7 -7
- package/dist/esm/callbacks/getMutationKey.js.map +1 -1
- package/dist/esm/callbacks/getQueriesData.js +6 -10
- package/dist/esm/callbacks/getQueriesData.js.map +1 -1
- package/dist/esm/callbacks/getQueryData.js +6 -11
- package/dist/esm/callbacks/getQueryData.js.map +1 -1
- package/dist/esm/callbacks/getQueryKey.js +7 -7
- package/dist/esm/callbacks/getQueryKey.js.map +1 -1
- package/dist/esm/callbacks/getQueryState.js +6 -11
- package/dist/esm/callbacks/getQueryState.js.map +1 -1
- package/dist/esm/callbacks/index.js +36 -73
- package/dist/esm/callbacks/index.js.map +1 -1
- package/dist/esm/callbacks/invalidateQueries.js +6 -10
- package/dist/esm/callbacks/invalidateQueries.js.map +1 -1
- package/dist/esm/callbacks/isFetching.js +6 -10
- package/dist/esm/callbacks/isFetching.js.map +1 -1
- package/dist/esm/callbacks/isMutating.js +6 -10
- package/dist/esm/callbacks/isMutating.js.map +1 -1
- package/dist/esm/callbacks/mutationFn.js +9 -10
- package/dist/esm/callbacks/mutationFn.js.map +1 -1
- package/dist/esm/callbacks/operationInvokeFn.js +19 -16
- package/dist/esm/callbacks/operationInvokeFn.js.map +1 -1
- package/dist/esm/callbacks/prefetchInfiniteQuery.js +7 -12
- package/dist/esm/callbacks/prefetchInfiniteQuery.js.map +1 -1
- package/dist/esm/callbacks/prefetchQuery.js +7 -12
- package/dist/esm/callbacks/prefetchQuery.js.map +1 -1
- package/dist/esm/callbacks/queryFn.js +10 -14
- package/dist/esm/callbacks/queryFn.js.map +1 -1
- package/dist/esm/callbacks/refetchQueries.js +6 -10
- package/dist/esm/callbacks/refetchQueries.js.map +1 -1
- package/dist/esm/callbacks/removeQueries.js +6 -10
- package/dist/esm/callbacks/removeQueries.js.map +1 -1
- package/dist/esm/callbacks/resetQueries.js +6 -10
- package/dist/esm/callbacks/resetQueries.js.map +1 -1
- package/dist/esm/callbacks/setInfiniteQueryData.js +6 -11
- package/dist/esm/callbacks/setInfiniteQueryData.js.map +1 -1
- package/dist/esm/callbacks/setQueriesData.js +6 -10
- package/dist/esm/callbacks/setQueriesData.js.map +1 -1
- package/dist/esm/callbacks/setQueryData.js +6 -11
- package/dist/esm/callbacks/setQueryData.js.map +1 -1
- package/dist/esm/callbacks/useInfiniteQuery.js +10 -13
- package/dist/esm/callbacks/useInfiniteQuery.js.map +1 -1
- package/dist/esm/callbacks/useIsFetching.js +11 -14
- package/dist/esm/callbacks/useIsFetching.js.map +1 -1
- package/dist/esm/callbacks/useIsMutating.js +11 -16
- package/dist/esm/callbacks/useIsMutating.js.map +1 -1
- package/dist/esm/callbacks/useMutation.js +34 -43
- package/dist/esm/callbacks/useMutation.js.map +1 -1
- package/dist/esm/callbacks/useMutationState.js +14 -19
- package/dist/esm/callbacks/useMutationState.js.map +1 -1
- package/dist/esm/callbacks/useQueries.js +38 -46
- package/dist/esm/callbacks/useQueries.js.map +1 -1
- package/dist/esm/callbacks/useQuery.js +10 -13
- package/dist/esm/callbacks/useQuery.js.map +1 -1
- package/dist/esm/callbacks/useSuspenseInfiniteQuery.js +10 -13
- package/dist/esm/callbacks/useSuspenseInfiniteQuery.js.map +1 -1
- package/dist/esm/callbacks/useSuspenseQueries.js +38 -46
- package/dist/esm/callbacks/useSuspenseQueries.js.map +1 -1
- package/dist/esm/callbacks/useSuspenseQuery.js +10 -13
- package/dist/esm/callbacks/useSuspenseQuery.js.map +1 -1
- package/dist/esm/index.js +7 -29
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/callQueryClientFetchMethod.js +41 -41
- package/dist/esm/lib/callQueryClientFetchMethod.js.map +1 -1
- package/dist/esm/lib/callQueryClientMethodWithMutationFilters.js +16 -17
- package/dist/esm/lib/callQueryClientMethodWithMutationFilters.js.map +1 -1
- package/dist/esm/lib/callQueryClientMethodWithQueryFilters.js +16 -17
- package/dist/esm/lib/callQueryClientMethodWithQueryFilters.js.map +1 -1
- package/dist/esm/lib/callQueryClientMethodWithQueryKey.js +17 -16
- package/dist/esm/lib/callQueryClientMethodWithQueryKey.js.map +1 -1
- package/dist/esm/lib/composeBaseQueryKey.js +10 -8
- package/dist/esm/lib/composeBaseQueryKey.js.map +1 -1
- package/dist/esm/lib/composeInfiniteQueryKey.js +6 -6
- package/dist/esm/lib/composeInfiniteQueryKey.js.map +1 -1
- package/dist/esm/lib/composeMutationFilters.js +31 -28
- package/dist/esm/lib/composeMutationFilters.js.map +1 -1
- package/dist/esm/lib/composeMutationKey.js +22 -23
- package/dist/esm/lib/composeMutationKey.js.map +1 -1
- package/dist/esm/lib/composeQueryFilters.js +33 -30
- package/dist/esm/lib/composeQueryFilters.js.map +1 -1
- package/dist/esm/lib/composeQueryKey.js +6 -6
- package/dist/esm/lib/composeQueryKey.js.map +1 -1
- package/dist/esm/lib/createRecursiveProxy.js +30 -22
- package/dist/esm/lib/createRecursiveProxy.js.map +1 -1
- package/dist/esm/lib/jwt-decode/index.js +49 -56
- package/dist/esm/lib/jwt-decode/index.js.map +1 -1
- package/dist/esm/lib/requestFn.js +156 -155
- package/dist/esm/lib/requestFn.js.map +1 -1
- package/dist/esm/lib/shelfMerge.js +27 -28
- package/dist/esm/lib/shelfMerge.js.map +1 -1
- package/dist/esm/lib/useComposeUseQueryOptions.js +37 -31
- package/dist/esm/lib/useComposeUseQueryOptions.js.map +1 -1
- package/dist/esm/lib/useQueryClient.js +15 -15
- package/dist/esm/lib/useQueryClient.js.map +1 -1
- package/dist/esm/qraftAPIClient.js +40 -47
- package/dist/esm/qraftAPIClient.js.map +1 -1
- package/package.json +9 -15
- package/dist/cjs/QraftContext.js +0 -31
- package/dist/cjs/QraftContext.js.map +0 -1
- package/dist/cjs/ServiceOperation.js +0 -17
- package/dist/cjs/ServiceOperation.js.map +0 -1
- package/dist/cjs/Unstable_QraftSecureRequestFn.js +0 -214
- package/dist/cjs/Unstable_QraftSecureRequestFn.js.map +0 -1
- package/dist/cjs/callbacks/cancelQueries.js +0 -36
- package/dist/cjs/callbacks/cancelQueries.js.map +0 -1
- package/dist/cjs/callbacks/fetchInfiniteQuery.js +0 -37
- package/dist/cjs/callbacks/fetchInfiniteQuery.js.map +0 -1
- package/dist/cjs/callbacks/fetchQuery.js +0 -37
- package/dist/cjs/callbacks/fetchQuery.js.map +0 -1
- package/dist/cjs/callbacks/getInfiniteQueryData.js +0 -37
- package/dist/cjs/callbacks/getInfiniteQueryData.js.map +0 -1
- package/dist/cjs/callbacks/getInfiniteQueryKey.js +0 -32
- package/dist/cjs/callbacks/getInfiniteQueryKey.js.map +0 -1
- package/dist/cjs/callbacks/getInfiniteQueryState.js +0 -37
- package/dist/cjs/callbacks/getInfiniteQueryState.js.map +0 -1
- package/dist/cjs/callbacks/getMutationKey.js +0 -32
- package/dist/cjs/callbacks/getMutationKey.js.map +0 -1
- package/dist/cjs/callbacks/getQueriesData.js +0 -36
- package/dist/cjs/callbacks/getQueriesData.js.map +0 -1
- package/dist/cjs/callbacks/getQueryData.js +0 -37
- package/dist/cjs/callbacks/getQueryData.js.map +0 -1
- package/dist/cjs/callbacks/getQueryKey.js +0 -32
- package/dist/cjs/callbacks/getQueryKey.js.map +0 -1
- package/dist/cjs/callbacks/getQueryState.js +0 -37
- package/dist/cjs/callbacks/getQueryState.js.map +0 -1
- package/dist/cjs/callbacks/index.js +0 -131
- package/dist/cjs/callbacks/index.js.map +0 -1
- package/dist/cjs/callbacks/invalidateQueries.js +0 -36
- package/dist/cjs/callbacks/invalidateQueries.js.map +0 -1
- package/dist/cjs/callbacks/isFetching.js +0 -36
- package/dist/cjs/callbacks/isFetching.js.map +0 -1
- package/dist/cjs/callbacks/isMutating.js +0 -36
- package/dist/cjs/callbacks/isMutating.js.map +0 -1
- package/dist/cjs/callbacks/mutationFn.js +0 -35
- package/dist/cjs/callbacks/mutationFn.js.map +0 -1
- package/dist/cjs/callbacks/operationInvokeFn.js +0 -41
- package/dist/cjs/callbacks/operationInvokeFn.js.map +0 -1
- package/dist/cjs/callbacks/prefetchInfiniteQuery.js +0 -37
- package/dist/cjs/callbacks/prefetchInfiniteQuery.js.map +0 -1
- package/dist/cjs/callbacks/prefetchQuery.js +0 -37
- package/dist/cjs/callbacks/prefetchQuery.js.map +0 -1
- package/dist/cjs/callbacks/queryFn.js +0 -39
- package/dist/cjs/callbacks/queryFn.js.map +0 -1
- package/dist/cjs/callbacks/refetchQueries.js +0 -36
- package/dist/cjs/callbacks/refetchQueries.js.map +0 -1
- package/dist/cjs/callbacks/removeQueries.js +0 -36
- package/dist/cjs/callbacks/removeQueries.js.map +0 -1
- package/dist/cjs/callbacks/resetQueries.js +0 -36
- package/dist/cjs/callbacks/resetQueries.js.map +0 -1
- package/dist/cjs/callbacks/setInfiniteQueryData.js +0 -37
- package/dist/cjs/callbacks/setInfiniteQueryData.js.map +0 -1
- package/dist/cjs/callbacks/setQueriesData.js +0 -36
- package/dist/cjs/callbacks/setQueriesData.js.map +0 -1
- package/dist/cjs/callbacks/setQueryData.js +0 -37
- package/dist/cjs/callbacks/setQueryData.js.map +0 -1
- package/dist/cjs/callbacks/useInfiniteQuery.js +0 -36
- package/dist/cjs/callbacks/useInfiniteQuery.js.map +0 -1
- package/dist/cjs/callbacks/useIsFetching.js +0 -39
- package/dist/cjs/callbacks/useIsFetching.js.map +0 -1
- package/dist/cjs/callbacks/useIsMutating.js +0 -39
- package/dist/cjs/callbacks/useIsMutating.js.map +0 -1
- package/dist/cjs/callbacks/useMutation.js +0 -66
- package/dist/cjs/callbacks/useMutation.js.map +0 -1
- package/dist/cjs/callbacks/useMutationState.js +0 -42
- package/dist/cjs/callbacks/useMutationState.js.map +0 -1
- package/dist/cjs/callbacks/useQueries.js +0 -69
- package/dist/cjs/callbacks/useQueries.js.map +0 -1
- package/dist/cjs/callbacks/useQuery.js +0 -36
- package/dist/cjs/callbacks/useQuery.js.map +0 -1
- package/dist/cjs/callbacks/useSuspenseInfiniteQuery.js +0 -36
- package/dist/cjs/callbacks/useSuspenseInfiniteQuery.js.map +0 -1
- package/dist/cjs/callbacks/useSuspenseQueries.js +0 -69
- package/dist/cjs/callbacks/useSuspenseQueries.js.map +0 -1
- package/dist/cjs/callbacks/useSuspenseQuery.js +0 -36
- package/dist/cjs/callbacks/useSuspenseQuery.js.map +0 -1
- package/dist/cjs/index.js +0 -63
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/lib/PartialParameters.type.js +0 -17
- package/dist/cjs/lib/PartialParameters.type.js.map +0 -1
- package/dist/cjs/lib/callQueryClientFetchMethod.js +0 -69
- package/dist/cjs/lib/callQueryClientFetchMethod.js.map +0 -1
- package/dist/cjs/lib/callQueryClientMethodWithMutationFilters.js +0 -42
- package/dist/cjs/lib/callQueryClientMethodWithMutationFilters.js.map +0 -1
- package/dist/cjs/lib/callQueryClientMethodWithQueryFilters.js +0 -42
- package/dist/cjs/lib/callQueryClientMethodWithQueryFilters.js.map +0 -1
- package/dist/cjs/lib/callQueryClientMethodWithQueryKey.js +0 -41
- package/dist/cjs/lib/callQueryClientMethodWithQueryKey.js.map +0 -1
- package/dist/cjs/lib/composeBaseQueryKey.js +0 -34
- package/dist/cjs/lib/composeBaseQueryKey.js.map +0 -1
- package/dist/cjs/lib/composeInfiniteQueryKey.js +0 -32
- package/dist/cjs/lib/composeInfiniteQueryKey.js.map +0 -1
- package/dist/cjs/lib/composeMutationFilters.js +0 -55
- package/dist/cjs/lib/composeMutationFilters.js.map +0 -1
- package/dist/cjs/lib/composeMutationKey.js +0 -52
- package/dist/cjs/lib/composeMutationKey.js.map +0 -1
- package/dist/cjs/lib/composeQueryFilters.js +0 -57
- package/dist/cjs/lib/composeQueryFilters.js.map +0 -1
- package/dist/cjs/lib/composeQueryKey.js +0 -32
- package/dist/cjs/lib/composeQueryKey.js.map +0 -1
- package/dist/cjs/lib/createRecursiveProxy.js +0 -49
- package/dist/cjs/lib/createRecursiveProxy.js.map +0 -1
- package/dist/cjs/lib/jwt-decode/index.js +0 -91
- package/dist/cjs/lib/jwt-decode/index.js.map +0 -1
- package/dist/cjs/lib/requestFn.js +0 -202
- package/dist/cjs/lib/requestFn.js.map +0 -1
- package/dist/cjs/lib/shelfMerge.js +0 -53
- package/dist/cjs/lib/shelfMerge.js.map +0 -1
- package/dist/cjs/lib/useComposeUseQueryOptions.js +0 -56
- package/dist/cjs/lib/useComposeUseQueryOptions.js.map +0 -1
- package/dist/cjs/lib/useQueryClient.js +0 -38
- package/dist/cjs/lib/useQueryClient.js.map +0 -1
- package/dist/cjs/qraftAPIClient.js +0 -77
- package/dist/cjs/qraftAPIClient.js.map +0 -1
- package/dist/cjs/service-operation/OperationInfiniteData.js +0 -17
- package/dist/cjs/service-operation/OperationInfiniteData.js.map +0 -1
- package/dist/cjs/service-operation/QueryFilters.js +0 -17
- package/dist/cjs/service-operation/QueryFilters.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperation.js +0 -17
- package/dist/cjs/service-operation/ServiceOperation.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationCancelQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationCancelQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationFetchInfiniteQuery.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationFetchInfiniteQuery.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationFetchQuery.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationFetchQuery.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationGetInfiniteQueryData.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationGetInfiniteQueryData.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationGetQueriesData.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationGetQueriesData.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationGetQueryData.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationGetQueryData.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationGetQueryState.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationGetQueryState.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationInvalidateQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationInvalidateQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationIsFetchingQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationIsFetchingQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationIsMutatingQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationIsMutatingQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationKey.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationKey.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationMutationFn.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationMutationFn.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationQueryFn.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationQueryFn.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationRefetchQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationRefetchQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationRemoveQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationRemoveQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationResetQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationResetQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationSetInfiniteQueryData.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationSetInfiniteQueryData.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationSetQueriesData.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationSetQueriesData.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationSetQueryData.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationSetQueryData.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseInfiniteQuery.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseInfiniteQuery.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseIsFetchingQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseIsFetchingQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseIsMutating.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseIsMutating.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseMutation.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseMutation.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseMutationState.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseMutationState.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseQuery.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseQuery.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseSuspenseInfiniteQuery.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseSuspenseInfiniteQuery.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseSuspenseQueries.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseSuspenseQueries.js.map +0 -1
- package/dist/cjs/service-operation/ServiceOperationUseSuspenseQueryQuery.js +0 -17
- package/dist/cjs/service-operation/ServiceOperationUseSuspenseQueryQuery.js.map +0 -1
- package/dist/cjs/service-operation/index.js +0 -17
- package/dist/cjs/service-operation/index.js.map +0 -1
- package/dist/esm/ServiceOperation.js +0 -1
- package/dist/esm/ServiceOperation.js.map +0 -1
- package/dist/esm/lib/PartialParameters.type.js +0 -1
- package/dist/esm/lib/PartialParameters.type.js.map +0 -1
- package/dist/esm/service-operation/OperationInfiniteData.js +0 -1
- package/dist/esm/service-operation/OperationInfiniteData.js.map +0 -1
- package/dist/esm/service-operation/QueryFilters.js +0 -1
- package/dist/esm/service-operation/QueryFilters.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperation.js +0 -1
- package/dist/esm/service-operation/ServiceOperation.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationCancelQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationCancelQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationFetchInfiniteQuery.js +0 -1
- package/dist/esm/service-operation/ServiceOperationFetchInfiniteQuery.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationFetchQuery.js +0 -1
- package/dist/esm/service-operation/ServiceOperationFetchQuery.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationGetInfiniteQueryData.js +0 -1
- package/dist/esm/service-operation/ServiceOperationGetInfiniteQueryData.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationGetQueriesData.js +0 -1
- package/dist/esm/service-operation/ServiceOperationGetQueriesData.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationGetQueryData.js +0 -1
- package/dist/esm/service-operation/ServiceOperationGetQueryData.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationGetQueryState.js +0 -1
- package/dist/esm/service-operation/ServiceOperationGetQueryState.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationInvalidateQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationInvalidateQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationIsFetchingQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationIsFetchingQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationIsMutatingQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationIsMutatingQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationKey.js +0 -1
- package/dist/esm/service-operation/ServiceOperationKey.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationMutationFn.js +0 -1
- package/dist/esm/service-operation/ServiceOperationMutationFn.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationQueryFn.js +0 -1
- package/dist/esm/service-operation/ServiceOperationQueryFn.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationRefetchQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationRefetchQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationRemoveQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationRemoveQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationResetQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationResetQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationSetInfiniteQueryData.js +0 -1
- package/dist/esm/service-operation/ServiceOperationSetInfiniteQueryData.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationSetQueriesData.js +0 -1
- package/dist/esm/service-operation/ServiceOperationSetQueriesData.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationSetQueryData.js +0 -1
- package/dist/esm/service-operation/ServiceOperationSetQueryData.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseInfiniteQuery.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseInfiniteQuery.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseIsFetchingQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseIsFetchingQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseIsMutating.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseIsMutating.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseMutation.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseMutation.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseMutationState.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseMutationState.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseQuery.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseQuery.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseSuspenseInfiniteQuery.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseSuspenseInfiniteQuery.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseSuspenseQueries.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseSuspenseQueries.js.map +0 -1
- package/dist/esm/service-operation/ServiceOperationUseSuspenseQueryQuery.js +0 -1
- package/dist/esm/service-operation/ServiceOperationUseSuspenseQueryQuery.js.map +0 -1
- package/dist/esm/service-operation/index.js +0 -1
- package/dist/esm/service-operation/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/useQueryClient.ts"],"sourcesContent":["'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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQueryClient.js","sources":["../../../src/lib/useQueryClient.ts"],"sourcesContent":["'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"],"names":["useQueryClient","qraftOptions","queryClient","queryClientByContext","useContext","context","QraftContext","useQueryClientTanstack"],"mappings":";;;;;AAYA,CAAA,CAAA,CAAA;;;;AAIC,CAAA,CAAA,CAAA,CACM,SAASA,CACdC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA4C,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAC5CC,WAAoC,CAAA,CAAA,CAAA;AAEpC,CAAA,CAAA,CAAA,CAAA,CAAMC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAuBC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAC3BH,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAcI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAWC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CACxBJ,CAAAA,CAAAA,CAAAA,WAAAA,CAAAA;AAEH,CAAA,CAAA,CAAA,CAAA,OAAOK,iBAAuBL,WAAeC,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;AAC/C,CAAA;;"}
|
|
@@ -1,53 +1,46 @@
|
|
|
1
|
-
import { createRecursiveProxy } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function getCallback(getPath, key) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!isServiceOperation(serviceOperation))
|
|
17
|
-
throw new Error(`Service operation not found: ${path.join(".")}`);
|
|
18
|
-
return callbacks[callbackName](
|
|
19
|
-
options,
|
|
20
|
-
serviceOperation.schema,
|
|
21
|
-
args
|
|
22
|
-
);
|
|
23
|
-
},
|
|
24
|
-
[]
|
|
25
|
-
);
|
|
1
|
+
import { createRecursiveProxy } from './lib/createRecursiveProxy.js';
|
|
2
|
+
|
|
3
|
+
const qraftAPIClient = (services, callbacks, options)=>{
|
|
4
|
+
return createRecursiveProxy(function getCallback(getPath, key) {
|
|
5
|
+
if (getPath.length !== 2 || key !== 'schema') return; // todo::maybe return callback?
|
|
6
|
+
const serviceOperation = getByPath(services, getPath);
|
|
7
|
+
if (!isServiceOperation(serviceOperation)) throw new Error(`Service operation not found: ${getPath.join('.')}`);
|
|
8
|
+
return serviceOperation.schema;
|
|
9
|
+
}, function applyCallback(applyPath, args) {
|
|
10
|
+
const { path, callbackName } = extractCallbackDetails(applyPath);
|
|
11
|
+
if (!(callbackName in callbacks)) throw new Error(`Function ${callbackName} is not supported`);
|
|
12
|
+
const serviceOperation = getByPath(services, path);
|
|
13
|
+
if (!isServiceOperation(serviceOperation)) throw new Error(`Service operation not found: ${path.join('.')}`);
|
|
14
|
+
return callbacks[callbackName](options, serviceOperation.schema, args);
|
|
15
|
+
}, []);
|
|
26
16
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Extracts Callback details from the applyPath
|
|
19
|
+
* @param applyPath
|
|
20
|
+
*/ function extractCallbackDetails(applyPath) {
|
|
21
|
+
// <service>.<operation>()
|
|
22
|
+
if (applyPath.length === 2) {
|
|
23
|
+
return {
|
|
24
|
+
path: applyPath,
|
|
25
|
+
callbackName: 'operationInvokeFn'
|
|
26
|
+
};
|
|
27
|
+
} else {
|
|
28
|
+
// <service>.<operation>.<method>()
|
|
29
|
+
return {
|
|
30
|
+
path: applyPath.slice(0, -1),
|
|
31
|
+
// The last arg is for instance `.useMutation` or `.useQuery()`
|
|
32
|
+
callbackName: applyPath[applyPath.length - 1]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
40
35
|
}
|
|
41
36
|
function isServiceOperation(input) {
|
|
42
|
-
|
|
37
|
+
return input !== null && typeof input === 'object' && 'schema' in input;
|
|
43
38
|
}
|
|
44
39
|
function getByPath(obj, path) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, obj);
|
|
40
|
+
return path.reduce((acc, key)=>{
|
|
41
|
+
if (acc && typeof acc === 'object' && key in acc) return acc[key];
|
|
42
|
+
}, obj);
|
|
49
43
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=qraftAPIClient.js.map
|
|
44
|
+
|
|
45
|
+
export { qraftAPIClient };
|
|
46
|
+
//# sourceMappingURL=qraftAPIClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/qraftAPIClient.ts"],"sourcesContent":["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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"qraftAPIClient.js","sources":["../../src/qraftAPIClient.ts"],"sourcesContent":["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"],"names":["qraftAPIClient","services","callbacks","options","createRecursiveProxy","getCallback","getPath","key","length","serviceOperation","getByPath","isServiceOperation","Error","join","schema","applyCallback","applyPath","args","path","callbackName","extractCallbackDetails","slice","input","obj","reduce","acc"],"mappings":";;AAWaA,MAAAA,cAAAA,GAAiB,CAI5BC,QAAAA,EACAC,SACAC,EAAAA,OAAAA,GAAAA;AAEA,IAAA,OAAOC,oBACL,CAAA,SAASC,WAAYC,CAAAA,OAAO,EAAEC,GAAG,EAAA;AAC/B,QAAA,IAAID,QAAQE,MAAM,KAAK,KAAKD,GAAQ,KAAA,QAAA,EAAU;QAE9C,MAAME,gBAAAA,GAAmBC,UAAUT,QAAUK,EAAAA,OAAAA,CAAAA,CAAAA;AAC7C,QAAA,IAAI,CAACK,kBAAAA,CAAmBF,gBACtB,CAAA,EAAA,MAAM,IAAIG,KAAAA,CAAM,CAAC,6BAA6B,EAAEN,OAAAA,CAAQO,IAAI,CAAC,KAAK,CAAC,CAAA,CAAA;AACrE,QAAA,OAAOJ,iBAAiBK,MAAM,CAAA;AAChC,KAAA,EACA,SAASC,aAAAA,CAAcC,SAAS,EAAEC,IAAI,EAAA;AACpC,QAAA,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGC,sBAAuBJ,CAAAA,SAAAA,CAAAA,CAAAA;AAEtD,QAAA,IAAI,EAAEG,YAAgBjB,IAAAA,SAAQ,CAC5B,EAAA,MAAM,IAAIU,KAAAA,CAAM,CAAC,SAAS,EAAEO,YAAAA,CAAa,iBAAiB,CAAC,CAAA,CAAA;QAE7D,MAAMV,gBAAAA,GAAmBC,UAAUT,QAAUiB,EAAAA,IAAAA,CAAAA,CAAAA;AAE7C,QAAA,IAAI,CAACP,kBAAAA,CAAmBF,gBACtB,CAAA,EAAA,MAAM,IAAIG,KAAAA,CAAM,CAAC,6BAA6B,EAAEM,IAAAA,CAAKL,IAAI,CAAC,KAAK,CAAC,CAAA,CAAA;AAElE,QAAA,OAAOX,SAAS,CAACiB,YAAAA,CAAgC,CAC/ChB,OACAM,EAAAA,gBAAAA,CAAiBK,MAAM,EACvBG,IAAAA,CAAAA,CAAAA;AAEJ,KAAA,EACA,EAAE,CAAA,CAAA;AAEN,EAAE;AAEF;;;IAIA,SAASG,uBAAuBJ,SAAmB,EAAA;;IAEjD,IAAIA,SAAAA,CAAUR,MAAM,KAAK,CAAG,EAAA;QAC1B,OAAO;YACLU,IAAMF,EAAAA,SAAAA;YACNG,YAAc,EAAA,mBAAA;AAIhB,SAAA,CAAA;KACK,MAAA;;QAEL,OAAO;AACLD,YAAAA,IAAAA,EAAMF,SAAUK,CAAAA,KAAK,CAAC,CAAA,EAAG,CAAC,CAAA,CAAA;;AAE1BF,YAAAA,YAAAA,EAAcH,SAAS,CAACA,SAAUR,CAAAA,MAAM,GAAG,CAAE,CAAA;AAC/C,SAAA,CAAA;AACF,KAAA;AACF,CAAA;AAEA,SAASG,mBACPW,KAAc,EAAA;AAEd,IAAA,OAAOA,KAAU,KAAA,IAAA,IAAQ,OAAOA,KAAAA,KAAU,YAAY,QAAYA,IAAAA,KAAAA,CAAAA;AACpE,CAAA;AAEA,SAASZ,SAAAA,CAAUa,GAA4B,EAAEL,IAAc,EAAA;AAC7D,IAAA,OAAOA,IAAKM,CAAAA,MAAM,CAAU,CAACC,GAAKlB,EAAAA,GAAAA,GAAAA;QAChC,IAAIkB,GAAAA,IAAO,OAAOA,GAAQ,KAAA,QAAA,IAAYlB,OAAOkB,GAC3C,EAAA,OAAOA,GAAG,CAAClB,GAAwB,CAAA,CAAA;KACpCgB,EAAAA,GAAAA,CAAAA,CAAAA;AACL;;;;"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/react",
|
|
3
|
-
"version": "1.11.0-beta.
|
|
3
|
+
"version": "1.11.0-beta.4",
|
|
4
4
|
"description": "API client for React, providing type-safe requests and dynamic Tanstack Query React Hooks via a modular, Proxy-based architecture.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
6
|
+
"build": "NODE_ENV=production rollup --config rollup.config.mjs && tsc --project tsconfig.build.json --emitDeclarationOnly",
|
|
7
7
|
"dev": "rimraf dist/ && tsc --project tsconfig.build.json --watch --outDir ./dist/esm",
|
|
8
8
|
"test": "vitest run",
|
|
9
9
|
"test:coverage": "vitest run --coverage",
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
|
11
11
|
"lint": "eslint",
|
|
12
|
-
"
|
|
12
|
+
"clean": "rimraf dist/",
|
|
13
|
+
"codegen": "openapi-qraft --plugin tanstack-query-react --plugin openapi-typescript ../test-fixtures/openapi.json -rm -o src/tests/fixtures/api --openapi-types-file-name openapi.ts --explicit-import-extensions --filter-services '/approval_policies/**,/entities/**,/files/**,!/internal/**' --operation-predefined-parameters '/approval_policies/{approval_policy_id}/**:header.x-monite-entity-id' '/entities/{entity_id}/documents:header.x-monite-version' && yarn _prettify-api",
|
|
13
14
|
"_prettify-api": "prettier --write src/tests/fixtures/api/**/*.ts"
|
|
14
15
|
},
|
|
15
16
|
"sideEffects": false,
|
|
16
17
|
"devDependencies": {
|
|
17
|
-
"@openapi-qraft/cli": "~1.11.0-beta.
|
|
18
|
+
"@openapi-qraft/cli": "~1.11.0-beta.4",
|
|
18
19
|
"@openapi-qraft/eslint-config": "~1.0.0",
|
|
19
|
-
"@openapi-qraft/openapi-typescript-plugin": "^1.0.4-beta.
|
|
20
|
+
"@openapi-qraft/openapi-typescript-plugin": "^1.0.4-beta.4",
|
|
21
|
+
"@openapi-qraft/rollup-config": "~1.0.0",
|
|
20
22
|
"@openapi-qraft/test-fixtures": "~1.0.0",
|
|
21
23
|
"@tanstack/react-query": "^5.17.3",
|
|
22
24
|
"@testing-library/jest-dom": "^5.17.0",
|
|
@@ -33,7 +35,7 @@
|
|
|
33
35
|
"query-string": "^8.1.0",
|
|
34
36
|
"react": "^18.2.0",
|
|
35
37
|
"rimraf": "^5.0.5",
|
|
36
|
-
"
|
|
38
|
+
"rollup": "~4.18.0",
|
|
37
39
|
"vitest": "^1.4.0"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {
|
|
@@ -48,17 +50,9 @@
|
|
|
48
50
|
"!src/tests/**"
|
|
49
51
|
],
|
|
50
52
|
"type": "module",
|
|
51
|
-
"main": "dist/cjs/index.
|
|
53
|
+
"main": "dist/cjs/index.cjs",
|
|
52
54
|
"module": "dist/esm/index.js",
|
|
53
55
|
"types": "dist/types/index.d.ts",
|
|
54
|
-
"exports": {
|
|
55
|
-
".": {
|
|
56
|
-
"import": "./dist/esm/index.js",
|
|
57
|
-
"require": "./dist/cjs/index.js",
|
|
58
|
-
"types": "./dist/types/index.d.ts"
|
|
59
|
-
},
|
|
60
|
-
"./package.json": "./package.json"
|
|
61
|
-
},
|
|
62
56
|
"repository": {
|
|
63
57
|
"type": "git",
|
|
64
58
|
"url": "git+https://github.com/OpenAPI-Qraft/openapi-qraft.git",
|
package/dist/cjs/QraftContext.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var QraftContext_exports = {};
|
|
21
|
-
__export(QraftContext_exports, {
|
|
22
|
-
QraftContext: () => QraftContext
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(QraftContext_exports);
|
|
25
|
-
var import_react = require("react");
|
|
26
|
-
const QraftContext = (0, import_react.createContext)(void 0);
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
QraftContext
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=QraftContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/QraftContext.ts"],"sourcesContent":["'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"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8B;AA2BvB,MAAM,mBAAe,4BAAiC,MAAS;","names":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var ServiceOperation_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(ServiceOperation_exports);
|
|
17
|
-
//# sourceMappingURL=ServiceOperation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ServiceOperation.ts"],"sourcesContent":["import type { DefaultError } from '@tanstack/query-core';\n\nimport type {\n ServiceOperationQuery as ServiceOperationQueryBase,\n ServiceOperationMutation as ServiceOperationMutationBase,\n} from './service-operation/ServiceOperation.js';\nimport type {\n ServiceOperationInfiniteQueryKey as ServiceOperationInfiniteQueryKeyBase,\n ServiceOperationMutationKey as ServiceOperationMutationKeyBase,\n ServiceOperationQueryKey as ServiceOperationQueryKeyBase,\n} from './service-operation/ServiceOperationKey.js';\nimport type { ServiceOperationMutationFn as ServiceOperationMutationFnBase } from './service-operation/ServiceOperationMutationFn.js';\n\n/**\n * @deprecated Use `ServiceOperationMutationFn` from `@openapi-qraft/react/service-operation/ServiceOperationMutationFn` instead.\n */\nexport type ServiceOperationMutationFn<\n TSchema extends { url: string; method: string },\n TBody,\n TData,\n TParams,\n> = ServiceOperationMutationFnBase<TSchema, TBody, TData, TParams>;\n\n/**\n * @deprecated Use `ServiceOperationQuery` from `@openapi-qraft/react` instead.\n */\nexport type ServiceOperationQuery<\n TSchema extends { url: string; method: string },\n TData,\n TParams,\n TError = DefaultError,\n> = ServiceOperationQueryBase<TSchema, TData, TParams, TError>;\n\n/**\n * @deprecated Use `ServiceOperationMutation` from `@openapi-qraft/react` instead.\n */\nexport type ServiceOperationMutation<\n TSchema extends { url: string; method: string },\n TBody,\n TData,\n TParams,\n TError = DefaultError,\n> = ServiceOperationMutationBase<TSchema, TBody, TData, TParams, TError>;\n\n/**\n * @deprecated Use `ServiceOperationQueryKey` from `@openapi-qraft/react/service-operation/ServiceOperationKey` instead.\n */\nexport type ServiceOperationQueryKey<\n S extends { url: string; method: string },\n T,\n> = ServiceOperationQueryKeyBase<S, T>;\n\n/**\n * @deprecated Use `ServiceOperationInfiniteQueryKey` from `@openapi-qraft/react/service-operation/ServiceOperationKey` instead.\n */\nexport type ServiceOperationInfiniteQueryKey<\n S extends { url: string; method: string },\n T,\n> = ServiceOperationInfiniteQueryKeyBase<S, T>;\n\n/**\n * @deprecated Use `ServiceOperationMutationKey` from `@openapi-qraft/react/service-operation/ServiceOperationKey` instead.\n */\nexport type ServiceOperationMutationKey<\n S extends Record<'url' | 'method', string>,\n T,\n> = ServiceOperationMutationKeyBase<S, T>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var Unstable_QraftSecureRequestFn_exports = {};
|
|
21
|
-
__export(Unstable_QraftSecureRequestFn_exports, {
|
|
22
|
-
QraftSecureRequestFn: () => QraftSecureRequestFn,
|
|
23
|
-
createSecureRequestFn: () => createSecureRequestFn,
|
|
24
|
-
shallowEqualObjects: () => shallowEqualObjects,
|
|
25
|
-
useSecuritySchemeAuth: () => useSecuritySchemeAuth
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(Unstable_QraftSecureRequestFn_exports);
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
var import_react_query = require("@tanstack/react-query");
|
|
30
|
-
var import_jwt_decode = require("./lib/jwt-decode/index.js");
|
|
31
|
-
function QraftSecureRequestFn({
|
|
32
|
-
children,
|
|
33
|
-
requestFn,
|
|
34
|
-
securitySchemes,
|
|
35
|
-
queryClient: inQueryClient
|
|
36
|
-
}) {
|
|
37
|
-
const queryClient = (0, import_react.useMemo)(
|
|
38
|
-
() => inQueryClient ?? new import_react_query.QueryClient({
|
|
39
|
-
defaultOptions: {
|
|
40
|
-
queries: {
|
|
41
|
-
staleTime: 3e5,
|
|
42
|
-
gcTime: 3e5,
|
|
43
|
-
refetchOnWindowFocus: false,
|
|
44
|
-
refetchOnMount: false,
|
|
45
|
-
refetchOnReconnect: false
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}),
|
|
49
|
-
[inQueryClient]
|
|
50
|
-
);
|
|
51
|
-
(0, import_react.useEffect)(() => {
|
|
52
|
-
queryClient.mount();
|
|
53
|
-
return () => {
|
|
54
|
-
return void queryClient.unmount();
|
|
55
|
-
};
|
|
56
|
-
}, [queryClient]);
|
|
57
|
-
const secureRequestFn = useSecuritySchemeAuth({
|
|
58
|
-
securitySchemes,
|
|
59
|
-
requestFn,
|
|
60
|
-
queryClient
|
|
61
|
-
});
|
|
62
|
-
return (0, import_react.createElement)(import_react.Fragment, {
|
|
63
|
-
children: children(secureRequestFn)
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const useSecuritySchemeAuth = ({
|
|
67
|
-
securitySchemes,
|
|
68
|
-
requestFn,
|
|
69
|
-
queryClient
|
|
70
|
-
}) => {
|
|
71
|
-
(0, import_react_query.useQueries)(
|
|
72
|
-
{
|
|
73
|
-
queries: Object.entries(securitySchemes).map(([securitySchemeName]) => {
|
|
74
|
-
const queryKey = [securitySchemeName];
|
|
75
|
-
return {
|
|
76
|
-
enabled: Boolean(queryClient.getQueryData(queryKey)),
|
|
77
|
-
queryKey,
|
|
78
|
-
queryFn: ({
|
|
79
|
-
signal
|
|
80
|
-
}) => {
|
|
81
|
-
const securitySchemeHandler = securitySchemes[securitySchemeName];
|
|
82
|
-
return securitySchemeHandler({ signal, isRefreshing: true });
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
})
|
|
86
|
-
},
|
|
87
|
-
queryClient
|
|
88
|
-
);
|
|
89
|
-
return (0, import_react.useMemo)(
|
|
90
|
-
() => createSecureRequestFn(securitySchemes, requestFn, queryClient),
|
|
91
|
-
[securitySchemes, requestFn, queryClient]
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
function createSecureRequestFn(securitySchemes, requestFn, queryClient) {
|
|
95
|
-
return async function secureRequestFn(schema, requestInfo, options) {
|
|
96
|
-
const availableSecuritySchemes = Object.keys(securitySchemes);
|
|
97
|
-
const securitySchemeName = schema.security?.find(
|
|
98
|
-
(security) => availableSecuritySchemes.includes(security)
|
|
99
|
-
);
|
|
100
|
-
if (!securitySchemeName) {
|
|
101
|
-
return requestFn(schema, requestInfo, options);
|
|
102
|
-
}
|
|
103
|
-
const securitySchemeHandler = securitySchemes[securitySchemeName];
|
|
104
|
-
return requestFn(
|
|
105
|
-
schema,
|
|
106
|
-
await createSecureRequestInfo(
|
|
107
|
-
securitySchemeHandler,
|
|
108
|
-
[securitySchemeName],
|
|
109
|
-
requestInfo,
|
|
110
|
-
queryClient
|
|
111
|
-
),
|
|
112
|
-
options
|
|
113
|
-
);
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function getJwtTokenRefreshInterval(token) {
|
|
117
|
-
const parsedToken = (0, import_jwt_decode.jwtDecode)(token);
|
|
118
|
-
if (!parsedToken.iat || !parsedToken.exp) {
|
|
119
|
-
throw new Error("JWT token must contain both 'iat' and 'exp' fields.");
|
|
120
|
-
}
|
|
121
|
-
return (parsedToken.exp - parsedToken.iat) * 1e3;
|
|
122
|
-
}
|
|
123
|
-
async function createSecureRequestInfo(handler, queryKey, requestInfo, queryClient) {
|
|
124
|
-
const prevSecurityResult = queryClient.getQueryData(queryKey);
|
|
125
|
-
const securityResult = await queryClient.fetchQuery({
|
|
126
|
-
queryKey,
|
|
127
|
-
queryFn: ({ signal }) => handler({
|
|
128
|
-
signal,
|
|
129
|
-
isRefreshing: Boolean(prevSecurityResult)
|
|
130
|
-
})
|
|
131
|
-
});
|
|
132
|
-
if (!shallowEqualObjects(securityResult, prevSecurityResult)) {
|
|
133
|
-
const securityRefreshInterval = getSecurityRefreshInterval(securityResult);
|
|
134
|
-
if (securityRefreshInterval !== void 0 && securityRefreshInterval > 0) {
|
|
135
|
-
queryClient.removeQueries({ queryKey, exact: true });
|
|
136
|
-
setSecurityQueryDefaults(queryClient, queryKey, securityRefreshInterval);
|
|
137
|
-
queryClient.setQueryData(queryKey, securityResult);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const securityParameters = createSecureRequestParameters(securityResult);
|
|
141
|
-
if (!securityParameters) return requestInfo;
|
|
142
|
-
return {
|
|
143
|
-
...requestInfo,
|
|
144
|
-
parameters: {
|
|
145
|
-
...requestInfo.parameters,
|
|
146
|
-
[securityParameters.in]: {
|
|
147
|
-
[securityParameters.name]: securityParameters.value,
|
|
148
|
-
...requestInfo.parameters?.[securityParameters.in]
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
function setSecurityQueryDefaults(queryClient, queryKey, refreshInterval) {
|
|
154
|
-
queryClient.setQueryDefaults(queryKey, {
|
|
155
|
-
// stale the token 90% before it expires
|
|
156
|
-
staleTime: isFinite(refreshInterval) ? refreshInterval * 0.9 : refreshInterval,
|
|
157
|
-
// garbage collect the token after it expires
|
|
158
|
-
gcTime: isFinite(refreshInterval) ? refreshInterval : refreshInterval,
|
|
159
|
-
// refetch the token 80% before it expires
|
|
160
|
-
refetchInterval: isFinite(refreshInterval) ? refreshInterval * 0.8 : refreshInterval,
|
|
161
|
-
// always refetch the token, even in the background
|
|
162
|
-
refetchIntervalInBackground: true
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function createSecureRequestParameters(securityResult) {
|
|
166
|
-
if (typeof securityResult === "string" || "token" in securityResult) {
|
|
167
|
-
return {
|
|
168
|
-
in: "header",
|
|
169
|
-
name: "Authorization",
|
|
170
|
-
value: `Bearer ${typeof securityResult === "string" ? securityResult : securityResult.token}`
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
if ("credentials" in securityResult) {
|
|
174
|
-
return {
|
|
175
|
-
in: "header",
|
|
176
|
-
name: "Authorization",
|
|
177
|
-
value: `Basic ${securityResult.credentials}`
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
if ("in" in securityResult && securityResult.in !== "cookie") {
|
|
181
|
-
return securityResult;
|
|
182
|
-
}
|
|
183
|
-
throw new Error(
|
|
184
|
-
'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".'
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
function getSecurityRefreshInterval(securityResult) {
|
|
188
|
-
if (typeof securityResult === "string") {
|
|
189
|
-
return getJwtTokenRefreshInterval(securityResult);
|
|
190
|
-
}
|
|
191
|
-
if ("refreshInterval" in securityResult) {
|
|
192
|
-
return securityResult.refreshInterval;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function shallowEqualObjects(newObj, prevObj) {
|
|
196
|
-
if (typeof newObj !== typeof prevObj) return false;
|
|
197
|
-
if (typeof newObj === "string") return newObj === prevObj;
|
|
198
|
-
if (typeof newObj !== "object" || newObj === null || typeof prevObj !== "object" || prevObj === null || prevObj === void 0)
|
|
199
|
-
return false;
|
|
200
|
-
if (Object.keys(newObj).length !== Object.keys(prevObj).length) return false;
|
|
201
|
-
for (const key in newObj) {
|
|
202
|
-
if (!Object.prototype.hasOwnProperty.call(newObj, key)) return false;
|
|
203
|
-
if (newObj[key] !== prevObj[key]) return false;
|
|
204
|
-
}
|
|
205
|
-
return true;
|
|
206
|
-
}
|
|
207
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
-
0 && (module.exports = {
|
|
209
|
-
QraftSecureRequestFn,
|
|
210
|
-
createSecureRequestFn,
|
|
211
|
-
shallowEqualObjects,
|
|
212
|
-
useSecuritySchemeAuth
|
|
213
|
-
});
|
|
214
|
-
//# sourceMappingURL=Unstable_QraftSecureRequestFn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Unstable_QraftSecureRequestFn.ts"],"sourcesContent":["'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"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAuE;AAEvE,yBAKO;AAEP,wBAA0B;AA0BnB,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AACf,GAA8B;AAC5B,QAAM,kBAAc;AAAA,IAClB,MACE,iBACA,IAAI,+BAAY;AAAA,MACd,gBAAgB;AAAA,QACd,SAAS;AAAA,UACP,WAAW;AAAA,UACX,QAAQ;AAAA,UACR,sBAAsB;AAAA,UACtB,gBAAgB;AAAA,UAChB,oBAAoB;AAAA,QACtB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,IACH,CAAC,aAAa;AAAA,EAChB;AAEA,8BAAU,MAAM;AACd,gBAAY,MAAM;AAClB,WAAO,MAAM;AACX,aAAO,KAAK,YAAY,QAAQ;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,QAAM,kBAAkB,sBAAsB;AAAA,IAC5C;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,aAAO,4BAAc,uBAAU;AAAA,IAC7B,UAAU,SAAS,eAAe;AAAA,EACpC,CAAC;AACH;AAEO,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,MAEiB;AACf;AAAA,IACE;AAAA,MACE,SAAS,OAAO,QAAQ,eAAe,EAAE,IAAI,CAAC,CAAC,kBAAkB,MAAM;AACrE,cAAM,WAAqB,CAAC,kBAAkB;AAC9C,eAAO;AAAA,UACL,SAAS,QAAQ,YAAY,aAAa,QAAQ,CAAC;AAAA,UACnD;AAAA,UACA,SAAS,CAAC;AAAA,YACR;AAAA,UACF,MAA4D;AAC1D,kBAAM,wBAAwB,gBAAgB,kBAAkB;AAChE,mBAAO,sBAAsB,EAAE,QAAQ,cAAc,KAAK,CAAC;AAAA,UAC7D;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,aAAO;AAAA,IACL,MAAM,sBAAsB,iBAAiB,WAAW,WAAW;AAAA,IACnE,CAAC,iBAAiB,WAAW,WAAW;AAAA,EAC1C;AACF;AAWO,SAAS,sBACd,iBACA,WACA,aACW;AACX,SAAO,eAAe,gBACpB,QACA,aACA,SACA;AACA,UAAM,2BAA2B,OAAO,KAAK,eAAe;AAG5D,UAAM,qBAAqB,OAAO,UAAU;AAAA,MAC1C,CAAC,aACC,yBAAyB,SAAS,QAAQ;AAAA,IAC9C;AAEA,QAAI,CAAC,oBAAoB;AACvB,aAAO,UAAU,QAAQ,aAAa,OAAO;AAAA,IAC/C;AAEA,UAAM,wBAAwB,gBAAgB,kBAAkB;AAEhE,WAAO;AAAA,MACL;AAAA,MACA,MAAM;AAAA,QACJ;AAAA,QACA,CAAC,kBAAkB;AAAA,QACnB;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAKA,SAAS,2BAA2B,OAAe;AACjD,QAAM,kBAAc,6BAAU,KAAK;AACnC,MAAI,CAAC,YAAY,OAAO,CAAC,YAAY,KAAK;AACxC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AAEA,UAAQ,YAAY,MAAM,YAAY,OAAO;AAC/C;AAMA,eAAe,wBACb,SACA,UACA,aACA,aACwB;AACxB,QAAM,qBAAqB,YAAY,aAA6B,QAAQ;AAE5E,QAAM,iBAAiB,MAAM,YAAY,WAAW;AAAA,IAClD;AAAA,IACA,SAAS,CAAC,EAAE,OAAO,MACjB,QAAQ;AAAA,MACN;AAAA,MACA,cAAc,QAAQ,kBAAkB;AAAA,IAC1C,CAAC;AAAA,EACL,CAAC;AAED,MAAI,CAAC,oBAAoB,gBAAgB,kBAAkB,GAAG;AAC5D,UAAM,0BAA0B,2BAA2B,cAAc;AAEzE,QAAI,4BAA4B,UAAa,0BAA0B,GAAG;AAExE,kBAAY,cAAc,EAAE,UAAU,OAAO,KAAK,CAAC;AAGnD,+BAAyB,aAAa,UAAU,uBAAuB;AAIvE,kBAAY,aAAa,UAAU,cAAc;AAAA,IACnD;AAAA,EACF;AAEA,QAAM,qBAAqB,8BAA8B,cAAc;AAEvE,MAAI,CAAC,mBAAoB,QAAO;AAEhC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY;AAAA,MACV,GAAG,YAAY;AAAA,MACf,CAAC,mBAAmB,EAAE,GAAG;AAAA,QACvB,CAAC,mBAAmB,IAAI,GAAG,mBAAmB;AAAA,QAC9C,GAAG,YAAY,aAAa,mBAAmB,EAAE;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,yBACP,aACA,UACA,iBACA;AAEA,cAAY,iBAAiB,UAAU;AAAA;AAAA,IAErC,WAAW,SAAS,eAAe,IAC/B,kBAAkB,MAClB;AAAA;AAAA,IAEJ,QAAQ,SAAS,eAAe,IAAI,kBAAkB;AAAA;AAAA,IAEtD,iBAAiB,SAAS,eAAe,IACrC,kBAAkB,MAClB;AAAA;AAAA,IAEJ,6BAA6B;AAAA,EAC/B,CAAC;AACH;AAEA,SAAS,8BAA8B,gBAAgC;AACrE,MAAI,OAAO,mBAAmB,YAAY,WAAW,gBAAgB;AACnE,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,OAAO,UAAU,OAAO,mBAAmB,WAAW,iBAAiB,eAAe,KAAK;AAAA,IAC7F;AAAA,EACF;AAEA,MAAI,iBAAiB,gBAAgB;AACnC,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,OAAO,SAAS,eAAe,WAAW;AAAA,IAC5C;AAAA,EACF;AAEA,MAAI,QAAQ,kBAAkB,eAAe,OAAO,UAAU;AAC5D,WAAO;AAAA,EACT;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEA,SAAS,2BAA2B,gBAAgC;AAClE,MAAI,OAAO,mBAAmB,UAAU;AACtC,WAAO,2BAA2B,cAAc;AAAA,EAClD;AAEA,MAAI,qBAAqB,gBAAgB;AACvC,WAAO,eAAe;AAAA,EACxB;AACF;AAKO,SAAS,oBACd,QACA,SACA;AACA,MAAI,OAAO,WAAW,OAAO,QAAS,QAAO;AAC7C,MAAI,OAAO,WAAW,SAAU,QAAO,WAAW;AAClD,MACE,OAAO,WAAW,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":[]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cancelQueries_exports = {};
|
|
20
|
-
__export(cancelQueries_exports, {
|
|
21
|
-
cancelQueries: () => cancelQueries
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(cancelQueries_exports);
|
|
24
|
-
var import_callQueryClientMethodWithQueryFilters = require("../lib/callQueryClientMethodWithQueryFilters.js");
|
|
25
|
-
function cancelQueries(qraftOptions, schema, args) {
|
|
26
|
-
return (0, import_callQueryClientMethodWithQueryFilters.callQueryClientMethodWithQueryFilters)(
|
|
27
|
-
"cancelQueries",
|
|
28
|
-
schema,
|
|
29
|
-
args
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
cancelQueries
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=cancelQueries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/callbacks/cancelQueries.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mDAAsD;AAK/C,SAAS,cACd,cACA,QACA,MAOe;AACf,aAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var fetchInfiniteQuery_exports = {};
|
|
20
|
-
__export(fetchInfiniteQuery_exports, {
|
|
21
|
-
fetchInfiniteQuery: () => fetchInfiniteQuery
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(fetchInfiniteQuery_exports);
|
|
24
|
-
var import_callQueryClientFetchMethod = require("../lib/callQueryClientFetchMethod.js");
|
|
25
|
-
const fetchInfiniteQuery = (_, schema, args) => {
|
|
26
|
-
return (0, import_callQueryClientFetchMethod.callQueryClientMethodWithQueryKey)(
|
|
27
|
-
"fetchInfiniteQuery",
|
|
28
|
-
schema,
|
|
29
|
-
true,
|
|
30
|
-
args
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
fetchInfiniteQuery
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=fetchInfiniteQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/callbacks/fetchInfiniteQuery.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAAkD;AAI3C,MAAM,qBAUS,CAAC,GAAG,QAAQ,SAAS;AACzC,aAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var fetchQuery_exports = {};
|
|
20
|
-
__export(fetchQuery_exports, {
|
|
21
|
-
fetchQuery: () => fetchQuery
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(fetchQuery_exports);
|
|
24
|
-
var import_callQueryClientFetchMethod = require("../lib/callQueryClientFetchMethod.js");
|
|
25
|
-
const fetchQuery = (_, schema, args) => {
|
|
26
|
-
return (0, import_callQueryClientFetchMethod.callQueryClientMethodWithQueryKey)(
|
|
27
|
-
"fetchQuery",
|
|
28
|
-
schema,
|
|
29
|
-
false,
|
|
30
|
-
args
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
fetchQuery
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=fetchQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/callbacks/fetchQuery.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAAkD;AAI3C,MAAM,aAQS,CAAC,GAAG,QAAQ,SAAS;AACzC,aAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|