@gravity-ui/data-source 0.3.0 → 0.5.0
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/react-query/ClientDataManager.d.ts +8 -5
- package/build/cjs/react-query/ClientDataManager.js +39 -15
- package/build/cjs/react-query/ClientDataManager.js.map +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.d.ts +4 -2
- package/build/cjs/react-query/impl/infinite/hooks.js +33 -2
- package/build/cjs/react-query/impl/infinite/hooks.js.map +1 -1
- package/build/cjs/react-query/impl/infinite/types.d.ts +5 -2
- package/build/cjs/react-query/impl/infinite/types.js.map +1 -1
- package/build/cjs/react-query/impl/infinite/utils.d.ts +4 -5
- package/build/cjs/react-query/impl/infinite/utils.js +1 -12
- package/build/cjs/react-query/impl/infinite/utils.js.map +1 -1
- package/build/cjs/react-query/impl/plain/hooks.d.ts +5 -2
- package/build/cjs/react-query/impl/plain/hooks.js +26 -2
- package/build/cjs/react-query/impl/plain/hooks.js.map +1 -1
- package/build/cjs/react-query/impl/plain/types.d.ts +4 -3
- package/build/cjs/react-query/impl/plain/types.js.map +1 -1
- package/build/cjs/react-query/impl/plain/utils.d.ts +3 -5
- package/build/cjs/react-query/impl/plain/utils.js +1 -8
- package/build/cjs/react-query/impl/plain/utils.js.map +1 -1
- package/build/cjs/react-query/index.d.ts +2 -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/index.d.ts +2 -0
- package/build/cjs/react-query/types/index.js +28 -0
- package/build/cjs/react-query/types/index.js.map +1 -0
- package/build/cjs/react-query/types/refetch-interval.d.ts +10 -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 +3 -0
- package/build/cjs/react-query/utils/getProgressiveRefetch.js +15 -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/react-query/ClientDataManager.d.ts +8 -5
- package/build/esm/react-query/ClientDataManager.js +39 -15
- package/build/esm/react-query/ClientDataManager.js.map +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.d.ts +4 -2
- package/build/esm/react-query/impl/infinite/hooks.js +32 -3
- package/build/esm/react-query/impl/infinite/hooks.js.map +1 -1
- package/build/esm/react-query/impl/infinite/types.d.ts +5 -2
- package/build/esm/react-query/impl/infinite/types.js.map +1 -1
- package/build/esm/react-query/impl/infinite/utils.d.ts +4 -5
- package/build/esm/react-query/impl/infinite/utils.js +0 -11
- package/build/esm/react-query/impl/infinite/utils.js.map +1 -1
- package/build/esm/react-query/impl/plain/hooks.d.ts +5 -2
- package/build/esm/react-query/impl/plain/hooks.js +25 -3
- package/build/esm/react-query/impl/plain/hooks.js.map +1 -1
- package/build/esm/react-query/impl/plain/types.d.ts +4 -3
- package/build/esm/react-query/impl/plain/types.js.map +1 -1
- package/build/esm/react-query/impl/plain/utils.d.ts +3 -5
- package/build/esm/react-query/impl/plain/utils.js +0 -7
- package/build/esm/react-query/impl/plain/utils.js.map +1 -1
- package/build/esm/react-query/index.d.ts +2 -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/index.d.ts +2 -0
- package/build/esm/react-query/types/index.js +3 -0
- package/build/esm/react-query/types/index.js.map +1 -0
- package/build/esm/react-query/types/refetch-interval.d.ts +10 -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 +3 -0
- package/build/esm/react-query/utils/getProgressiveRefetch.js +9 -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,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DefaultError, InfiniteData, InfiniteQueryObserverResult, InfiniteQueryPageParamsOptions, 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
4
|
import type { QueryDataSourceContext } from '../../types';
|
|
5
|
-
|
|
5
|
+
import type { QueryObserverExtendedOptions } from '../plain/types';
|
|
6
|
+
export interface InfiniteQueryObserverExtendedOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserverExtendedOptions<TQueryFnData, TError, TData, InfiniteData<TQueryData, TPageParam>, TQueryKey, TPageParam>, InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {
|
|
7
|
+
}
|
|
8
|
+
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
9
|
type: 'infinite';
|
|
7
10
|
next: (lastPage: TResponse, allPages: TResponse[]) => Partial<TRequest> | null | undefined;
|
|
8
11
|
prev?: (firstPage: TResponse, allPages: TResponse[]) => Partial<TRequest> | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n InfiniteQueryObserverResult,\n InfiniteQueryPageParamsOptions,\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';\nimport type {QueryObserverExtendedOptions} from '../plain/types';\n\nexport interface InfiniteQueryObserverExtendedOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> extends QueryObserverExtendedOptions<\n TQueryFnData,\n TError,\n TData,\n InfiniteData<TQueryData, TPageParam>,\n TQueryKey,\n TPageParam\n >,\n InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {}\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,5 +1,4 @@
|
|
|
1
|
-
import type { InfiniteData
|
|
2
|
-
import type { DataSourceContext, DataSourceData, DataSourceError, DataSourceKey, DataSourceOptions, DataSourceParams, DataSourceResponse
|
|
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>>) =>
|
|
5
|
-
export declare const transformResult: <TDataSource extends AnyInfiniteQueryDataSource>(result: InfiniteQueryObserverResult<InfiniteData<DataSourceData<TDataSource>, AnyPageParam>, DataSourceError<TDataSource>>) => DataSourceState<TDataSource>;
|
|
1
|
+
import type { InfiniteData } from '@tanstack/react-query';
|
|
2
|
+
import type { DataSourceContext, DataSourceData, DataSourceError, DataSourceKey, DataSourceOptions, DataSourceParams, DataSourceResponse } from '../../../core';
|
|
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,8 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
2
|
import { skipToken } from '@tanstack/react-query';
|
|
3
3
|
import { composeFullKey, idle } from '../../../core';
|
|
4
|
-
import { normalizeStatus } from '../../utils/normalizeStatus';
|
|
5
|
-
var EMPTY_ARRAY = [];
|
|
6
4
|
var EMPTY_OBJECT = {};
|
|
7
5
|
export var composeOptions = function composeOptions(context, dataSource, params, options) {
|
|
8
6
|
var transformParams = dataSource.transformParams,
|
|
@@ -27,13 +25,4 @@ export var composeOptions = function composeOptions(context, dataSource, params,
|
|
|
27
25
|
getPreviousPageParam: prev
|
|
28
26
|
}, dataSource.options), options);
|
|
29
27
|
};
|
|
30
|
-
export var transformResult = function transformResult(result) {
|
|
31
|
-
var _result$data$pages$fl, _result$data;
|
|
32
|
-
return _objectSpread(_objectSpread({}, result), {}, {
|
|
33
|
-
status: normalizeStatus(result.status, result.fetchStatus),
|
|
34
|
-
data: (_result$data$pages$fl = (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.pages.flat(1)) !== null && _result$data$pages$fl !== void 0 ? _result$data$pages$fl : EMPTY_ARRAY,
|
|
35
|
-
originalStatus: result.status,
|
|
36
|
-
originalData: result.data
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
28
|
// #sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["skipToken","composeFullKey","idle","
|
|
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,3 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { type QueryObserverOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { DataSourceContext, DataSourceData, DataSourceError, DataSourceKey, DataSourceOptions, DataSourceParams, DataSourceResponse, DataSourceState } from '../../../core';
|
|
3
|
+
import type { AnyQueryDataSource } from '../../types';
|
|
4
|
+
import type { AnyPlainQueryDataSource, QueryObserverExtendedOptions } from './types';
|
|
3
5
|
export declare const usePlainQueryData: <TDataSource extends AnyPlainQueryDataSource>(context: DataSourceContext<TDataSource>, dataSource: TDataSource, params: DataSourceParams<TDataSource>, options?: Partial<DataSourceOptions<TDataSource>>) => DataSourceState<TDataSource>;
|
|
6
|
+
export declare function useQueryDataOptions<TDataSource extends AnyQueryDataSource>(composedOptions: QueryObserverExtendedOptions<DataSourceResponse<TDataSource>, DataSourceError<TDataSource>, DataSourceData<TDataSource>, DataSourceResponse<TDataSource>, DataSourceKey>): QueryObserverOptions<DataSourceResponse<TDataSource>, DataSourceError<TDataSource>, DataSourceData<TDataSource>, DataSourceResponse<TDataSource>, DataSourceKey>;
|
|
@@ -1,8 +1,30 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
|
+
var _excluded = ["refetchInterval", "queryFn"];
|
|
1
4
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
5
|
+
import { useRefetchInterval } from '../../hooks/useRefetchInterval';
|
|
6
|
+
import { normalizeStatus } from '../../utils/normalizeStatus';
|
|
7
|
+
import { composeOptions } from './utils';
|
|
3
8
|
export var usePlainQueryData = function usePlainQueryData(context, dataSource, params, options) {
|
|
4
9
|
var composedOptions = composeOptions(context, dataSource, params, options);
|
|
5
|
-
var
|
|
6
|
-
|
|
10
|
+
var extendedOptions = useQueryDataOptions(composedOptions);
|
|
11
|
+
var result = useQuery(extendedOptions);
|
|
12
|
+
return _objectSpread(_objectSpread({}, result), {}, {
|
|
13
|
+
status: normalizeStatus(result.status, result.fetchStatus),
|
|
14
|
+
originalStatus: result.status
|
|
15
|
+
});
|
|
7
16
|
};
|
|
17
|
+
export function useQueryDataOptions(composedOptions) {
|
|
18
|
+
var _ref = composedOptions || {},
|
|
19
|
+
refetchIntervalOption = _ref.refetchInterval,
|
|
20
|
+
queryFnOption = _ref.queryFn,
|
|
21
|
+
restOptions = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
+
var _useRefetchInterval = useRefetchInterval(refetchIntervalOption, queryFnOption),
|
|
23
|
+
refetchInterval = _useRefetchInterval.refetchInterval,
|
|
24
|
+
queryFn = _useRefetchInterval.queryFn;
|
|
25
|
+
return _objectSpread(_objectSpread({}, restOptions), {}, {
|
|
26
|
+
refetchInterval: refetchInterval,
|
|
27
|
+
queryFn: queryFn
|
|
28
|
+
});
|
|
29
|
+
}
|
|
8
30
|
// #sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useQuery","
|
|
1
|
+
{"version":3,"names":["useQuery","useRefetchInterval","normalizeStatus","composeOptions","usePlainQueryData","context","dataSource","params","options","composedOptions","extendedOptions","useQueryDataOptions","result","_objectSpread","status","fetchStatus","originalStatus","_ref","refetchIntervalOption","refetchInterval","queryFnOption","queryFn","restOptions","_objectWithoutProperties","_excluded","_useRefetchInterval"],"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 type {AnyQueryDataSource} from '../../types';\nimport {normalizeStatus} from '../../utils/normalizeStatus';\n\nimport type {AnyPlainQueryDataSource, QueryObserverExtendedOptions} from './types';\nimport {composeOptions} from './utils';\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 composedOptions = composeOptions(context, dataSource, params, options);\n\n const extendedOptions = useQueryDataOptions(composedOptions);\n\n const result = useQuery(extendedOptions);\n\n return {\n ...result,\n status: normalizeStatus(result.status, result.fetchStatus),\n originalStatus: result.status,\n } as DataSourceState<TDataSource>;\n};\n\nexport function useQueryDataOptions<TDataSource extends AnyQueryDataSource>(\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 refetchInterval: refetchIntervalOption,\n queryFn: queryFnOption,\n ...restOptions\n } = composedOptions || {};\n\n const {refetchInterval, queryFn} = useRefetchInterval(refetchIntervalOption, queryFnOption);\n\n return {...restOptions, refetchInterval, queryFn};\n}\n"],"mappings":";;;AAAA,SAAmCA,QAAQ,QAAO,uBAAuB;AAYzE,SAAQC,kBAAkB,QAAO,gCAAgC;AAEjE,SAAQC,eAAe,QAAO,6BAA6B;AAG3D,SAAQC,cAAc,QAAO,SAAS;AAEtC,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAC1BC,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAClB;EAC/B,IAAMC,eAAe,GAAGN,cAAc,CAACE,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,CAAC;EAE5E,IAAME,eAAe,GAAGC,mBAAmB,CAACF,eAAe,CAAC;EAE5D,IAAMG,MAAM,GAAGZ,QAAQ,CAACU,eAAe,CAAC;EAExC,OAAAG,aAAA,CAAAA,aAAA,KACOD,MAAM;IACTE,MAAM,EAAEZ,eAAe,CAACU,MAAM,CAACE,MAAM,EAAEF,MAAM,CAACG,WAAW,CAAC;IAC1DC,cAAc,EAAEJ,MAAM,CAACE;EAAM;AAErC,CAAC;AAED,OAAO,SAASH,mBAAmBA,CAC/BF,eAMC,EAOH;EACE,IAAAQ,IAAA,GAIIR,eAAe,IAAI,CAAC,CAAC;IAHJS,qBAAqB,GAAAD,IAAA,CAAtCE,eAAe;IACNC,aAAa,GAAAH,IAAA,CAAtBI,OAAO;IACJC,WAAW,GAAAC,wBAAA,CAAAN,IAAA,EAAAO,SAAA;EAGlB,IAAAC,mBAAA,GAAmCxB,kBAAkB,CAACiB,qBAAqB,EAAEE,aAAa,CAAC;IAApFD,eAAe,GAAAM,mBAAA,CAAfN,eAAe;IAAEE,OAAO,GAAAI,mBAAA,CAAPJ,OAAO;EAE/B,OAAAR,aAAA,CAAAA,aAAA,KAAWS,WAAW;IAAEH,eAAe,EAAfA,eAAe;IAAEE,OAAO,EAAPA;EAAO;AACpD","ignoreList":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
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
|
-
export type
|
|
4
|
+
import type { QueryDataExtendedOptions, QueryDataSourceContext } from '../../types';
|
|
5
|
+
export type QueryObserverExtendedOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, 'refetchInterval'> & QueryDataExtendedOptions<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
6
|
+
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
7
|
type: 'plain';
|
|
7
8
|
};
|
|
8
9
|
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 {QueryDataExtendedOptions, QueryDataSourceContext} from '../../types';\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> = Omit<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>,\n 'refetchInterval'\n> &\n QueryDataExtendedOptions<TQueryFnData, TError, TQueryData, TQueryKey>;\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,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export declare const composeOptions: <TDataSource extends AnyPlainQueryDataSource>(context: DataSourceContext<TDataSource>, dataSource: TDataSource, params: DataSourceParams<TDataSource>, options?: Partial<DataSourceOptions<TDataSource>>) => QueryObserverOptions<DataSourceResponse<TDataSource>, DataSourceError<TDataSource>, DataSourceData<TDataSource>, DataSourceResponse<TDataSource>, DataSourceKey>;
|
|
5
|
-
export declare const transformResult: <TDataSource extends AnyPlainQueryDataSource>(result: QueryObserverResult<DataSourceData<TDataSource>, DataSourceError<TDataSource>>) => DataSourceState<TDataSource>;
|
|
1
|
+
import type { DataSourceContext, DataSourceData, DataSourceError, DataSourceKey, DataSourceOptions, DataSourceParams, DataSourceResponse } from '../../../core';
|
|
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,7 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
2
|
import { skipToken } from '@tanstack/react-query';
|
|
3
3
|
import { composeFullKey, idle } from '../../../core';
|
|
4
|
-
import { normalizeStatus } from '../../utils/normalizeStatus';
|
|
5
4
|
export var composeOptions = function composeOptions(context, dataSource, params, options) {
|
|
6
5
|
var transformParams = dataSource.transformParams;
|
|
7
6
|
var queryFn = function queryFn(fetchContext) {
|
|
@@ -13,10 +12,4 @@ export var composeOptions = function composeOptions(context, dataSource, params,
|
|
|
13
12
|
select: dataSource.transformResponse
|
|
14
13
|
}, dataSource.options), options);
|
|
15
14
|
};
|
|
16
|
-
export var transformResult = function transformResult(result) {
|
|
17
|
-
return _objectSpread(_objectSpread({}, result), {}, {
|
|
18
|
-
status: normalizeStatus(result.status, result.fetchStatus),
|
|
19
|
-
originalStatus: result.status
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
15
|
// #sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["skipToken","composeFullKey","idle","
|
|
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,4 @@
|
|
|
1
|
-
export type { QueryDataSourceContext, AnyQueryDataSource } from './types';
|
|
1
|
+
export type { QueryDataSourceContext, AnyQueryDataSource, ProgressiveRefetchInterval, RefetchInterval, RefetchIntervalFunction, } from './types';
|
|
2
2
|
export { useQueryContext } from './hooks/useQueryContext';
|
|
3
3
|
export { useQueryData } from './hooks/useQueryData';
|
|
4
4
|
export { useQueryResponses } from './hooks/useQueryResponses';
|
|
@@ -11,5 +11,6 @@ export type { PlainQueryDataSource, AnyPlainQueryDataSource } from './impl/plain
|
|
|
11
11
|
export { makePlainQueryDataSource } from './impl/plain/factory';
|
|
12
12
|
export { composeOptions as composePlainQueryOptions } from './impl/plain/utils';
|
|
13
13
|
export { normalizeStatus } from './utils/normalizeStatus';
|
|
14
|
+
export { getProgressiveRefetch } from './utils/getProgressiveRefetch';
|
|
14
15
|
export type { ClientDataManagerConfig } from './ClientDataManager';
|
|
15
16
|
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
|
|
1
|
+
{"version":3,"names":["useQueryContext","useQueryData","useQueryResponses","useRefetchAll","useRefetchErrored","makeInfiniteQueryDataSource","composeOptions","composeInfiniteQueryOptions","makePlainQueryDataSource","composePlainQueryOptions","normalizeStatus","getProgressiveRefetch","ClientDataManager"],"sources":["index.ts"],"sourcesContent":["export type {\n QueryDataSourceContext,\n AnyQueryDataSource,\n ProgressiveRefetchInterval,\n RefetchInterval,\n RefetchIntervalFunction,\n} 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';\nexport {getProgressiveRefetch} from './utils/getProgressiveRefetch';\n\nexport type {ClientDataManagerConfig} from './ClientDataManager';\nexport {ClientDataManager} from './ClientDataManager';\n"],"mappings":"AAQA,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;AACvD,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 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './base';\nexport * from './refetch-interval';\n"],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
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>;
|
|
4
|
+
export interface ProgressiveRefetchInterval {
|
|
5
|
+
minInterval: number;
|
|
6
|
+
maxInterval: number;
|
|
7
|
+
}
|
|
8
|
+
export interface QueryDataExtendedOptions<TQueryFnData = unknown, TError = DefaultError, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> {
|
|
9
|
+
refetchInterval?: RefetchInterval<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
10
|
+
}
|
|
@@ -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\nexport interface ProgressiveRefetchInterval {\n minInterval: number;\n maxInterval: number;\n}\n\nexport interface QueryDataExtendedOptions<\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 { QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import type { ProgressiveRefetchInterval, RefetchIntervalFunction } from '../types';
|
|
3
|
+
export declare const getProgressiveRefetch: <TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>({ minInterval, maxInterval, }: ProgressiveRefetchInterval) => RefetchIntervalFunction<TQueryFnData, TError, TData, TQueryKey>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var BASE = 2;
|
|
2
|
+
export var getProgressiveRefetch = function getProgressiveRefetch(_ref) {
|
|
3
|
+
var minInterval = _ref.minInterval,
|
|
4
|
+
maxInterval = _ref.maxInterval;
|
|
5
|
+
return function (_, queryRefetchCount) {
|
|
6
|
+
return Math.min(minInterval * Math.pow(BASE, queryRefetchCount), maxInterval);
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
// #sourceMappingURL=getProgressiveRefetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BASE","getProgressiveRefetch","_ref","minInterval","maxInterval","_","queryRefetchCount","Math","min","pow"],"sources":["getProgressiveRefetch.ts"],"sourcesContent":["import type {DefaultError, QueryKey} from '@tanstack/react-query';\n\nimport type {ProgressiveRefetchInterval, RefetchIntervalFunction} from '../types';\n\nconst BASE = 2;\n\nexport const getProgressiveRefetch = <\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>({\n minInterval,\n maxInterval,\n}: ProgressiveRefetchInterval): RefetchIntervalFunction<TQueryFnData, TError, TData, TQueryKey> => {\n return (_, queryRefetchCount) => {\n return Math.min(minInterval * BASE ** queryRefetchCount, maxInterval);\n };\n};\n"],"mappings":"AAIA,IAAMA,IAAI,GAAG,CAAC;AAEd,OAAO,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAAC,IAAA,EAQiE;EAAA,IAF/FC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IACXC,WAAW,GAAAF,IAAA,CAAXE,WAAW;EAEX,OAAO,UAACC,CAAC,EAAEC,iBAAiB,EAAK;IAC7B,OAAOC,IAAI,CAACC,GAAG,CAACL,WAAW,GAAAI,IAAA,CAAAE,GAAA,CAAGT,IAAI,EAAIM,iBAAiB,GAAEF,WAAW,CAAC;EACzE,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":[]}
|