@gravity-ui/data-source 0.4.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 +19 -1
- 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 +3 -3
- 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 +19 -1
- 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 +2 -3
- 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 +18 -1
- 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 +3 -3
- 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 +18 -1
- 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 +2 -3
- 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,13 +1,30 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
2
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
|
+
var _excluded = ["refetchInterval", "queryFn"];
|
|
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';
|
|
5
8
|
export var usePlainQueryData = function usePlainQueryData(context, dataSource, params, options) {
|
|
6
9
|
var composedOptions = composeOptions(context, dataSource, params, options);
|
|
7
|
-
var
|
|
10
|
+
var extendedOptions = useQueryDataOptions(composedOptions);
|
|
11
|
+
var result = useQuery(extendedOptions);
|
|
8
12
|
return _objectSpread(_objectSpread({}, result), {}, {
|
|
9
13
|
status: normalizeStatus(result.status, result.fetchStatus),
|
|
10
14
|
originalStatus: result.status
|
|
11
15
|
});
|
|
12
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
|
+
}
|
|
13
30
|
// #sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useQuery","normalizeStatus","composeOptions","usePlainQueryData","context","dataSource","params","options","composedOptions","result","_objectSpread","status","fetchStatus","originalStatus"],"sources":["hooks.ts"],"sourcesContent":["import {useQuery} from '@tanstack/react-query';\n\nimport type {\n DataSourceContext,\n DataSourceOptions,\n DataSourceParams,\n DataSourceState,\n} from '../../../core';\nimport {normalizeStatus} from '../../utils/normalizeStatus';\n\nimport type {AnyPlainQueryDataSource} 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 const result = 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,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,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":[]}
|