@decathlon/moon
Advanced tools
Comparing version 4.0.2 to 4.1.0
@@ -271,3 +271,5 @@ import { QueryCache, MutationCache, QueryClient, QueryClientProvider, hashQueryKey, InfiniteQueryObserver, QueryObserver, notifyManager, QueriesObserver, useQuery as useQuery$1, useMutation as useMutation$1, useInfiniteQuery as useInfiniteQuery$1 } from 'react-query'; | ||
var createObserver = useCallback(function () { | ||
return isInfinite ? new InfiniteQueryObserver(store, defaultOptions) : new QueryObserver(store, defaultOptions); | ||
return isInfinite | ||
? new InfiniteQueryObserver(store, defaultOptions) | ||
: new QueryObserver(store, defaultOptions); | ||
}, [isInfinite, store, defaultOptions]); | ||
@@ -277,2 +279,3 @@ var observer = observerRef.current || createObserver(); | ||
if (observer.hasListeners()) { | ||
// @ts-ignore InfiniteQueryObserver | QueryObserver | ||
observer.setOptions(defaultOptions); | ||
@@ -306,3 +309,5 @@ } | ||
var queries = useMemo(function () { | ||
return queriesIds.map(function (queryId) { return store.defaultQueryObserverOptions({ queryKey: queryId, enabled: false }); }); | ||
return queriesIds.map(function (queryId) { | ||
return store.defaultQueryObserverOptions({ queryKey: queryId, enabled: false }); | ||
}); | ||
}, [currentQueriesIds]); | ||
@@ -416,2 +421,3 @@ var observerRef = useRef(); | ||
// remove cache if networkOnly | ||
// @ts-ignore @react-query must update to undefined | ||
store.setQueryData(queryId, queryConfig === null || queryConfig === void 0 ? void 0 : queryConfig.initialData); | ||
@@ -462,5 +468,3 @@ } | ||
var queryResult = useQueryResult(queryId, resutToProps); | ||
var queryProps = resutToProps | ||
? queryResult | ||
: { queryResult: queryResult }; | ||
var queryProps = resutToProps ? queryResult : { queryResult: queryResult }; | ||
var componentProps = __assign(__assign({}, queryProps), rest); | ||
@@ -467,0 +471,0 @@ return createElement(WrappedComponent, __assign({ ref: forwardedRef }, componentProps)); |
@@ -271,3 +271,5 @@ (function (global, factory) { | ||
var createObserver = React.useCallback(function () { | ||
return isInfinite ? new reactQuery.InfiniteQueryObserver(store, defaultOptions) : new reactQuery.QueryObserver(store, defaultOptions); | ||
return isInfinite | ||
? new reactQuery.InfiniteQueryObserver(store, defaultOptions) | ||
: new reactQuery.QueryObserver(store, defaultOptions); | ||
}, [isInfinite, store, defaultOptions]); | ||
@@ -277,2 +279,3 @@ var observer = observerRef.current || createObserver(); | ||
if (observer.hasListeners()) { | ||
// @ts-ignore InfiniteQueryObserver | QueryObserver | ||
observer.setOptions(defaultOptions); | ||
@@ -306,3 +309,5 @@ } | ||
var queries = React.useMemo(function () { | ||
return queriesIds.map(function (queryId) { return store.defaultQueryObserverOptions({ queryKey: queryId, enabled: false }); }); | ||
return queriesIds.map(function (queryId) { | ||
return store.defaultQueryObserverOptions({ queryKey: queryId, enabled: false }); | ||
}); | ||
}, [currentQueriesIds]); | ||
@@ -415,2 +420,3 @@ var observerRef = React.useRef(); | ||
// remove cache if networkOnly | ||
// @ts-ignore @react-query must update to undefined | ||
store.setQueryData(queryId, queryConfig === null || queryConfig === void 0 ? void 0 : queryConfig.initialData); | ||
@@ -461,5 +467,3 @@ } | ||
var queryResult = useQueryResult(queryId, resutToProps); | ||
var queryProps = resutToProps | ||
? queryResult | ||
: { queryResult: queryResult }; | ||
var queryProps = resutToProps ? queryResult : { queryResult: queryResult }; | ||
var componentProps = __assign(__assign({}, queryProps), rest); | ||
@@ -466,0 +470,0 @@ return React.createElement(WrappedComponent, __assign({ ref: forwardedRef }, componentProps)); |
@@ -5,10 +5,10 @@ /// <reference types="react" /> | ||
import { IInfiniteQueryProps } from "./useInfiniteQuery"; | ||
export interface IInfiniteQueryChildrenProps<QueryResponse, QueryError> extends Omit<UseInfiniteQueryResult<QueryResponse | undefined, QueryError>, "fetchNextPage" | "fetchPreviousPage" | "refetch" | "remove"> { | ||
actions: Pick<UseInfiniteQueryResult<QueryResponse | undefined, QueryError>, "fetchNextPage" | "fetchPreviousPage" | "refetch" | "remove">; | ||
export interface IInfiniteQueryChildrenProps<QueryResponse, QueryError> extends Omit<UseInfiniteQueryResult<QueryResponse, QueryError>, "fetchNextPage" | "fetchPreviousPage" | "refetch" | "remove"> { | ||
actions: Pick<UseInfiniteQueryResult<QueryResponse, QueryError>, "fetchNextPage" | "fetchPreviousPage" | "refetch" | "remove">; | ||
} | ||
export declare type InfiniteQueryChildren<QueryResponse, QueryError> = (props: IInfiniteQueryChildrenProps<QueryResponse, QueryError>) => Nullable<JSX.Element>; | ||
export interface IInfiniteQueryComponentProps<QueryVariables, QueryPageVariables, QueryResponse, QueryError, QueryConfig> extends IInfiniteQueryProps<QueryVariables & QueryPageVariables, QueryResponse, QueryError, QueryConfig> { | ||
children?: InfiniteQueryChildren<QueryResponse, QueryError>; | ||
export interface IInfiniteQueryComponentProps<QueryVariables, QueryPageVariables, QueryResponse, QueryData, QueryError, QueryConfig> extends IInfiniteQueryProps<QueryVariables & QueryPageVariables, QueryResponse, QueryData, QueryError, QueryConfig> { | ||
children?: InfiniteQueryChildren<QueryData, QueryError>; | ||
} | ||
declare function InfiniteQuery<QueryVariables = any, QueryPageVariables = any, QueryResponse = any, QueryError = any, QueryConfig = any>(props: IInfiniteQueryComponentProps<QueryVariables, QueryPageVariables, QueryResponse, QueryError, QueryConfig>): Nullable<JSX.Element>; | ||
declare function InfiniteQuery<QueryVariables = any, QueryPageVariables = any, QueryResponse = any, QueryData = QueryResponse, QueryError = any, QueryConfig = any>(props: IInfiniteQueryComponentProps<QueryVariables, QueryPageVariables, QueryResponse, QueryData, QueryError, QueryConfig>): Nullable<JSX.Element>; | ||
export default InfiniteQuery; |
@@ -6,10 +6,10 @@ import * as React from "react"; | ||
import { ResultProps, QueriesResults } from "./hooks"; | ||
export interface IQueryChildrenProps<QueryResponse, QueryError> extends Omit<UseQueryResult<QueryResponse | undefined, QueryError>, "refetch" | "remove"> { | ||
actions: Pick<UseQueryResult<QueryResponse | undefined, QueryError>, "refetch" | "remove">; | ||
export interface IQueryChildrenProps<QueryData, QueryError> extends Omit<UseQueryResult<QueryData, QueryError>, "refetch" | "remove"> { | ||
actions: Pick<UseQueryResult<QueryData, QueryError>, "refetch" | "remove">; | ||
} | ||
export declare type QueryChildren<QueryResponse, QueryError> = (props: IQueryChildrenProps<QueryResponse, QueryError>) => Nullable<JSX.Element>; | ||
export interface IQueryComponentProps<QueryVariables, QueryResponse, QueryError, QueryConfig> extends IQueryProps<QueryVariables, QueryResponse, QueryError, QueryConfig> { | ||
children?: QueryChildren<QueryResponse, QueryError>; | ||
export declare type QueryChildren<QueryData, QueryError> = (props: IQueryChildrenProps<QueryData, QueryError>) => Nullable<JSX.Element>; | ||
export interface IQueryComponentProps<QueryVariables, QueryResponse, QueryData, QueryError, QueryConfig> extends IQueryProps<QueryVariables, QueryResponse, QueryData, QueryError, QueryConfig> { | ||
children?: QueryChildren<QueryData, QueryError>; | ||
} | ||
declare function Query<QueryVariables = any, QueryResponse = any, QueryError = any, QueryConfig = any>(props: IQueryComponentProps<QueryVariables, QueryResponse, QueryError, QueryConfig>): Nullable<JSX.Element>; | ||
declare function Query<QueryVariables = any, QueryResponse = any, QueryData = QueryResponse, QueryError = any, QueryConfig = any>(props: IQueryComponentProps<QueryVariables, QueryResponse, QueryData, QueryError, QueryConfig>): Nullable<JSX.Element>; | ||
declare namespace Query { | ||
@@ -16,0 +16,0 @@ var defaultProps: { |
import { UseInfiniteQueryResult, UseInfiniteQueryOptions as ReactQueryConfig } from "react-query"; | ||
import { ClientConfig } from "./utils"; | ||
export declare type IInfiniteQueryResultProps<QueryResponse, QueryError> = [ | ||
Omit<UseInfiniteQueryResult<QueryResponse | undefined, QueryError>, "fetchNextPage" | "fetchPreviousPage" | "refetch" | "remove">, | ||
Pick<UseInfiniteQueryResult<QueryResponse | undefined, QueryError>, "fetchNextPage" | "fetchPreviousPage" | "refetch" | "remove"> & { | ||
export declare type IInfiniteQueryResultProps<QueryData, QueryError> = [ | ||
Omit<UseInfiniteQueryResult<QueryData, QueryError>, "fetchNextPage" | "fetchPreviousPage" | "refetch" | "remove">, | ||
Pick<UseInfiniteQueryResult<QueryData, QueryError>, "fetchNextPage" | "fetchPreviousPage" | "refetch" | "remove"> & { | ||
cancel: () => void; | ||
} | ||
]; | ||
export interface IInfiniteQueryProps<QueryVariables = any, QueryResponse = any, QueryError = any, QueryConfig = any> { | ||
export interface IInfiniteQueryProps<QueryVariables = any, QueryResponse = any, QueryData = QueryResponse, QueryError = any, QueryConfig = any> { | ||
id?: string; | ||
@@ -20,4 +20,4 @@ /** The Link id of the http client. */ | ||
/** The react-query config. Please see the react-query QueryConfig for more details. */ | ||
queryConfig?: ReactQueryConfig<QueryResponse | undefined, QueryError>; | ||
queryConfig?: ReactQueryConfig<QueryResponse, QueryError, QueryData>; | ||
} | ||
export default function useInfiniteQuery<QueryVariables = any, QueryPageVariables = any, QueryResponse = any, QueryError = any, QueryConfig extends ClientConfig = any>({ id, source, endPoint, variables, options, queryConfig }: IInfiniteQueryProps<QueryVariables & QueryPageVariables, QueryResponse, QueryError, QueryConfig>): IInfiniteQueryResultProps<QueryResponse, QueryError>; | ||
export default function useInfiniteQuery<QueryVariables = any, QueryPageVariables = any, QueryResponse = any, QueryData = QueryResponse, QueryError = any, QueryConfig extends ClientConfig = any>({ id, source, endPoint, variables, options, queryConfig }: IInfiniteQueryProps<QueryVariables & QueryPageVariables, QueryResponse, QueryData, QueryError, QueryConfig>): IInfiniteQueryResultProps<QueryData, QueryError>; |
@@ -9,8 +9,8 @@ import { UseQueryResult, UseQueryOptions as ReactQueryConfig } from "react-query"; | ||
export declare type IQueryResultProps<QueryResponse, QueryError> = [ | ||
Omit<UseQueryResult<QueryResponse | undefined, QueryError>, "refetch" | "remove">, | ||
Pick<UseQueryResult<QueryResponse | undefined, QueryError>, "refetch" | "remove"> & { | ||
Omit<UseQueryResult<QueryResponse, QueryError>, "refetch" | "remove">, | ||
Pick<UseQueryResult<QueryResponse, QueryError>, "refetch" | "remove"> & { | ||
cancel: () => void; | ||
} | ||
]; | ||
export interface IQueryProps<QueryVariables = any, QueryResponse = any, QueryError = any, QueryConfig = any> { | ||
export interface IQueryProps<QueryVariables = any, QueryResponse = any, QueryData = QueryResponse, QueryError = any, QueryConfig = any> { | ||
id?: string; | ||
@@ -31,5 +31,5 @@ /** The Link id of the http client. */ | ||
/** The react-query config. Please see the react-query QueryConfig for more details. */ | ||
queryConfig?: ReactQueryConfig<QueryResponse | undefined, QueryError>; | ||
queryConfig?: ReactQueryConfig<QueryResponse, QueryError, QueryData>; | ||
} | ||
export declare const getQueryId: (queryProps: Pick<IQueryProps, "id" | "source" | "endPoint" | "variables" | "options">) => string; | ||
export default function useQuery<QueryVariables = any, QueryResponse = any, QueryError = any, QueryConfig extends ClientConfig = any>({ id, source, endPoint, variables, options, fetchPolicy, queryConfig }: IQueryProps<QueryVariables, QueryResponse, QueryError, QueryConfig>): IQueryResultProps<QueryResponse, QueryError>; | ||
export default function useQuery<QueryVariables = any, QueryResponse = any, QueryData = QueryResponse, QueryError = any, QueryConfig extends ClientConfig = any>({ id, source, endPoint, variables, options, fetchPolicy, queryConfig }: IQueryProps<QueryVariables, QueryResponse, QueryData, QueryError, QueryConfig>): IQueryResultProps<QueryData, QueryError>; |
@@ -59,3 +59,5 @@ "use strict"; | ||
var createObserver = React.useCallback(function () { | ||
return isInfinite ? new react_query_1.InfiniteQueryObserver(store, defaultOptions) : new react_query_1.QueryObserver(store, defaultOptions); | ||
return isInfinite | ||
? new react_query_1.InfiniteQueryObserver(store, defaultOptions) | ||
: new react_query_1.QueryObserver(store, defaultOptions); | ||
}, [isInfinite, store, defaultOptions]); | ||
@@ -65,2 +67,3 @@ var observer = observerRef.current || createObserver(); | ||
if (observer.hasListeners()) { | ||
// @ts-ignore InfiniteQueryObserver | QueryObserver | ||
observer.setOptions(defaultOptions); | ||
@@ -95,3 +98,5 @@ } | ||
var queries = React.useMemo(function () { | ||
return queriesIds.map(function (queryId) { return store.defaultQueryObserverOptions({ queryKey: queryId, enabled: false }); }); | ||
return queriesIds.map(function (queryId) { | ||
return store.defaultQueryObserverOptions({ queryKey: queryId, enabled: false }); | ||
}); | ||
}, [currentQueriesIds]); | ||
@@ -98,0 +103,0 @@ var observerRef = React.useRef(); |
@@ -64,5 +64,3 @@ "use strict"; | ||
var queryResult = hooks_1.useQueryResult(queryId, resutToProps); | ||
var queryProps = resutToProps | ||
? queryResult | ||
: { queryResult: queryResult }; | ||
var queryProps = resutToProps ? queryResult : { queryResult: queryResult }; | ||
var componentProps = __assign(__assign({}, queryProps), rest); | ||
@@ -69,0 +67,0 @@ return React.createElement(WrappedComponent, __assign({ ref: forwardedRef }, componentProps)); |
@@ -77,2 +77,3 @@ "use strict"; | ||
// remove cache if networkOnly | ||
// @ts-ignore @react-query must update to undefined | ||
store.setQueryData(queryId, queryConfig === null || queryConfig === void 0 ? void 0 : queryConfig.initialData); | ||
@@ -79,0 +80,0 @@ } |
{ | ||
"name": "@decathlon/moon", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "A featured, production ready caching REST client for every React UI", | ||
@@ -25,3 +25,3 @@ "author": "Decathlon", | ||
"react": "^17.0.1", | ||
"react-query": "~3.5.1" | ||
"react-query": "~3.16.0" | ||
}, | ||
@@ -59,3 +59,3 @@ "scripts": { | ||
}, | ||
"gitHead": "57d1486fcbe05cd0504ebd352e5a607e1b6716db" | ||
"gitHead": "f428173a955e8823a66ee1aff0cde26b8b592fc6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229547
2324