@gravity-ui/data-source 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/core/index.d.ts +1 -0
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/types/DataManagerOptions.d.ts +10 -0
- package/build/cjs/core/types/DataManagerOptions.js +6 -0
- package/build/cjs/core/types/DataManagerOptions.js.map +1 -0
- package/build/cjs/core/types/DataManger.d.ts +6 -5
- package/build/cjs/core/types/DataManger.js.map +1 -1
- package/build/cjs/core/utils/getError.js.map +1 -1
- package/build/cjs/core/utils/getStatus.js.map +1 -1
- package/build/cjs/core/utils/hasTag.js.map +1 -1
- package/build/cjs/react-query/ClientDataManager.d.ts +9 -6
- package/build/cjs/react-query/ClientDataManager.js +35 -15
- package/build/cjs/react-query/ClientDataManager.js.map +1 -1
- package/build/cjs/react-query/hooks/useQueryContext.d.ts +1 -1
- package/build/cjs/react-query/hooks/useQueryContext.js.map +1 -1
- package/build/cjs/react-query/hooks/useQueryData.d.ts +1 -1
- package/build/cjs/react-query/hooks/useQueryData.js.map +1 -1
- package/build/cjs/react-query/hooks/useRefetchInterval.d.ts +7 -0
- package/build/cjs/react-query/hooks/useRefetchInterval.js +33 -0
- package/build/cjs/react-query/hooks/useRefetchInterval.js.map +1 -0
- package/build/cjs/react-query/impl/infinite/hooks.js +25 -9
- package/build/cjs/react-query/impl/infinite/hooks.js.map +1 -1
- package/build/cjs/react-query/impl/infinite/types.d.ts +5 -3
- package/build/cjs/react-query/impl/infinite/types.js.map +1 -1
- package/build/cjs/react-query/impl/infinite/utils.d.ts +3 -3
- package/build/cjs/react-query/impl/infinite/utils.js.map +1 -1
- package/build/cjs/react-query/impl/plain/hooks.js +21 -5
- package/build/cjs/react-query/impl/plain/hooks.js.map +1 -1
- package/build/cjs/react-query/impl/plain/types.d.ts +5 -3
- package/build/cjs/react-query/impl/plain/types.js.map +1 -1
- package/build/cjs/react-query/impl/plain/utils.d.ts +2 -3
- package/build/cjs/react-query/impl/plain/utils.js.map +1 -1
- package/build/cjs/react-query/index.d.ts +4 -1
- package/build/cjs/react-query/index.js +7 -0
- package/build/cjs/react-query/index.js.map +1 -1
- package/build/cjs/react-query/{types.d.ts → types/base.d.ts} +2 -2
- package/build/cjs/react-query/{types.js → types/base.js} +1 -1
- package/build/cjs/react-query/types/base.js.map +1 -0
- package/build/cjs/react-query/types/options.d.ts +5 -0
- package/build/cjs/react-query/types/options.js +6 -0
- package/build/cjs/react-query/types/options.js.map +1 -0
- package/build/cjs/react-query/types/refetch-interval.d.ts +3 -0
- package/build/cjs/react-query/types/refetch-interval.js +6 -0
- package/build/cjs/react-query/types/refetch-interval.js.map +1 -0
- package/build/cjs/react-query/utils/getProgressiveRefetch.d.ts +8 -0
- package/build/cjs/react-query/utils/getProgressiveRefetch.js +16 -0
- package/build/cjs/react-query/utils/getProgressiveRefetch.js.map +1 -0
- package/build/esm/core/index.d.ts +1 -0
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/types/DataManagerOptions.d.ts +10 -0
- package/build/esm/core/types/DataManagerOptions.js +2 -0
- package/build/esm/core/types/DataManagerOptions.js.map +1 -0
- package/build/esm/core/types/DataManger.d.ts +6 -5
- package/build/esm/core/types/DataManger.js.map +1 -1
- package/build/esm/core/utils/getError.js.map +1 -1
- package/build/esm/core/utils/getStatus.js.map +1 -1
- package/build/esm/core/utils/hasTag.js.map +1 -1
- package/build/esm/react-query/ClientDataManager.d.ts +9 -6
- package/build/esm/react-query/ClientDataManager.js +35 -15
- package/build/esm/react-query/ClientDataManager.js.map +1 -1
- package/build/esm/react-query/hooks/useQueryContext.d.ts +1 -1
- package/build/esm/react-query/hooks/useQueryContext.js.map +1 -1
- package/build/esm/react-query/hooks/useQueryData.d.ts +1 -1
- package/build/esm/react-query/hooks/useQueryData.js.map +1 -1
- package/build/esm/react-query/hooks/useRefetchInterval.d.ts +7 -0
- package/build/esm/react-query/hooks/useRefetchInterval.js +26 -0
- package/build/esm/react-query/hooks/useRefetchInterval.js.map +1 -0
- package/build/esm/react-query/impl/infinite/hooks.js +25 -9
- package/build/esm/react-query/impl/infinite/hooks.js.map +1 -1
- package/build/esm/react-query/impl/infinite/types.d.ts +5 -3
- package/build/esm/react-query/impl/infinite/types.js.map +1 -1
- package/build/esm/react-query/impl/infinite/utils.d.ts +3 -3
- package/build/esm/react-query/impl/infinite/utils.js.map +1 -1
- package/build/esm/react-query/impl/plain/hooks.js +21 -5
- package/build/esm/react-query/impl/plain/hooks.js.map +1 -1
- package/build/esm/react-query/impl/plain/types.d.ts +5 -3
- package/build/esm/react-query/impl/plain/types.js.map +1 -1
- package/build/esm/react-query/impl/plain/utils.d.ts +2 -3
- package/build/esm/react-query/impl/plain/utils.js.map +1 -1
- package/build/esm/react-query/index.d.ts +4 -1
- package/build/esm/react-query/index.js +1 -0
- package/build/esm/react-query/index.js.map +1 -1
- package/build/esm/react-query/{types.d.ts → types/base.d.ts} +2 -2
- package/build/esm/react-query/types/base.js +2 -0
- package/build/esm/react-query/types/base.js.map +1 -0
- package/build/esm/react-query/types/options.d.ts +5 -0
- package/build/esm/react-query/types/options.js +2 -0
- package/build/esm/react-query/types/options.js.map +1 -0
- package/build/esm/react-query/types/refetch-interval.d.ts +3 -0
- package/build/esm/react-query/types/refetch-interval.js +2 -0
- package/build/esm/react-query/types/refetch-interval.js.map +1 -0
- package/build/esm/react-query/utils/getProgressiveRefetch.d.ts +8 -0
- package/build/esm/react-query/utils/getProgressiveRefetch.js +10 -0
- package/build/esm/react-query/utils/getProgressiveRefetch.js.map +1 -0
- package/package.json +1 -1
- package/build/cjs/react-query/types.js.map +0 -1
- package/build/esm/react-query/types.js +0 -2
- package/build/esm/react-query/types.js.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { InfiniteData, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, QueryFunctionContext } from '@tanstack/react-query';
|
|
1
|
+
import type { DefaultError, InfiniteData, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, QueryFunctionContext, QueryKey } from '@tanstack/react-query';
|
|
2
2
|
import type { Overwrite } from 'utility-types';
|
|
3
3
|
import type { ActualData, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
|
|
4
|
-
import type { QueryDataSourceContext } from '../../types';
|
|
5
|
-
|
|
4
|
+
import type { QueryDataSourceContext } from '../../types/base';
|
|
5
|
+
import type { QueryDataAdditionalOptions } from '../../types/options';
|
|
6
|
+
export type InfiniteQueryObserverExtendedOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = Overwrite<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, QueryDataAdditionalOptions<TQueryFnData, TError, InfiniteData<TQueryData, TPageParam>, TQueryKey>>;
|
|
7
|
+
export type InfiniteQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, InfiniteQueryObserverExtendedOptions<TResponse, TError, InfiniteData<ActualData<TData, TResponse>, Partial<TRequest>>, TResponse, DataSourceKey, Partial<TRequest>>, ResultWrapper<InfiniteQueryObserverResult<InfiniteData<ActualData<TData, TResponse>, Partial<TRequest>>, TError>, TRequest, TResponse, TData, TError>, QueryFunctionContext<DataSourceKey, Partial<TRequest>>> & {
|
|
6
8
|
type: 'infinite';
|
|
7
9
|
next: (lastPage: TResponse, allPages: TResponse[]) => Partial<TRequest> | null | undefined;
|
|
8
10
|
prev?: (firstPage: TResponse, allPages: TResponse[]) => Partial<TRequest> | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n InfiniteData,\n InfiniteQueryObserverOptions,\n InfiniteQueryObserverResult,\n QueryFunctionContext,\n} from '@tanstack/react-query';\nimport type {Overwrite} from 'utility-types';\n\nimport type {ActualData, DataLoaderStatus, DataSource, DataSourceKey} from '../../../core';\nimport type {QueryDataSourceContext} from '../../types';\n\nexport type InfiniteQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<\n QueryDataSourceContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n InfiniteQueryObserverOptions,\n InfiniteQueryObserverResult,\n QueryFunctionContext,\n QueryKey,\n} from '@tanstack/react-query';\nimport type {Overwrite} from 'utility-types';\n\nimport type {ActualData, DataLoaderStatus, DataSource, DataSourceKey} from '../../../core';\nimport type {QueryDataSourceContext} from '../../types/base';\nimport type {QueryDataAdditionalOptions} from '../../types/options';\n\nexport type InfiniteQueryObserverExtendedOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Overwrite<\n InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>,\n QueryDataAdditionalOptions<\n TQueryFnData,\n TError,\n InfiniteData<TQueryData, TPageParam>,\n TQueryKey\n >\n>;\n\nexport type InfiniteQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<\n QueryDataSourceContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n InfiniteQueryObserverExtendedOptions<\n TResponse,\n TError,\n InfiniteData<ActualData<TData, TResponse>, Partial<TRequest>>,\n TResponse,\n DataSourceKey,\n Partial<TRequest>\n >,\n ResultWrapper<\n InfiniteQueryObserverResult<\n InfiniteData<ActualData<TData, TResponse>, Partial<TRequest>>,\n TError\n >,\n TRequest,\n TResponse,\n TData,\n TError\n >,\n QueryFunctionContext<DataSourceKey, Partial<TRequest>>\n> & {\n type: 'infinite';\n next: (lastPage: TResponse, allPages: TResponse[]) => Partial<TRequest> | null | undefined;\n prev?: (firstPage: TResponse, allPages: TResponse[]) => Partial<TRequest> | null | undefined;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyInfiniteQueryDataSource = InfiniteQueryDataSource<any, any, any, any, any>;\n\n// It is used instead of `Partial<DataSourceRequest<TDataSource>>` because TS can't calculate type\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyPageParam = Partial<any>;\n\ntype ResultWrapper<TResult, TRequest, TResponse, TData, TError> =\n TResult extends InfiniteQueryObserverResult<\n InfiniteData<ActualData<TData, TResponse>, Partial<TRequest>>,\n TError\n >\n ? Overwrite<\n TResult,\n {\n status: DataLoaderStatus;\n data: Array<FlatArray<Array<ActualData<TData, TResponse>>, 1>>;\n }\n > & {\n originalStatus: TResult['status'];\n originalData: TResult['data'];\n }\n : never;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InfiniteData
|
|
1
|
+
import type { InfiniteData } from '@tanstack/react-query';
|
|
2
2
|
import type { DataSourceContext, DataSourceData, DataSourceError, DataSourceKey, DataSourceOptions, DataSourceParams, DataSourceResponse } from '../../../core';
|
|
3
|
-
import type { AnyInfiniteQueryDataSource, AnyPageParam } from './types';
|
|
4
|
-
export declare const composeOptions: <TDataSource extends AnyInfiniteQueryDataSource>(context: DataSourceContext<TDataSource>, dataSource: TDataSource, params: DataSourceParams<TDataSource>, options?: Partial<DataSourceOptions<TDataSource>>) =>
|
|
3
|
+
import type { AnyInfiniteQueryDataSource, AnyPageParam, InfiniteQueryObserverExtendedOptions } from './types';
|
|
4
|
+
export declare const composeOptions: <TDataSource extends AnyInfiniteQueryDataSource>(context: DataSourceContext<TDataSource>, dataSource: TDataSource, params: DataSourceParams<TDataSource>, options?: Partial<DataSourceOptions<TDataSource>>) => InfiniteQueryObserverExtendedOptions<DataSourceResponse<TDataSource>, DataSourceError<TDataSource>, InfiniteData<DataSourceData<TDataSource>, AnyPageParam>, DataSourceResponse<TDataSource>, DataSourceKey, AnyPageParam>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["skipToken","composeFullKey","idle","EMPTY_OBJECT","composeOptions","context","dataSource","params","options","transformParams","transformResponse","next","prev","queryFn","fetchContext","request","paginatedRequest","_objectSpread","pageParam","fetch","queryKey","select","data","pages","map","undefined","initialPageParam","getNextPageParam","getPreviousPageParam"],"sources":["utils.ts"],"sourcesContent":["import {skipToken} from '@tanstack/react-query';\nimport type {
|
|
1
|
+
{"version":3,"names":["skipToken","composeFullKey","idle","EMPTY_OBJECT","composeOptions","context","dataSource","params","options","transformParams","transformResponse","next","prev","queryFn","fetchContext","request","paginatedRequest","_objectSpread","pageParam","fetch","queryKey","select","data","pages","map","undefined","initialPageParam","getNextPageParam","getPreviousPageParam"],"sources":["utils.ts"],"sourcesContent":["import {skipToken} from '@tanstack/react-query';\nimport type {InfiniteData, QueryFunctionContext} from '@tanstack/react-query';\n\nimport {composeFullKey, idle} from '../../../core';\nimport type {\n DataSourceContext,\n DataSourceData,\n DataSourceError,\n DataSourceKey,\n DataSourceOptions,\n DataSourceParams,\n DataSourceResponse,\n} from '../../../core';\n\nimport type {\n AnyInfiniteQueryDataSource,\n AnyPageParam,\n InfiniteQueryObserverExtendedOptions,\n} from './types';\n\nconst EMPTY_OBJECT = {};\n\nexport const composeOptions = <TDataSource extends AnyInfiniteQueryDataSource>(\n context: DataSourceContext<TDataSource>,\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n options?: Partial<DataSourceOptions<TDataSource>>,\n): InfiniteQueryObserverExtendedOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n InfiniteData<DataSourceData<TDataSource>, AnyPageParam>,\n DataSourceResponse<TDataSource>,\n DataSourceKey,\n AnyPageParam\n> => {\n const {transformParams, transformResponse, next, prev} = dataSource;\n\n const queryFn = (\n fetchContext: QueryFunctionContext<DataSourceKey, AnyPageParam>,\n ): DataSourceResponse<TDataSource> | Promise<DataSourceResponse<TDataSource>> => {\n const request = transformParams ? transformParams(params) : params;\n const paginatedRequest = {...request, ...fetchContext.pageParam};\n\n return dataSource.fetch(context, fetchContext, paginatedRequest);\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select: transformResponse\n ? (data) => ({...data, pages: data.pages.map(transformResponse)})\n : undefined,\n initialPageParam: EMPTY_OBJECT,\n getNextPageParam: next,\n getPreviousPageParam: prev,\n ...dataSource.options,\n ...options,\n };\n};\n"],"mappings":";AAAA,SAAQA,SAAS,QAAO,uBAAuB;AAG/C,SAAQC,cAAc,EAAEC,IAAI,QAAO,eAAe;AAiBlD,IAAMC,YAAY,GAAG,CAAC,CAAC;AAEvB,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAQhD;EACD,IAAOC,eAAe,GAAmCH,UAAU,CAA5DG,eAAe;IAAEC,iBAAiB,GAAgBJ,UAAU,CAA3CI,iBAAiB;IAAEC,IAAI,GAAUL,UAAU,CAAxBK,IAAI;IAAEC,IAAI,GAAIN,UAAU,CAAlBM,IAAI;EAErD,IAAMC,OAAO,GAAG,SAAVA,OAAOA,CACTC,YAA+D,EACc;IAC7E,IAAMC,OAAO,GAAGN,eAAe,GAAGA,eAAe,CAACF,MAAM,CAAC,GAAGA,MAAM;IAClE,IAAMS,gBAAgB,GAAAC,aAAA,CAAAA,aAAA,KAAOF,OAAO,GAAKD,YAAY,CAACI,SAAS,CAAC;IAEhE,OAAOZ,UAAU,CAACa,KAAK,CAACd,OAAO,EAAES,YAAY,EAAEE,gBAAgB,CAAC;EACpE,CAAC;EAED,OAAAC,aAAA,CAAAA,aAAA;IACIG,QAAQ,EAAEnB,cAAc,CAACK,UAAU,EAAEC,MAAM,CAAC;IAC5CM,OAAO,EAAEN,MAAM,KAAKL,IAAI,GAAGF,SAAS,GAAGa,OAAO;IAC9CQ,MAAM,EAAEX,iBAAiB,GACnB,UAACY,IAAI;MAAA,OAAAL,aAAA,CAAAA,aAAA,KAAUK,IAAI;QAAEC,KAAK,EAAED,IAAI,CAACC,KAAK,CAACC,GAAG,CAACd,iBAAiB;MAAC;IAAA,CAAE,GAC/De,SAAS;IACfC,gBAAgB,EAAEvB,YAAY;IAC9BwB,gBAAgB,EAAEhB,IAAI;IACtBiB,oBAAoB,EAAEhB;EAAI,GACvBN,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["queryFn", "refetchInterval"];
|
|
2
4
|
import { useQuery } from '@tanstack/react-query';
|
|
5
|
+
import { useRefetchInterval } from '../../hooks/useRefetchInterval';
|
|
3
6
|
import { normalizeStatus } from '../../utils/normalizeStatus';
|
|
4
7
|
import { composeOptions } from './utils';
|
|
8
|
+
var usePlainQueryDataOptions = function usePlainQueryDataOptions(composedOptions) {
|
|
9
|
+
var queryFnOption = composedOptions.queryFn,
|
|
10
|
+
refetchIntervalOption = composedOptions.refetchInterval,
|
|
11
|
+
restOptions = _objectWithoutProperties(composedOptions, _excluded);
|
|
12
|
+
var _useRefetchInterval = useRefetchInterval(refetchIntervalOption, queryFnOption),
|
|
13
|
+
queryFn = _useRefetchInterval.queryFn,
|
|
14
|
+
refetchInterval = _useRefetchInterval.refetchInterval;
|
|
15
|
+
return _objectSpread(_objectSpread({}, restOptions), {}, {
|
|
16
|
+
queryFn: queryFn,
|
|
17
|
+
refetchInterval: refetchInterval
|
|
18
|
+
});
|
|
19
|
+
};
|
|
5
20
|
export var usePlainQueryData = function usePlainQueryData(context, dataSource, params, options) {
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
21
|
+
var extendedOptions = composeOptions(context, dataSource, params, options);
|
|
22
|
+
var composedOptions = usePlainQueryDataOptions(extendedOptions);
|
|
23
|
+
var state = useQuery(composedOptions);
|
|
24
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
25
|
+
status: normalizeStatus(state.status, state.fetchStatus),
|
|
26
|
+
originalStatus: state.status
|
|
11
27
|
});
|
|
12
28
|
};
|
|
13
29
|
// #sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useQuery","normalizeStatus","composeOptions","usePlainQueryData","context","dataSource","params","options","
|
|
1
|
+
{"version":3,"names":["useQuery","useRefetchInterval","normalizeStatus","composeOptions","usePlainQueryDataOptions","composedOptions","queryFnOption","queryFn","refetchIntervalOption","refetchInterval","restOptions","_objectWithoutProperties","_excluded","_useRefetchInterval","_objectSpread","usePlainQueryData","context","dataSource","params","options","extendedOptions","state","status","fetchStatus","originalStatus"],"sources":["hooks.ts"],"sourcesContent":["import {type QueryObserverOptions, useQuery} from '@tanstack/react-query';\n\nimport type {\n DataSourceContext,\n DataSourceData,\n DataSourceError,\n DataSourceKey,\n DataSourceOptions,\n DataSourceParams,\n DataSourceResponse,\n DataSourceState,\n} from '../../../core';\nimport {useRefetchInterval} from '../../hooks/useRefetchInterval';\nimport {normalizeStatus} from '../../utils/normalizeStatus';\n\nimport type {AnyPlainQueryDataSource, QueryObserverExtendedOptions} from './types';\nimport {composeOptions} from './utils';\n\nconst usePlainQueryDataOptions = <TDataSource extends AnyPlainQueryDataSource>(\n composedOptions: QueryObserverExtendedOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n DataSourceData<TDataSource>,\n DataSourceResponse<TDataSource>,\n DataSourceKey\n >,\n): QueryObserverOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n DataSourceData<TDataSource>,\n DataSourceResponse<TDataSource>,\n DataSourceKey\n> => {\n const {\n queryFn: queryFnOption,\n refetchInterval: refetchIntervalOption,\n ...restOptions\n } = composedOptions;\n\n const {queryFn, refetchInterval} = useRefetchInterval(refetchIntervalOption, queryFnOption);\n\n return {...restOptions, queryFn, refetchInterval};\n};\n\nexport const usePlainQueryData = <TDataSource extends AnyPlainQueryDataSource>(\n context: DataSourceContext<TDataSource>,\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n options?: Partial<DataSourceOptions<TDataSource>>,\n): DataSourceState<TDataSource> => {\n const extendedOptions = composeOptions(context, dataSource, params, options);\n const composedOptions = usePlainQueryDataOptions(extendedOptions);\n const state = useQuery(composedOptions);\n\n return {\n ...state,\n status: normalizeStatus(state.status, state.fetchStatus),\n originalStatus: state.status,\n } as DataSourceState<TDataSource>;\n};\n"],"mappings":";;;AAAA,SAAmCA,QAAQ,QAAO,uBAAuB;AAYzE,SAAQC,kBAAkB,QAAO,gCAAgC;AACjE,SAAQC,eAAe,QAAO,6BAA6B;AAG3D,SAAQC,cAAc,QAAO,SAAS;AAEtC,IAAMC,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAC1BC,eAMC,EAOA;EACD,IACaC,aAAa,GAGtBD,eAAe,CAHfE,OAAO;IACUC,qBAAqB,GAEtCH,eAAe,CAFfI,eAAe;IACZC,WAAW,GAAAC,wBAAA,CACdN,eAAe,EAAAO,SAAA;EAEnB,IAAAC,mBAAA,GAAmCZ,kBAAkB,CAACO,qBAAqB,EAAEF,aAAa,CAAC;IAApFC,OAAO,GAAAM,mBAAA,CAAPN,OAAO;IAAEE,eAAe,GAAAI,mBAAA,CAAfJ,eAAe;EAE/B,OAAAK,aAAA,CAAAA,aAAA,KAAWJ,WAAW;IAAEH,OAAO,EAAPA,OAAO;IAAEE,eAAe,EAAfA;EAAe;AACpD,CAAC;AAED,OAAO,IAAMM,iBAAiB,GAAG,SAApBA,iBAAiBA,CAC1BC,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAClB;EAC/B,IAAMC,eAAe,GAAGjB,cAAc,CAACa,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,CAAC;EAC5E,IAAMd,eAAe,GAAGD,wBAAwB,CAACgB,eAAe,CAAC;EACjE,IAAMC,KAAK,GAAGrB,QAAQ,CAACK,eAAe,CAAC;EAEvC,OAAAS,aAAA,CAAAA,aAAA,KACOO,KAAK;IACRC,MAAM,EAAEpB,eAAe,CAACmB,KAAK,CAACC,MAAM,EAAED,KAAK,CAACE,WAAW,CAAC;IACxDC,cAAc,EAAEH,KAAK,CAACC;EAAM;AAEpC,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { QueryFunctionContext, QueryObserverOptions, QueryObserverResult } from '@tanstack/react-query';
|
|
1
|
+
import type { DefaultError, QueryFunctionContext, QueryKey, QueryObserverOptions, QueryObserverResult } from '@tanstack/react-query';
|
|
2
2
|
import type { Overwrite } from 'utility-types';
|
|
3
3
|
import type { ActualData, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
|
|
4
|
-
import type { QueryDataSourceContext } from '../../types';
|
|
5
|
-
|
|
4
|
+
import type { QueryDataSourceContext } from '../../types/base';
|
|
5
|
+
import type { QueryDataAdditionalOptions } from '../../types/options';
|
|
6
|
+
export type QueryObserverExtendedOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = Overwrite<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, QueryDataAdditionalOptions<TQueryFnData, TError, TQueryData, TQueryKey>>;
|
|
7
|
+
export type PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, QueryObserverExtendedOptions<TResponse, TError, ActualData<TData, TResponse>, TResponse, DataSourceKey>, ResultWrapper<QueryObserverResult<ActualData<TData, TResponse>, TError>, TResponse, TData, TError>, QueryFunctionContext<DataSourceKey>> & {
|
|
6
8
|
type: 'plain';
|
|
7
9
|
};
|
|
8
10
|
export type AnyPlainQueryDataSource = PlainQueryDataSource<any, any, any, any, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n QueryFunctionContext,\n QueryObserverOptions,\n QueryObserverResult,\n} from '@tanstack/react-query';\nimport type {Overwrite} from 'utility-types';\n\nimport type {ActualData, DataLoaderStatus, DataSource, DataSourceKey} from '../../../core';\nimport type {QueryDataSourceContext} from '../../types';\n\nexport type PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<\n QueryDataSourceContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n DefaultError,\n QueryFunctionContext,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n} from '@tanstack/react-query';\nimport type {Overwrite} from 'utility-types';\n\nimport type {ActualData, DataLoaderStatus, DataSource, DataSourceKey} from '../../../core';\nimport type {QueryDataSourceContext} from '../../types/base';\nimport type {QueryDataAdditionalOptions} from '../../types/options';\n\nexport type QueryObserverExtendedOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = Overwrite<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>,\n QueryDataAdditionalOptions<TQueryFnData, TError, TQueryData, TQueryKey>\n>;\n\nexport type PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<\n QueryDataSourceContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n QueryObserverExtendedOptions<\n TResponse,\n TError,\n ActualData<TData, TResponse>,\n TResponse,\n DataSourceKey\n >,\n ResultWrapper<\n QueryObserverResult<ActualData<TData, TResponse>, TError>,\n TResponse,\n TData,\n TError\n >,\n QueryFunctionContext<DataSourceKey>\n> & {\n type: 'plain';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyPlainQueryDataSource = PlainQueryDataSource<any, any, any, any, any>;\n\ntype ResultWrapper<TResult, TResponse, TData, TError> =\n TResult extends QueryObserverResult<ActualData<TData, TResponse>, TError>\n ? Overwrite<TResult, {status: DataLoaderStatus}> & {originalStatus: TResult['status']}\n : never;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type QueryObserverOptions } from '@tanstack/react-query';
|
|
2
1
|
import type { DataSourceContext, DataSourceData, DataSourceError, DataSourceKey, DataSourceOptions, DataSourceParams, DataSourceResponse } from '../../../core';
|
|
3
|
-
import type { AnyPlainQueryDataSource } from './types';
|
|
4
|
-
export declare const composeOptions: <TDataSource extends AnyPlainQueryDataSource>(context: DataSourceContext<TDataSource>, dataSource: TDataSource, params: DataSourceParams<TDataSource>, options?: Partial<DataSourceOptions<TDataSource>>) =>
|
|
2
|
+
import type { AnyPlainQueryDataSource, QueryObserverExtendedOptions } from './types';
|
|
3
|
+
export declare const composeOptions: <TDataSource extends AnyPlainQueryDataSource>(context: DataSourceContext<TDataSource>, dataSource: TDataSource, params: DataSourceParams<TDataSource>, options?: Partial<DataSourceOptions<TDataSource>>) => QueryObserverExtendedOptions<DataSourceResponse<TDataSource>, DataSourceError<TDataSource>, DataSourceData<TDataSource>, DataSourceResponse<TDataSource>, DataSourceKey>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["skipToken","composeFullKey","idle","composeOptions","context","dataSource","params","options","transformParams","queryFn","fetchContext","fetch","_objectSpread","queryKey","select","transformResponse"],"sources":["utils.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["skipToken","composeFullKey","idle","composeOptions","context","dataSource","params","options","transformParams","queryFn","fetchContext","fetch","_objectSpread","queryKey","select","transformResponse"],"sources":["utils.ts"],"sourcesContent":["import {type QueryFunctionContext, skipToken} from '@tanstack/react-query';\n\nimport {composeFullKey, idle} from '../../../core';\nimport type {\n DataSourceContext,\n DataSourceData,\n DataSourceError,\n DataSourceKey,\n DataSourceOptions,\n DataSourceParams,\n DataSourceResponse,\n} from '../../../core';\n\nimport type {AnyPlainQueryDataSource, QueryObserverExtendedOptions} from './types';\n\nexport const composeOptions = <TDataSource extends AnyPlainQueryDataSource>(\n context: DataSourceContext<TDataSource>,\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n options?: Partial<DataSourceOptions<TDataSource>>,\n): QueryObserverExtendedOptions<\n DataSourceResponse<TDataSource>,\n DataSourceError<TDataSource>,\n DataSourceData<TDataSource>,\n DataSourceResponse<TDataSource>,\n DataSourceKey\n> => {\n const {transformParams} = dataSource;\n\n const queryFn = (\n fetchContext: QueryFunctionContext<DataSourceKey>,\n ): DataSourceResponse<TDataSource> | Promise<DataSourceResponse<TDataSource>> => {\n return dataSource.fetch(\n context,\n fetchContext,\n transformParams ? transformParams(params) : params,\n );\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select: dataSource.transformResponse,\n ...dataSource.options,\n ...options,\n };\n};\n"],"mappings":";AAAA,SAAmCA,SAAS,QAAO,uBAAuB;AAE1E,SAAQC,cAAc,EAAEC,IAAI,QAAO,eAAe;AAalD,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAOhD;EACD,IAAOC,eAAe,GAAIH,UAAU,CAA7BG,eAAe;EAEtB,IAAMC,OAAO,GAAG,SAAVA,OAAOA,CACTC,YAAiD,EAC4B;IAC7E,OAAOL,UAAU,CAACM,KAAK,CACnBP,OAAO,EACPM,YAAY,EACZF,eAAe,GAAGA,eAAe,CAACF,MAAM,CAAC,GAAGA,MAChD,CAAC;EACL,CAAC;EAED,OAAAM,aAAA,CAAAA,aAAA;IACIC,QAAQ,EAAEZ,cAAc,CAACI,UAAU,EAAEC,MAAM,CAAC;IAC5CG,OAAO,EAAEH,MAAM,KAAKJ,IAAI,GAAGF,SAAS,GAAGS,OAAO;IAC9CK,MAAM,EAAET,UAAU,CAACU;EAAiB,GACjCV,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type { QueryDataSourceContext, AnyQueryDataSource } from './types';
|
|
1
|
+
export type { QueryDataSourceContext, AnyQueryDataSource } from './types/base';
|
|
2
|
+
export type { RefetchIntervalFunction, RefetchInterval } from './types/refetch-interval';
|
|
2
3
|
export { useQueryContext } from './hooks/useQueryContext';
|
|
3
4
|
export { useQueryData } from './hooks/useQueryData';
|
|
4
5
|
export { useQueryResponses } from './hooks/useQueryResponses';
|
|
@@ -11,5 +12,7 @@ export type { PlainQueryDataSource, AnyPlainQueryDataSource } from './impl/plain
|
|
|
11
12
|
export { makePlainQueryDataSource } from './impl/plain/factory';
|
|
12
13
|
export { composeOptions as composePlainQueryOptions } from './impl/plain/utils';
|
|
13
14
|
export { normalizeStatus } from './utils/normalizeStatus';
|
|
15
|
+
export type { ProgressiveRefetchOptions } from './utils/getProgressiveRefetch';
|
|
16
|
+
export { getProgressiveRefetch } from './utils/getProgressiveRefetch';
|
|
14
17
|
export type { ClientDataManagerConfig } from './ClientDataManager';
|
|
15
18
|
export { ClientDataManager } from './ClientDataManager';
|
|
@@ -8,5 +8,6 @@ export { composeOptions as composeInfiniteQueryOptions } from './impl/infinite/u
|
|
|
8
8
|
export { makePlainQueryDataSource } from './impl/plain/factory';
|
|
9
9
|
export { composeOptions as composePlainQueryOptions } from './impl/plain/utils';
|
|
10
10
|
export { normalizeStatus } from './utils/normalizeStatus';
|
|
11
|
+
export { getProgressiveRefetch } from './utils/getProgressiveRefetch';
|
|
11
12
|
export { ClientDataManager } from './ClientDataManager';
|
|
12
13
|
// #sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useQueryContext","useQueryData","useQueryResponses","useRefetchAll","useRefetchErrored","makeInfiniteQueryDataSource","composeOptions","composeInfiniteQueryOptions","makePlainQueryDataSource","composePlainQueryOptions","normalizeStatus","ClientDataManager"],"sources":["index.ts"],"sourcesContent":["export type {QueryDataSourceContext, AnyQueryDataSource} from './types';\n\nexport {useQueryContext} from './hooks/useQueryContext';\nexport {useQueryData} from './hooks/useQueryData';\nexport {useQueryResponses} from './hooks/useQueryResponses';\nexport {useRefetchAll} from './hooks/useRefetchAll';\nexport {useRefetchErrored} from './hooks/useRefetchErrored';\n\nexport type {InfiniteQueryDataSource, AnyInfiniteQueryDataSource} from './impl/infinite/types';\nexport {makeInfiniteQueryDataSource} from './impl/infinite/factory';\nexport {composeOptions as composeInfiniteQueryOptions} from './impl/infinite/utils';\n\nexport type {PlainQueryDataSource, AnyPlainQueryDataSource} from './impl/plain/types';\nexport {makePlainQueryDataSource} from './impl/plain/factory';\nexport {composeOptions as composePlainQueryOptions} from './impl/plain/utils';\n\nexport {normalizeStatus} from './utils/normalizeStatus';\n\nexport type {ClientDataManagerConfig} from './ClientDataManager';\nexport {ClientDataManager} from './ClientDataManager';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["useQueryContext","useQueryData","useQueryResponses","useRefetchAll","useRefetchErrored","makeInfiniteQueryDataSource","composeOptions","composeInfiniteQueryOptions","makePlainQueryDataSource","composePlainQueryOptions","normalizeStatus","getProgressiveRefetch","ClientDataManager"],"sources":["index.ts"],"sourcesContent":["export type {QueryDataSourceContext, AnyQueryDataSource} from './types/base';\nexport type {RefetchIntervalFunction, RefetchInterval} from './types/refetch-interval';\n\nexport {useQueryContext} from './hooks/useQueryContext';\nexport {useQueryData} from './hooks/useQueryData';\nexport {useQueryResponses} from './hooks/useQueryResponses';\nexport {useRefetchAll} from './hooks/useRefetchAll';\nexport {useRefetchErrored} from './hooks/useRefetchErrored';\n\nexport type {InfiniteQueryDataSource, AnyInfiniteQueryDataSource} from './impl/infinite/types';\nexport {makeInfiniteQueryDataSource} from './impl/infinite/factory';\nexport {composeOptions as composeInfiniteQueryOptions} from './impl/infinite/utils';\n\nexport type {PlainQueryDataSource, AnyPlainQueryDataSource} from './impl/plain/types';\nexport {makePlainQueryDataSource} from './impl/plain/factory';\nexport {composeOptions as composePlainQueryOptions} from './impl/plain/utils';\n\nexport {normalizeStatus} from './utils/normalizeStatus';\nexport type {ProgressiveRefetchOptions} from './utils/getProgressiveRefetch';\nexport {getProgressiveRefetch} from './utils/getProgressiveRefetch';\n\nexport type {ClientDataManagerConfig} from './ClientDataManager';\nexport {ClientDataManager} from './ClientDataManager';\n"],"mappings":"AAGA,SAAQA,eAAe,QAAO,yBAAyB;AACvD,SAAQC,YAAY,QAAO,sBAAsB;AACjD,SAAQC,iBAAiB,QAAO,2BAA2B;AAC3D,SAAQC,aAAa,QAAO,uBAAuB;AACnD,SAAQC,iBAAiB,QAAO,2BAA2B;AAG3D,SAAQC,2BAA2B,QAAO,yBAAyB;AACnE,SAAQC,cAAc,IAAIC,2BAA2B,QAAO,uBAAuB;AAGnF,SAAQC,wBAAwB,QAAO,sBAAsB;AAC7D,SAAQF,cAAc,IAAIG,wBAAwB,QAAO,oBAAoB;AAE7E,SAAQC,eAAe,QAAO,yBAAyB;AAEvD,SAAQC,qBAAqB,QAAO,+BAA+B;AAGnE,SAAQC,iBAAiB,QAAO,qBAAqB","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import type { AnyInfiniteQueryDataSource } from '
|
|
3
|
-
import type { AnyPlainQueryDataSource } from '
|
|
2
|
+
import type { AnyInfiniteQueryDataSource } from '../impl/infinite/types';
|
|
3
|
+
import type { AnyPlainQueryDataSource } from '../impl/plain/types';
|
|
4
4
|
export interface QueryDataSourceContext {
|
|
5
5
|
queryClient: QueryClient;
|
|
6
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["base.ts"],"sourcesContent":["import type {QueryClient} from '@tanstack/react-query';\n\nimport type {AnyInfiniteQueryDataSource} from '../impl/infinite/types';\nimport type {AnyPlainQueryDataSource} from '../impl/plain/types';\n\nexport interface QueryDataSourceContext {\n queryClient: QueryClient;\n}\n\nexport type AnyQueryDataSource = AnyPlainQueryDataSource | AnyInfiniteQueryDataSource;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DefaultError, QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import type { RefetchInterval } from './refetch-interval';
|
|
3
|
+
export interface QueryDataAdditionalOptions<TQueryFnData = unknown, TError = DefaultError, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> {
|
|
4
|
+
refetchInterval?: RefetchInterval<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["options.ts"],"sourcesContent":["import type {DefaultError, QueryKey} from '@tanstack/react-query';\n\nimport type {RefetchInterval} from './refetch-interval';\n\nexport interface QueryDataAdditionalOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> {\n refetchInterval?: RefetchInterval<TQueryFnData, TError, TQueryData, TQueryKey>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DefaultError, Query, QueryKey } from '@tanstack/react-query';
|
|
2
|
+
export type RefetchIntervalFunction<TQueryFnData = unknown, TError = DefaultError, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = (query: Query<TQueryFnData, TError, TQueryData, TQueryKey>, count: number) => number | false | undefined;
|
|
3
|
+
export type RefetchInterval<TQueryFnData = unknown, TError = DefaultError, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = number | false | RefetchIntervalFunction<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["refetch-interval.ts"],"sourcesContent":["import type {DefaultError, Query, QueryKey} from '@tanstack/react-query';\n\nexport type RefetchIntervalFunction<\n TQueryFnData = unknown,\n TError = DefaultError,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = (\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n count: number,\n) => number | false | undefined;\n\nexport type RefetchInterval<\n TQueryFnData = unknown,\n TError = DefaultError,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = number | false | RefetchIntervalFunction<TQueryFnData, TError, TQueryData, TQueryKey>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import type { RefetchIntervalFunction } from '../types/refetch-interval';
|
|
3
|
+
export interface ProgressiveRefetchOptions {
|
|
4
|
+
minInterval: number;
|
|
5
|
+
maxInterval: number;
|
|
6
|
+
multiplier?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const getProgressiveRefetch: <TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>({ minInterval, maxInterval, multiplier, }: ProgressiveRefetchOptions) => RefetchIntervalFunction<TQueryFnData, TError, TData, TQueryKey>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var getProgressiveRefetch = function getProgressiveRefetch(_ref) {
|
|
2
|
+
var minInterval = _ref.minInterval,
|
|
3
|
+
maxInterval = _ref.maxInterval,
|
|
4
|
+
_ref$multiplier = _ref.multiplier,
|
|
5
|
+
multiplier = _ref$multiplier === void 0 ? 2 : _ref$multiplier;
|
|
6
|
+
return function (_query, count) {
|
|
7
|
+
return Math.min(minInterval * Math.pow(multiplier, count), maxInterval);
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
// #sourceMappingURL=getProgressiveRefetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getProgressiveRefetch","_ref","minInterval","maxInterval","_ref$multiplier","multiplier","_query","count","Math","min","pow"],"sources":["getProgressiveRefetch.ts"],"sourcesContent":["import type {DefaultError, QueryKey} from '@tanstack/react-query';\n\nimport type {RefetchIntervalFunction} from '../types/refetch-interval';\n\nexport interface ProgressiveRefetchOptions {\n minInterval: number;\n maxInterval: number;\n multiplier?: number;\n}\n\nexport const getProgressiveRefetch = <\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>({\n minInterval,\n maxInterval,\n multiplier = 2,\n}: ProgressiveRefetchOptions): RefetchIntervalFunction<TQueryFnData, TError, TData, TQueryKey> => {\n return (_query, count) => {\n return Math.min(minInterval * multiplier ** count, maxInterval);\n };\n};\n"],"mappings":"AAUA,OAAO,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAAC,IAAA,EASgE;EAAA,IAH9FC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IACXC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IAAAC,eAAA,GAAAH,IAAA,CACXI,UAAU;IAAVA,UAAU,GAAAD,eAAA,cAAG,CAAC,GAAAA,eAAA;EAEd,OAAO,UAACE,MAAM,EAAEC,KAAK,EAAK;IACtB,OAAOC,IAAI,CAACC,GAAG,CAACP,WAAW,GAAAM,IAAA,CAAAE,GAAA,CAAGL,UAAU,EAAIE,KAAK,GAAEJ,WAAW,CAAC;EACnE,CAAC;AACL,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {QueryClient} from '@tanstack/react-query';\n\nimport type {AnyInfiniteQueryDataSource} from './impl/infinite/types';\nimport type {AnyPlainQueryDataSource} from './impl/plain/types';\n\nexport interface QueryDataSourceContext {\n queryClient: QueryClient;\n}\n\nexport type AnyQueryDataSource = AnyPlainQueryDataSource | AnyInfiniteQueryDataSource;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {QueryClient} from '@tanstack/react-query';\n\nimport type {AnyInfiniteQueryDataSource} from './impl/infinite/types';\nimport type {AnyPlainQueryDataSource} from './impl/plain/types';\n\nexport interface QueryDataSourceContext {\n queryClient: QueryClient;\n}\n\nexport type AnyQueryDataSource = AnyPlainQueryDataSource | AnyInfiniteQueryDataSource;\n"],"mappings":"","ignoreList":[]}
|