@gravity-ui/data-source 0.6.1 → 0.7.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.
Files changed (177) hide show
  1. package/build/cjs/core/index.d.ts +2 -1
  2. package/build/cjs/core/index.js +7 -0
  3. package/build/cjs/core/index.js.map +1 -1
  4. package/build/cjs/core/types/DataSource.d.ts +15 -19
  5. package/build/cjs/core/types/DataSource.js.map +1 -1
  6. package/build/cjs/core/utils/__tests__/composeFullKey.test.js +34 -0
  7. package/build/cjs/core/utils/__tests__/composeFullKey.test.js.map +1 -0
  8. package/build/cjs/core/utils/__tests__/composeKey.test.js +32 -0
  9. package/build/cjs/core/utils/__tests__/composeKey.test.js.map +1 -0
  10. package/build/cjs/core/utils/__tests__/getError.test.js +31 -0
  11. package/build/cjs/core/utils/__tests__/getError.test.js.map +1 -0
  12. package/build/cjs/core/utils/__tests__/getStatus.test.js +49 -0
  13. package/build/cjs/core/utils/__tests__/getStatus.test.js.map +1 -0
  14. package/build/cjs/core/utils/__tests__/hasTag.test.js +31 -0
  15. package/build/cjs/core/utils/__tests__/hasTag.test.js.map +1 -0
  16. package/build/cjs/core/utils/__tests__/mergeStatuses.test.js +25 -0
  17. package/build/cjs/core/utils/__tests__/mergeStatuses.test.js.map +1 -0
  18. package/build/cjs/core/utils/__tests__/skipContext.test.js +70 -0
  19. package/build/cjs/core/utils/__tests__/skipContext.test.js.map +1 -0
  20. package/build/cjs/core/utils/__tests__/withCancellation.test.js +106 -0
  21. package/build/cjs/core/utils/__tests__/withCancellation.test.js.map +1 -0
  22. package/build/cjs/core/utils/__tests__/withCatch.test.js +208 -0
  23. package/build/cjs/core/utils/__tests__/withCatch.test.js.map +1 -0
  24. package/build/cjs/core/utils/withCatch.d.ts +26 -0
  25. package/build/cjs/core/utils/withCatch.js +37 -0
  26. package/build/cjs/core/utils/withCatch.js.map +1 -0
  27. package/build/cjs/react/__tests__/DataManagerContext.test.js +46 -0
  28. package/build/cjs/react/__tests__/DataManagerContext.test.js.map +1 -0
  29. package/build/cjs/react/__tests__/withDataManager.test.js +58 -0
  30. package/build/cjs/react/__tests__/withDataManager.test.js.map +1 -0
  31. package/build/cjs/react/components/DataInfiniteLoader/__tests__/DataInfiniteLoader.test.js +187 -0
  32. package/build/cjs/react/components/DataInfiniteLoader/__tests__/DataInfiniteLoader.test.js.map +1 -0
  33. package/build/cjs/react/components/DataLoader/__tests__/DataLoader.test.js +119 -0
  34. package/build/cjs/react/components/DataLoader/__tests__/DataLoader.test.js.map +1 -0
  35. package/build/cjs/react/withDataManager.d.ts +1 -1
  36. package/build/cjs/react/withDataManager.js +3 -3
  37. package/build/cjs/react/withDataManager.js.map +1 -1
  38. package/build/cjs/react-query/constants.d.ts +2 -0
  39. package/build/cjs/react-query/constants.js +9 -0
  40. package/build/cjs/react-query/constants.js.map +1 -0
  41. package/build/cjs/react-query/hooks/__tests__/useQueryContext.test.js +55 -0
  42. package/build/cjs/react-query/hooks/__tests__/useQueryContext.test.js.map +1 -0
  43. package/build/cjs/react-query/hooks/__tests__/useQueryData.test.js +97 -0
  44. package/build/cjs/react-query/hooks/__tests__/useQueryData.test.js.map +1 -0
  45. package/build/cjs/react-query/hooks/__tests__/useQueryResponses.test.js +77 -0
  46. package/build/cjs/react-query/hooks/__tests__/useQueryResponses.test.js.map +1 -0
  47. package/build/cjs/react-query/hooks/__tests__/useRefetchAll.test.js +79 -0
  48. package/build/cjs/react-query/hooks/__tests__/useRefetchAll.test.js.map +1 -0
  49. package/build/cjs/react-query/hooks/__tests__/useRefetchErrored.test.js +117 -0
  50. package/build/cjs/react-query/hooks/__tests__/useRefetchErrored.test.js.map +1 -0
  51. package/build/cjs/react-query/hooks/__tests__/useRefetchInterval.test.js +156 -0
  52. package/build/cjs/react-query/hooks/__tests__/useRefetchInterval.test.js.map +1 -0
  53. package/build/cjs/react-query/hooks/useRefetchInterval.d.ts +1 -1
  54. package/build/cjs/react-query/impl/infinite/factory.d.ts +1 -1
  55. package/build/cjs/react-query/impl/infinite/factory.js.map +1 -1
  56. package/build/cjs/react-query/impl/infinite/types.d.ts +7 -7
  57. package/build/cjs/react-query/impl/infinite/types.js.map +1 -1
  58. package/build/cjs/react-query/impl/infinite/utils.js +11 -22
  59. package/build/cjs/react-query/impl/infinite/utils.js.map +1 -1
  60. package/build/cjs/react-query/impl/plain/factory.d.ts +1 -1
  61. package/build/cjs/react-query/impl/plain/factory.js.map +1 -1
  62. package/build/cjs/react-query/impl/plain/types.d.ts +4 -4
  63. package/build/cjs/react-query/impl/plain/types.js.map +1 -1
  64. package/build/cjs/react-query/impl/plain/utils.js +12 -23
  65. package/build/cjs/react-query/impl/plain/utils.js.map +1 -1
  66. package/build/cjs/react-query/utils/__tests__/formatNullableValue.test.js +27 -0
  67. package/build/cjs/react-query/utils/__tests__/formatNullableValue.test.js.map +1 -0
  68. package/build/cjs/react-query/utils/__tests__/getProgressiveRefetch.test.js +76 -0
  69. package/build/cjs/react-query/utils/__tests__/getProgressiveRefetch.test.js.map +1 -0
  70. package/build/cjs/react-query/utils/__tests__/normalizeStatus.test.js +30 -0
  71. package/build/cjs/react-query/utils/__tests__/normalizeStatus.test.js.map +1 -0
  72. package/build/cjs/react-query/utils/__tests__/notReachable.test.js +35 -0
  73. package/build/cjs/react-query/utils/__tests__/notReachable.test.js.map +1 -0
  74. package/build/cjs/react-query/utils/__tests__/parseNullableValue.test.js +27 -0
  75. package/build/cjs/react-query/utils/__tests__/parseNullableValue.test.js.map +1 -0
  76. package/build/cjs/react-query/utils/formatNullableValue.d.ts +2 -0
  77. package/build/cjs/react-query/utils/formatNullableValue.js +17 -0
  78. package/build/cjs/react-query/utils/formatNullableValue.js.map +1 -0
  79. package/build/cjs/react-query/utils/getProgressiveRefetch.d.ts +2 -2
  80. package/build/cjs/react-query/utils/parseNullableValue.d.ts +2 -0
  81. package/build/cjs/react-query/utils/parseNullableValue.js +17 -0
  82. package/build/cjs/react-query/utils/parseNullableValue.js.map +1 -0
  83. package/build/cjs/setupTests.d.ts +1 -0
  84. package/build/cjs/setupTests.js +4 -0
  85. package/build/cjs/setupTests.js.map +1 -0
  86. package/build/esm/core/index.d.ts +2 -1
  87. package/build/esm/core/index.js +1 -0
  88. package/build/esm/core/index.js.map +1 -1
  89. package/build/esm/core/types/DataSource.d.ts +15 -19
  90. package/build/esm/core/types/DataSource.js.map +1 -1
  91. package/build/esm/core/utils/__tests__/composeFullKey.test.js +32 -0
  92. package/build/esm/core/utils/__tests__/composeFullKey.test.js.map +1 -0
  93. package/build/esm/core/utils/__tests__/composeKey.test.js +30 -0
  94. package/build/esm/core/utils/__tests__/composeKey.test.js.map +1 -0
  95. package/build/esm/core/utils/__tests__/getError.test.js +29 -0
  96. package/build/esm/core/utils/__tests__/getError.test.js.map +1 -0
  97. package/build/esm/core/utils/__tests__/getStatus.test.js +47 -0
  98. package/build/esm/core/utils/__tests__/getStatus.test.js.map +1 -0
  99. package/build/esm/core/utils/__tests__/hasTag.test.js +29 -0
  100. package/build/esm/core/utils/__tests__/hasTag.test.js.map +1 -0
  101. package/build/esm/core/utils/__tests__/mergeStatuses.test.js +23 -0
  102. package/build/esm/core/utils/__tests__/mergeStatuses.test.js.map +1 -0
  103. package/build/esm/core/utils/__tests__/skipContext.test.js +67 -0
  104. package/build/esm/core/utils/__tests__/skipContext.test.js.map +1 -0
  105. package/build/esm/core/utils/__tests__/withCancellation.test.js +104 -0
  106. package/build/esm/core/utils/__tests__/withCancellation.test.js.map +1 -0
  107. package/build/esm/core/utils/__tests__/withCatch.test.js +205 -0
  108. package/build/esm/core/utils/__tests__/withCatch.test.js.map +1 -0
  109. package/build/esm/core/utils/withCatch.d.ts +26 -0
  110. package/build/esm/core/utils/withCatch.js +31 -0
  111. package/build/esm/core/utils/withCatch.js.map +1 -0
  112. package/build/esm/react/__tests__/DataManagerContext.test.js +43 -0
  113. package/build/esm/react/__tests__/DataManagerContext.test.js.map +1 -0
  114. package/build/esm/react/__tests__/withDataManager.test.js +55 -0
  115. package/build/esm/react/__tests__/withDataManager.test.js.map +1 -0
  116. package/build/esm/react/components/DataInfiniteLoader/__tests__/DataInfiniteLoader.test.js +184 -0
  117. package/build/esm/react/components/DataInfiniteLoader/__tests__/DataInfiniteLoader.test.js.map +1 -0
  118. package/build/esm/react/components/DataLoader/__tests__/DataLoader.test.js +116 -0
  119. package/build/esm/react/components/DataLoader/__tests__/DataLoader.test.js.map +1 -0
  120. package/build/esm/react/withDataManager.d.ts +1 -1
  121. package/build/esm/react/withDataManager.js +3 -3
  122. package/build/esm/react/withDataManager.js.map +1 -1
  123. package/build/esm/react-query/constants.d.ts +2 -0
  124. package/build/esm/react-query/constants.js +3 -0
  125. package/build/esm/react-query/constants.js.map +1 -0
  126. package/build/esm/react-query/hooks/__tests__/useQueryContext.test.js +52 -0
  127. package/build/esm/react-query/hooks/__tests__/useQueryContext.test.js.map +1 -0
  128. package/build/esm/react-query/hooks/__tests__/useQueryData.test.js +95 -0
  129. package/build/esm/react-query/hooks/__tests__/useQueryData.test.js.map +1 -0
  130. package/build/esm/react-query/hooks/__tests__/useQueryResponses.test.js +74 -0
  131. package/build/esm/react-query/hooks/__tests__/useQueryResponses.test.js.map +1 -0
  132. package/build/esm/react-query/hooks/__tests__/useRefetchAll.test.js +77 -0
  133. package/build/esm/react-query/hooks/__tests__/useRefetchAll.test.js.map +1 -0
  134. package/build/esm/react-query/hooks/__tests__/useRefetchErrored.test.js +115 -0
  135. package/build/esm/react-query/hooks/__tests__/useRefetchErrored.test.js.map +1 -0
  136. package/build/esm/react-query/hooks/__tests__/useRefetchInterval.test.js +154 -0
  137. package/build/esm/react-query/hooks/__tests__/useRefetchInterval.test.js.map +1 -0
  138. package/build/esm/react-query/hooks/useRefetchInterval.d.ts +1 -1
  139. package/build/esm/react-query/impl/infinite/factory.d.ts +1 -1
  140. package/build/esm/react-query/impl/infinite/factory.js.map +1 -1
  141. package/build/esm/react-query/impl/infinite/types.d.ts +7 -7
  142. package/build/esm/react-query/impl/infinite/types.js.map +1 -1
  143. package/build/esm/react-query/impl/infinite/utils.js +9 -20
  144. package/build/esm/react-query/impl/infinite/utils.js.map +1 -1
  145. package/build/esm/react-query/impl/plain/factory.d.ts +1 -1
  146. package/build/esm/react-query/impl/plain/factory.js.map +1 -1
  147. package/build/esm/react-query/impl/plain/types.d.ts +4 -4
  148. package/build/esm/react-query/impl/plain/types.js.map +1 -1
  149. package/build/esm/react-query/impl/plain/utils.js +10 -21
  150. package/build/esm/react-query/impl/plain/utils.js.map +1 -1
  151. package/build/esm/react-query/utils/__tests__/formatNullableValue.test.js +25 -0
  152. package/build/esm/react-query/utils/__tests__/formatNullableValue.test.js.map +1 -0
  153. package/build/esm/react-query/utils/__tests__/getProgressiveRefetch.test.js +74 -0
  154. package/build/esm/react-query/utils/__tests__/getProgressiveRefetch.test.js.map +1 -0
  155. package/build/esm/react-query/utils/__tests__/normalizeStatus.test.js +28 -0
  156. package/build/esm/react-query/utils/__tests__/normalizeStatus.test.js.map +1 -0
  157. package/build/esm/react-query/utils/__tests__/notReachable.test.js +33 -0
  158. package/build/esm/react-query/utils/__tests__/notReachable.test.js.map +1 -0
  159. package/build/esm/react-query/utils/__tests__/parseNullableValue.test.js +25 -0
  160. package/build/esm/react-query/utils/__tests__/parseNullableValue.test.js.map +1 -0
  161. package/build/esm/react-query/utils/formatNullableValue.d.ts +2 -0
  162. package/build/esm/react-query/utils/formatNullableValue.js +11 -0
  163. package/build/esm/react-query/utils/formatNullableValue.js.map +1 -0
  164. package/build/esm/react-query/utils/getProgressiveRefetch.d.ts +2 -2
  165. package/build/esm/react-query/utils/parseNullableValue.d.ts +2 -0
  166. package/build/esm/react-query/utils/parseNullableValue.js +11 -0
  167. package/build/esm/react-query/utils/parseNullableValue.js.map +1 -0
  168. package/build/esm/setupTests.d.ts +1 -0
  169. package/build/esm/setupTests.js +2 -0
  170. package/build/esm/setupTests.js.map +1 -0
  171. package/package.json +17 -13
  172. package/build/cjs/react-query/impl/utils.d.ts +0 -4
  173. package/build/cjs/react-query/impl/utils.js +0 -27
  174. package/build/cjs/react-query/impl/utils.js.map +0 -1
  175. package/build/esm/react-query/impl/utils.d.ts +0 -4
  176. package/build/esm/react-query/impl/utils.js +0 -21
  177. package/build/esm/react-query/impl/utils.js.map +0 -1
@@ -1,19 +1,19 @@
1
1
  import type { DefaultError, InfiniteData, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, QueryFunctionContext, QueryKey } from '@tanstack/react-query';
2
2
  import type { Overwrite } from 'utility-types';
3
- import type { ActualData, ActualResponse, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
3
+ import type { ActualData, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
4
4
  import type { QueryDataSourceContext } from '../../types/base';
5
5
  import type { QueryDataAdditionalOptions } from '../../types/options';
6
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, TErrorResponse> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, TErrorResponse, InfiniteQueryObserverExtendedOptions<ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>, NoInfer<TError>, InfiniteData<ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>, Partial<NoInfer<TRequest>>>, ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>, DataSourceKey, Partial<NoInfer<TRequest>>>, ResultWrapper<InfiniteQueryObserverResult<InfiniteData<ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>, Partial<NoInfer<TRequest>>>, NoInfer<TError>>, NoInfer<TRequest>, NoInfer<TResponse>, NoInfer<TData>, NoInfer<TError>, NoInfer<TErrorResponse>>, QueryFunctionContext<DataSourceKey, Partial<NoInfer<TRequest>>>> & {
7
+ export type InfiniteQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, InfiniteQueryObserverExtendedOptions<NoInfer<TResponse>, NoInfer<TError>, InfiniteData<ActualData<NoInfer<TData>, NoInfer<TResponse>>, Partial<TRequest>>, NoInfer<TResponse>, DataSourceKey, Partial<NoInfer<TRequest>>>, ResultWrapper<InfiniteQueryObserverResult<InfiniteData<ActualData<NoInfer<TData>, NoInfer<TResponse>>, Partial<TRequest>>, NoInfer<TError>>, NoInfer<TRequest>, NoInfer<TResponse>, NoInfer<TData>, NoInfer<TError>>, QueryFunctionContext<DataSourceKey, Partial<NoInfer<TRequest>>>> & {
8
8
  type: 'infinite';
9
- next: (lastPage: ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>, allPages: Array<ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>>) => Partial<NoInfer<TRequest>> | undefined | null;
10
- prev?: (firstPage: ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>, allPages: Array<ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>>) => Partial<NoInfer<TRequest>> | undefined | null;
9
+ next: (lastPage: NoInfer<TResponse>, allPages: NoInfer<TResponse>[]) => Partial<NoInfer<TRequest>> | null | undefined;
10
+ prev?: (firstPage: NoInfer<TResponse>, allPages: NoInfer<TResponse>[]) => Partial<NoInfer<TRequest>> | null | undefined;
11
11
  };
12
- export type AnyInfiniteQueryDataSource = InfiniteQueryDataSource<any, any, any, any, any, any>;
12
+ export type AnyInfiniteQueryDataSource = InfiniteQueryDataSource<any, any, any, any, any>;
13
13
  export type AnyPageParam = Partial<any>;
14
- type ResultWrapper<TResult, TRequest, TResponse, TData, TError, TErrorResponse> = TResult extends InfiniteQueryObserverResult<InfiniteData<ActualData<TResponse, TData, TErrorResponse>, Partial<TRequest>>, TError> ? Overwrite<TResult, {
14
+ type ResultWrapper<TResult, TRequest, TResponse, TData, TError> = TResult extends InfiniteQueryObserverResult<InfiniteData<ActualData<TData, TResponse>, Partial<TRequest>>, TError> ? Overwrite<TResult, {
15
15
  status: DataLoaderStatus;
16
- data: Array<FlatArray<Array<ActualData<TResponse, TData, TErrorResponse>>, 1>>;
16
+ data: Array<FlatArray<Array<ActualData<TData, TResponse>>, 1>>;
17
17
  }> & {
18
18
  originalStatus: TResult['status'];
19
19
  originalData: TResult['data'];
@@ -1 +1 @@
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 {\n ActualData,\n ActualResponse,\n DataLoaderStatus,\n DataSource,\n DataSourceKey,\n} 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, TErrorResponse> =\n DataSource<\n QueryDataSourceContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n TErrorResponse,\n InfiniteQueryObserverExtendedOptions<\n ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n NoInfer<TError>,\n InfiniteData<\n ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>,\n Partial<NoInfer<TRequest>>\n >,\n ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n DataSourceKey,\n Partial<NoInfer<TRequest>>\n >,\n ResultWrapper<\n InfiniteQueryObserverResult<\n InfiniteData<\n ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>,\n Partial<NoInfer<TRequest>>\n >,\n NoInfer<TError>\n >,\n NoInfer<TRequest>,\n NoInfer<TResponse>,\n NoInfer<TData>,\n NoInfer<TError>,\n NoInfer<TErrorResponse>\n >,\n QueryFunctionContext<DataSourceKey, Partial<NoInfer<TRequest>>>\n > & {\n type: 'infinite';\n next: (\n lastPage: ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n allPages: Array<ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>>,\n ) => Partial<NoInfer<TRequest>> | undefined | null;\n prev?: (\n firstPage: ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n allPages: Array<ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>>,\n ) => Partial<NoInfer<TRequest>> | undefined | null;\n };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyInfiniteQueryDataSource = InfiniteQueryDataSource<any, 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, TErrorResponse> =\n TResult extends InfiniteQueryObserverResult<\n InfiniteData<ActualData<TResponse, TData, TErrorResponse>, Partial<TRequest>>,\n TError\n >\n ? Overwrite<\n TResult,\n {\n status: DataLoaderStatus;\n data: Array<FlatArray<Array<ActualData<TResponse, TData, TErrorResponse>>, 1>>;\n }\n > & {\n originalStatus: TResult['status'];\n originalData: TResult['data'];\n }\n : never;\n"],"mappings":"","ignoreList":[]}
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 NoInfer<TResponse>,\n NoInfer<TError>,\n InfiniteData<ActualData<NoInfer<TData>, NoInfer<TResponse>>, Partial<TRequest>>,\n NoInfer<TResponse>,\n DataSourceKey,\n Partial<NoInfer<TRequest>>\n >,\n ResultWrapper<\n InfiniteQueryObserverResult<\n InfiniteData<ActualData<NoInfer<TData>, NoInfer<TResponse>>, Partial<TRequest>>,\n NoInfer<TError>\n >,\n NoInfer<TRequest>,\n NoInfer<TResponse>,\n NoInfer<TData>,\n NoInfer<TError>\n >,\n QueryFunctionContext<DataSourceKey, Partial<NoInfer<TRequest>>>\n> & {\n type: 'infinite';\n next: (\n lastPage: NoInfer<TResponse>,\n allPages: NoInfer<TResponse>[],\n ) => Partial<NoInfer<TRequest>> | null | undefined;\n prev?: (\n firstPage: NoInfer<TResponse>,\n allPages: NoInfer<TResponse>[],\n ) => Partial<NoInfer<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,45 +1,34 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/regeneratorRuntime";
1
2
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import { skipToken } from '@tanstack/react-query';
5
5
  import { composeFullKey, idle } from '../../../core';
6
- import { formatNullableValue, parseNullableValue } from '../utils';
6
+ import { formatNullableValue } from '../../utils/formatNullableValue';
7
+ import { parseNullableValue } from '../../utils/parseNullableValue';
7
8
  var EMPTY_OBJECT = {};
8
9
  export var composeOptions = function composeOptions(context, dataSource, params, options) {
9
10
  var transformParams = dataSource.transformParams,
10
- transformError = dataSource.transformError,
11
11
  transformResponse = dataSource.transformResponse,
12
12
  next = dataSource.next,
13
13
  prev = dataSource.prev;
14
14
  var queryFn = /*#__PURE__*/function () {
15
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fetchContext) {
15
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetchContext) {
16
16
  var request, paginatedRequest, response;
17
- return _regeneratorRuntime.wrap(function _callee$(_context) {
17
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
18
18
  while (1) switch (_context.prev = _context.next) {
19
19
  case 0:
20
20
  request = transformParams ? transformParams(params) : params;
21
21
  paginatedRequest = _objectSpread(_objectSpread({}, request), fetchContext.pageParam);
22
- _context.prev = 2;
23
- _context.next = 5;
22
+ _context.next = 4;
24
23
  return dataSource.fetch(context, fetchContext, paginatedRequest);
25
- case 5:
24
+ case 4:
26
25
  response = _context.sent;
27
26
  return _context.abrupt("return", formatNullableValue(response));
28
- case 9:
29
- _context.prev = 9;
30
- _context.t0 = _context["catch"](2);
31
- if (transformError) {
32
- _context.next = 13;
33
- break;
34
- }
35
- throw _context.t0;
36
- case 13:
37
- return _context.abrupt("return", formatNullableValue(transformError(_context.t0)));
38
- case 14:
27
+ case 6:
39
28
  case "end":
40
29
  return _context.stop();
41
30
  }
42
- }, _callee, null, [[2, 9]]);
31
+ }, _callee);
43
32
  }));
44
33
  return function queryFn(_x) {
45
34
  return _ref.apply(this, arguments);
@@ -1 +1 @@
1
- {"version":3,"names":["skipToken","composeFullKey","idle","formatNullableValue","parseNullableValue","EMPTY_OBJECT","composeOptions","context","dataSource","params","options","transformParams","transformError","transformResponse","next","prev","queryFn","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","fetchContext","request","paginatedRequest","response","wrap","_callee$","_context","_objectSpread","pageParam","fetch","sent","abrupt","t0","stop","_x","apply","arguments","selectPage","actualResponse","queryKey","select","data","pages","map","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';\nimport type {nullSymbol, undefinedSymbol} from '../utils';\nimport {formatNullableValue, parseNullableValue} from '../utils';\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, transformError, transformResponse, next, prev} = dataSource;\n\n const queryFn = async (\n fetchContext: QueryFunctionContext<DataSourceKey, AnyPageParam>,\n ): Promise<DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol> => {\n const request = transformParams ? transformParams(params) : params;\n const paginatedRequest = {...request, ...fetchContext.pageParam};\n\n try {\n const response = await dataSource.fetch(context, fetchContext, paginatedRequest);\n\n return formatNullableValue(response);\n } catch (error) {\n if (!transformError) {\n throw error;\n }\n\n return formatNullableValue(transformError(error));\n }\n };\n\n const selectPage = (\n response: DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol,\n ): DataSourceData<TDataSource> => {\n const actualResponse = parseNullableValue(response);\n\n return transformResponse ? transformResponse(actualResponse) : actualResponse;\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select: (data) => ({...data, pages: data.pages.map(selectPage)}),\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;AAWlD,SAAQC,mBAAmB,EAAEC,kBAAkB,QAAO,UAAU;AA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AN,QAAA,CAAAK,MAAA,WAIZ9B,mBAAmB,CAACS,cAAc,CAAAgB,QAAA,CAAAM,EAAM,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAN,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAd,OAAA;IAAA,CAExD;IAAA,gBAjBKL,OAAOA,CAAAoB,EAAA;MAAA,OAAAnB,IAAA,CAAAoB,KAAA,OAAAC,SAAA;IAAA;EAAA,GAiBZ;EAED,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CACZd,QAAsF,EACxD;IAC9B,IAAMe,cAAc,GAAGpC,kBAAkB,CAACqB,QAAQ,CAAC;IAEnD,OAAOZ,iBAAiB,GAAGA,iBAAiB,CAAC2B,cAAc,CAAC,GAAGA,cAAc;EACjF,CAAC;EAED,OAAAX,aAAA,CAAAA,aAAA;IACIY,QAAQ,EAAExC,cAAc,CAACO,UAAU,EAAEC,MAAM,CAAC;IAC5CO,OAAO,EAAEP,MAAM,KAAKP,IAAI,GAAGF,SAAS,GAAGgB,OAAO;IAC9C0B,MAAM,EAAE,SAARA,MAAMA,CAAGC,IAAI;MAAA,OAAAd,aAAA,CAAAA,aAAA,KAAUc,IAAI;QAAEC,KAAK,EAAED,IAAI,CAACC,KAAK,CAACC,GAAG,CAACN,UAAU;MAAC;IAAA,CAAE;IAChEO,gBAAgB,EAAEzC,YAAY;IAC9B0C,gBAAgB,EAAEjC,IAAI;IACtBkC,oBAAoB,EAAEjC;EAAI,GACvBP,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["skipToken","composeFullKey","idle","formatNullableValue","parseNullableValue","EMPTY_OBJECT","composeOptions","context","dataSource","params","options","transformParams","transformResponse","next","prev","queryFn","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","fetchContext","request","paginatedRequest","response","wrap","_callee$","_context","_objectSpread","pageParam","fetch","sent","abrupt","stop","_x","apply","arguments","selectPage","actualResponse","queryKey","select","data","pages","map","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';\nimport type {nullSymbol, undefinedSymbol} from '../../constants';\nimport {formatNullableValue} from '../../utils/formatNullableValue';\nimport {parseNullableValue} from '../../utils/parseNullableValue';\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 = async (\n fetchContext: QueryFunctionContext<DataSourceKey, AnyPageParam>,\n ): Promise<DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol> => {\n const request = transformParams ? transformParams(params) : params;\n const paginatedRequest = {...request, ...fetchContext.pageParam};\n\n const response = await dataSource.fetch(context, fetchContext, paginatedRequest);\n\n return formatNullableValue(response);\n };\n\n const selectPage = (\n response: DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol,\n ): DataSourceData<TDataSource> => {\n const actualResponse = parseNullableValue(response) as DataSourceData<TDataSource>;\n\n return transformResponse ? transformResponse(actualResponse) : actualResponse;\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select: (data) => ({...data, pages: data.pages.map(selectPage)}),\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;AAWlD,SAAQC,mBAAmB,QAAO,iCAAiC;AACnE,SAAQC,kBAAkB,QAAO,gCAAgC;AAQjE,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;IAAA,IAAAC,IAAA,GAAAC,iBAAA,cAAAC,mBAAA,GAAAC,IAAA,CAAG,SAAAC,QACZC,YAA+D;MAAA,IAAAC,OAAA,EAAAC,gBAAA,EAAAC,QAAA;MAAA,OAAAN,mBAAA,GAAAO,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAb,IAAA,GAAAa,QAAA,CAAAd,IAAA;UAAA;YAEzDS,OAAO,GAAGX,eAAe,GAAGA,eAAe,CAACF,MAAM,CAAC,GAAGA,MAAM;YAC5Dc,gBAAgB,GAAAK,aAAA,CAAAA,aAAA,KAAON,OAAO,GAAKD,YAAY,CAACQ,SAAS;YAAAF,QAAA,CAAAd,IAAA;YAAA,OAExCL,UAAU,CAACsB,KAAK,CAACvB,OAAO,EAAEc,YAAY,EAAEE,gBAAgB,CAAC;UAAA;YAA1EC,QAAQ,GAAAG,QAAA,CAAAI,IAAA;YAAA,OAAAJ,QAAA,CAAAK,MAAA,WAEP7B,mBAAmB,CAACqB,QAAQ,CAAC;UAAA;UAAA;YAAA,OAAAG,QAAA,CAAAM,IAAA;QAAA;MAAA,GAAAb,OAAA;IAAA,CACvC;IAAA,gBATKL,OAAOA,CAAAmB,EAAA;MAAA,OAAAlB,IAAA,CAAAmB,KAAA,OAAAC,SAAA;IAAA;EAAA,GASZ;EAED,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CACZb,QAAsF,EACxD;IAC9B,IAAMc,cAAc,GAAGlC,kBAAkB,CAACoB,QAAQ,CAAgC;IAElF,OAAOZ,iBAAiB,GAAGA,iBAAiB,CAAC0B,cAAc,CAAC,GAAGA,cAAc;EACjF,CAAC;EAED,OAAAV,aAAA,CAAAA,aAAA;IACIW,QAAQ,EAAEtC,cAAc,CAACO,UAAU,EAAEC,MAAM,CAAC;IAC5CM,OAAO,EAAEN,MAAM,KAAKP,IAAI,GAAGF,SAAS,GAAGe,OAAO;IAC9CyB,MAAM,EAAE,SAARA,MAAMA,CAAGC,IAAI;MAAA,OAAAb,aAAA,CAAAA,aAAA,KAAUa,IAAI;QAAEC,KAAK,EAAED,IAAI,CAACC,KAAK,CAACC,GAAG,CAACN,UAAU;MAAC;IAAA,CAAE;IAChEO,gBAAgB,EAAEvC,YAAY;IAC9BwC,gBAAgB,EAAEhC,IAAI;IACtBiC,oBAAoB,EAAEhC;EAAI,GACvBN,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
1
  import type { PlainQueryDataSource } from './types';
2
- export declare const makePlainQueryDataSource: <TParams, TRequest, TResponse, TData, TError, TErrorResponse>(config: Omit<PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse>, "type">) => PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse>;
2
+ export declare const makePlainQueryDataSource: <TParams, TRequest, TResponse, TData, TError>(config: Omit<PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError>, "type">) => PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError>;
@@ -1 +1 @@
1
- {"version":3,"names":["makePlainQueryDataSource","config","_objectSpread","type"],"sources":["factory.ts"],"sourcesContent":["import type {PlainQueryDataSource} from './types';\n\nexport const makePlainQueryDataSource = <\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n TErrorResponse,\n>(\n config: Omit<\n PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse>,\n 'type'\n >,\n): PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError, TErrorResponse> => ({\n ...config,\n type: 'plain',\n});\n"],"mappings":";AAEA,OAAO,IAAMA,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAQjCC,MAGC;EAAA,OAAAC,aAAA,CAAAA,aAAA,KAEED,MAAM;IACTE,IAAI,EAAE;EAAO;AAAA,CACf","ignoreList":[]}
1
+ {"version":3,"names":["makePlainQueryDataSource","config","_objectSpread","type"],"sources":["factory.ts"],"sourcesContent":["import type {PlainQueryDataSource} from './types';\n\nexport const makePlainQueryDataSource = <TParams, TRequest, TResponse, TData, TError>(\n config: Omit<PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError>, 'type'>,\n): PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> => ({\n ...config,\n type: 'plain',\n});\n"],"mappings":";AAEA,OAAO,IAAMA,wBAAwB,GAAG,SAA3BA,wBAAwBA,CACjCC,MAAuF;EAAA,OAAAC,aAAA,CAAAA,aAAA,KAEpFD,MAAM;IACTE,IAAI,EAAE;EAAO;AAAA,CACf","ignoreList":[]}
@@ -1,14 +1,14 @@
1
1
  import type { DefaultError, QueryFunctionContext, QueryKey, QueryObserverOptions, QueryObserverResult } from '@tanstack/react-query';
2
2
  import type { Overwrite } from 'utility-types';
3
- import type { ActualData, ActualResponse, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
3
+ import type { ActualData, DataLoaderStatus, DataSource, DataSourceKey } from '../../../core';
4
4
  import type { QueryDataSourceContext } from '../../types/base';
5
5
  import type { QueryDataAdditionalOptions } from '../../types/options';
6
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, TErrorResponse> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, TErrorResponse, QueryObserverExtendedOptions<ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>, NoInfer<TError>, ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>, ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>, DataSourceKey>, ResultWrapper<QueryObserverResult<ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>, NoInfer<TError>>, NoInfer<TResponse>, NoInfer<TData>, NoInfer<TError>, NoInfer<TErrorResponse>>, QueryFunctionContext<DataSourceKey>> & {
7
+ export type PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> = DataSource<QueryDataSourceContext, TParams, TRequest, TResponse, TData, TError, QueryObserverExtendedOptions<NoInfer<TResponse>, NoInfer<TError>, ActualData<NoInfer<TData>, NoInfer<TResponse>>, NoInfer<TResponse>, DataSourceKey>, ResultWrapper<QueryObserverResult<ActualData<NoInfer<TData>, NoInfer<TResponse>>, NoInfer<TError>>, NoInfer<TResponse>, NoInfer<TData>, NoInfer<TError>>, QueryFunctionContext<DataSourceKey>> & {
8
8
  type: 'plain';
9
9
  };
10
- export type AnyPlainQueryDataSource = PlainQueryDataSource<any, any, any, any, any, any>;
11
- type ResultWrapper<TResult, TResponse, TData, TError, TErrorResponse> = TResult extends QueryObserverResult<ActualData<TResponse, TData, TErrorResponse>, TError> ? Overwrite<TResult, {
10
+ export type AnyPlainQueryDataSource = PlainQueryDataSource<any, any, any, any, any>;
11
+ type ResultWrapper<TResult, TResponse, TData, TError> = TResult extends QueryObserverResult<ActualData<TData, TResponse>, TError> ? Overwrite<TResult, {
12
12
  status: DataLoaderStatus;
13
13
  }> & {
14
14
  originalStatus: TResult['status'];
@@ -1 +1 @@
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 {\n ActualData,\n ActualResponse,\n DataLoaderStatus,\n DataSource,\n DataSourceKey,\n} 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, TErrorResponse> =\n DataSource<\n QueryDataSourceContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n TErrorResponse,\n QueryObserverExtendedOptions<\n ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n NoInfer<TError>,\n ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>,\n ActualResponse<NoInfer<TResponse>, NoInfer<TErrorResponse>>,\n DataSourceKey\n >,\n ResultWrapper<\n QueryObserverResult<\n ActualData<NoInfer<TResponse>, NoInfer<TData>, NoInfer<TErrorResponse>>,\n NoInfer<TError>\n >,\n NoInfer<TResponse>,\n NoInfer<TData>,\n NoInfer<TError>,\n NoInfer<TErrorResponse>\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, any>;\n\ntype ResultWrapper<TResult, TResponse, TData, TError, TErrorResponse> =\n TResult extends QueryObserverResult<ActualData<TResponse, TData, TErrorResponse>, TError>\n ? Overwrite<TResult, {status: DataLoaderStatus}> & {originalStatus: TResult['status']}\n : never;\n"],"mappings":"","ignoreList":[]}
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 NoInfer<TResponse>,\n NoInfer<TError>,\n ActualData<NoInfer<TData>, NoInfer<TResponse>>,\n NoInfer<TResponse>,\n DataSourceKey\n >,\n ResultWrapper<\n QueryObserverResult<ActualData<NoInfer<TData>, NoInfer<TResponse>>, NoInfer<TError>>,\n NoInfer<TResponse>,\n NoInfer<TData>,\n NoInfer<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,40 +1,29 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import _regeneratorRuntime from "@babel/runtime/helpers/regeneratorRuntime";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import { skipToken } from '@tanstack/react-query';
5
5
  import { composeFullKey, idle } from '../../../core';
6
- import { formatNullableValue, parseNullableValue } from '../utils';
6
+ import { formatNullableValue } from '../../utils/formatNullableValue';
7
+ import { parseNullableValue } from '../../utils/parseNullableValue';
7
8
  export var composeOptions = function composeOptions(context, dataSource, params, options) {
8
9
  var transformParams = dataSource.transformParams,
9
- transformResponse = dataSource.transformResponse,
10
- transformError = dataSource.transformError;
10
+ transformResponse = dataSource.transformResponse;
11
11
  var queryFn = /*#__PURE__*/function () {
12
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fetchContext) {
12
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetchContext) {
13
13
  var response;
14
- return _regeneratorRuntime.wrap(function _callee$(_context) {
14
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
15
15
  while (1) switch (_context.prev = _context.next) {
16
16
  case 0:
17
- _context.prev = 0;
18
- _context.next = 3;
17
+ _context.next = 2;
19
18
  return dataSource.fetch(context, fetchContext, transformParams ? transformParams(params) : params);
20
- case 3:
19
+ case 2:
21
20
  response = _context.sent;
22
21
  return _context.abrupt("return", formatNullableValue(response));
23
- case 7:
24
- _context.prev = 7;
25
- _context.t0 = _context["catch"](0);
26
- if (transformError) {
27
- _context.next = 11;
28
- break;
29
- }
30
- throw _context.t0;
31
- case 11:
32
- return _context.abrupt("return", formatNullableValue(transformError(_context.t0)));
33
- case 12:
22
+ case 4:
34
23
  case "end":
35
24
  return _context.stop();
36
25
  }
37
- }, _callee, null, [[0, 7]]);
26
+ }, _callee);
38
27
  }));
39
28
  return function queryFn(_x) {
40
29
  return _ref.apply(this, arguments);
@@ -1 +1 @@
1
- {"version":3,"names":["skipToken","composeFullKey","idle","formatNullableValue","parseNullableValue","composeOptions","context","dataSource","params","options","transformParams","transformResponse","transformError","queryFn","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","fetchContext","response","wrap","_callee$","_context","prev","next","fetch","sent","abrupt","t0","stop","_x","apply","arguments","select","actualResponse","_objectSpread","queryKey"],"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';\nimport type {nullSymbol, undefinedSymbol} from '../utils';\nimport {formatNullableValue, parseNullableValue} from '../utils';\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, transformResponse, transformError} = dataSource;\n\n const queryFn = async (\n fetchContext: QueryFunctionContext<DataSourceKey>,\n ): Promise<DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol> => {\n try {\n const response = await dataSource.fetch(\n context,\n fetchContext,\n transformParams ? transformParams(params) : params,\n );\n\n return formatNullableValue(response);\n } catch (error) {\n if (!transformError) {\n throw error;\n }\n\n return formatNullableValue(transformError(error));\n }\n };\n\n const select = (\n response: DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol,\n ): DataSourceData<TDataSource> => {\n const actualResponse = parseNullableValue(response);\n\n return transformResponse ? transformResponse(actualResponse) : actualResponse;\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select,\n ...dataSource.options,\n ...options,\n };\n};\n"],"mappings":";;;AAAA,SAAmCA,SAAS,QAAO,uBAAuB;AAE1E,SAAQC,cAAc,EAAEC,IAAI,QAAO,eAAe;AAWlD,SAAQC,mBAAmB,EAAEC,kBAAkB,QAAO,UAAU;AAIhE,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,OAAuC,EACvCC,UAAuB,EACvBC,MAAqC,EACrCC,OAAiD,EAOhD;EACD,IAAOC,eAAe,GAAuCH,UAAU,CAAhEG,eAAe;IAAEC,iBAAiB,GAAoBJ,UAAU,CAA/CI,iBAAiB;IAAEC,cAAc,GAAIL,UAAU,CAA5BK,cAAc;EAEzD,IAAMC,OAAO;IAAA,IAAAC,IAAA,GAAAC,iBAAA,eAAAC,mBAAA,CAAAC,IAAA,CAAG,SAAAC,QACZC,YAAiD;MAAA,IAAAC,QAAA;MAAA,OAAAJ,mBAAA,CAAAK,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAAF,QAAA,CAAAC,IAAA;YAAAD,QAAA,CAAAE,IAAA;YAAA,OAGtBlB,UAAU,CAACmB,KAAK,CACnCpB,OAAO,EACPa,YAAY,EACZT,eAAe,GAAGA,eAAe,CAACF,MAAM,CAAC,GAAGA,MAChD,CAAC;UAAA;YAJKY,QAAQ,GAAAG,QAAA,CAAAI,IAAA;YAAA,OAAAJ,QAAA,CAAAK,MAAA,WAMPzB,mBAAmB,CAACiB,QAAQ,CAAC;UAAA;YAAAG,QAAA,CAAAC,IAAA;YAAAD,QAAA,CAAAM,EAAA,GAAAN,QAAA;YAAA,IAE/BX,cAAc;cAAAW,QAAA,CAAAE,IAAA;cAAA;YAAA;YAAA,MAAAF,QAAA,CAAAM,EAAA;UAAA;YAAA,OAAAN,QAAA,CAAAK,MAAA,WAIZzB,mBAAmB,CAACS,cAAc,CAAAW,QAAA,CAAAM,EAAM,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAN,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAZ,OAAA;IAAA,CAExD;IAAA,gBAlBKL,OAAOA,CAAAkB,EAAA;MAAA,OAAAjB,IAAA,CAAAkB,KAAA,OAAAC,SAAA;IAAA;EAAA,GAkBZ;EAED,IAAMC,MAAM,GAAG,SAATA,MAAMA,CACRd,QAAsF,EACxD;IAC9B,IAAMe,cAAc,GAAG/B,kBAAkB,CAACgB,QAAQ,CAAC;IAEnD,OAAOT,iBAAiB,GAAGA,iBAAiB,CAACwB,cAAc,CAAC,GAAGA,cAAc;EACjF,CAAC;EAED,OAAAC,aAAA,CAAAA,aAAA;IACIC,QAAQ,EAAEpC,cAAc,CAACM,UAAU,EAAEC,MAAM,CAAC;IAC5CK,OAAO,EAAEL,MAAM,KAAKN,IAAI,GAAGF,SAAS,GAAGa,OAAO;IAC9CqB,MAAM,EAANA;EAAM,GACH3B,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["skipToken","composeFullKey","idle","formatNullableValue","parseNullableValue","composeOptions","context","dataSource","params","options","transformParams","transformResponse","queryFn","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","fetchContext","response","wrap","_callee$","_context","prev","next","fetch","sent","abrupt","stop","_x","apply","arguments","select","actualResponse","_objectSpread","queryKey"],"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';\nimport type {nullSymbol, undefinedSymbol} from '../../constants';\nimport {formatNullableValue} from '../../utils/formatNullableValue';\nimport {parseNullableValue} from '../../utils/parseNullableValue';\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, transformResponse} = dataSource;\n\n const queryFn = async (\n fetchContext: QueryFunctionContext<DataSourceKey>,\n ): Promise<DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol> => {\n const response = await dataSource.fetch(\n context,\n fetchContext,\n transformParams ? transformParams(params) : params,\n );\n\n return formatNullableValue(response);\n };\n\n const select = (\n response: DataSourceResponse<TDataSource> | typeof undefinedSymbol | typeof nullSymbol,\n ): DataSourceData<TDataSource> => {\n const actualResponse = parseNullableValue(response) as DataSourceData<TDataSource>;\n\n return transformResponse ? transformResponse(actualResponse) : actualResponse;\n };\n\n return {\n queryKey: composeFullKey(dataSource, params),\n queryFn: params === idle ? skipToken : queryFn,\n select,\n ...dataSource.options,\n ...options,\n };\n};\n"],"mappings":";;;AAAA,SAAmCA,SAAS,QAAO,uBAAuB;AAE1E,SAAQC,cAAc,EAAEC,IAAI,QAAO,eAAe;AAWlD,SAAQC,mBAAmB,QAAO,iCAAiC;AACnE,SAAQC,kBAAkB,QAAO,gCAAgC;AAIjE,OAAO,IAAMC,cAAc,GAAG,SAAjBA,c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AAM,EAANA;EAAM,GACHzB,UAAU,CAACE,OAAO,GAClBA,OAAO;AAElB,CAAC","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import { nullSymbol, undefinedSymbol } from '../../constants';
2
+ import { formatNullableValue } from '../formatNullableValue';
3
+ describe('formatNullableValue', function () {
4
+ it('should return undefinedSymbol for undefined', function () {
5
+ expect(formatNullableValue(undefined)).toBe(undefinedSymbol);
6
+ });
7
+ it('should return nullSymbol for null', function () {
8
+ expect(formatNullableValue(null)).toBe(nullSymbol);
9
+ });
10
+ it('should return the value for non-nullable values', function () {
11
+ expect(formatNullableValue(42)).toBe(42);
12
+ expect(formatNullableValue(0)).toBe(0);
13
+ expect(formatNullableValue('test')).toBe('test');
14
+ expect(formatNullableValue('')).toBe('');
15
+ expect(formatNullableValue(true)).toBe(true);
16
+ expect(formatNullableValue(false)).toBe(false);
17
+ var obj = {
18
+ a: 1
19
+ };
20
+ expect(formatNullableValue(obj)).toBe(obj);
21
+ var arr = [1, 2, 3];
22
+ expect(formatNullableValue(arr)).toBe(arr);
23
+ });
24
+ });
25
+ // #sourceMappingURL=formatNullableValue.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nullSymbol","undefinedSymbol","formatNullableValue","describe","it","expect","undefined","toBe","obj","a","arr"],"sources":["formatNullableValue.test.ts"],"sourcesContent":["import {nullSymbol, undefinedSymbol} from '../../constants';\nimport {formatNullableValue} from '../formatNullableValue';\n\ndescribe('formatNullableValue', () => {\n it('should return undefinedSymbol for undefined', () => {\n expect(formatNullableValue(undefined)).toBe(undefinedSymbol);\n });\n\n it('should return nullSymbol for null', () => {\n expect(formatNullableValue(null)).toBe(nullSymbol);\n });\n\n it('should return the value for non-nullable values', () => {\n expect(formatNullableValue(42)).toBe(42);\n expect(formatNullableValue(0)).toBe(0);\n expect(formatNullableValue('test')).toBe('test');\n expect(formatNullableValue('')).toBe('');\n expect(formatNullableValue(true)).toBe(true);\n expect(formatNullableValue(false)).toBe(false);\n\n const ob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C,EAAE,CAAC,CAAC;IACrBL,MAAM,CAACH,mBAAmB,CAACQ,GAAG,CAAC,CAAC,CAACH,IAAI,CAACG,GAAG,CAAC;EAC9C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ import { getProgressiveRefetch } from '../getProgressiveRefetch';
2
+ describe('getProgressiveRefetch', function () {
3
+ it('should return a function', function () {
4
+ var refetchFn = getProgressiveRefetch({
5
+ minInterval: 1000,
6
+ maxInterval: 10000
7
+ });
8
+ expect(refetchFn).toEqual(expect.any(Function));
9
+ });
10
+ it('should return minInterval for the first call (count = 0)', function () {
11
+ var minInterval = 1000;
12
+ var maxInterval = 10000;
13
+ var refetchFn = getProgressiveRefetch({
14
+ minInterval: minInterval,
15
+ maxInterval: maxInterval
16
+ });
17
+ var result = refetchFn({}, 0);
18
+ expect(result).toBe(minInterval);
19
+ });
20
+ it('should increase interval by multiplier for each count', function () {
21
+ var minInterval = 1000;
22
+ var maxInterval = 10000;
23
+ var multiplier = 2;
24
+ var refetchFn = getProgressiveRefetch({
25
+ minInterval: minInterval,
26
+ maxInterval: maxInterval,
27
+ multiplier: multiplier
28
+ });
29
+ expect(refetchFn({}, 0)).toBe(1000);
30
+ expect(refetchFn({}, 1)).toBe(2000);
31
+ expect(refetchFn({}, 2)).toBe(4000);
32
+ expect(refetchFn({}, 3)).toBe(8000);
33
+ });
34
+ it('should not exceed maxInterval', function () {
35
+ var minInterval = 1000;
36
+ var maxInterval = 5000;
37
+ var multiplier = 2;
38
+ var refetchFn = getProgressiveRefetch({
39
+ minInterval: minInterval,
40
+ maxInterval: maxInterval,
41
+ multiplier: multiplier
42
+ });
43
+ expect(refetchFn({}, 0)).toBe(1000);
44
+ expect(refetchFn({}, 1)).toBe(2000);
45
+ expect(refetchFn({}, 2)).toBe(4000);
46
+ expect(refetchFn({}, 3)).toBe(5000);
47
+ expect(refetchFn({}, 4)).toBe(5000);
48
+ });
49
+ it('should use default multiplier (2) if not provided', function () {
50
+ var minInterval = 1000;
51
+ var maxInterval = 10000;
52
+ var refetchFn = getProgressiveRefetch({
53
+ minInterval: minInterval,
54
+ maxInterval: maxInterval
55
+ });
56
+ expect(refetchFn({}, 0)).toBe(1000);
57
+ expect(refetchFn({}, 1)).toBe(2000);
58
+ expect(refetchFn({}, 2)).toBe(4000);
59
+ });
60
+ it('should work with custom multiplier', function () {
61
+ var minInterval = 1000;
62
+ var maxInterval = 10000;
63
+ var multiplier = 1.5;
64
+ var refetchFn = getProgressiveRefetch({
65
+ minInterval: minInterval,
66
+ maxInterval: maxInterval,
67
+ multiplier: multiplier
68
+ });
69
+ expect(refetchFn({}, 0)).toBe(1000);
70
+ expect(refetchFn({}, 1)).toBe(1500);
71
+ expect(refetchFn({}, 2)).toBe(2250);
72
+ });
73
+ });
74
+ // #sourceMappingURL=getProgressiveRefetch.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getProgressiveRefetch","describe","it","refetchFn","minInterval","maxInterval","expect","toEqual","any","Function","result","toBe","multiplier"],"sources":["getProgressiveRefetch.test.ts"],"sourcesContent":["import type {Query} from '@tanstack/react-query';\n\nimport {getProgressiveRefetch} from '../getProgressiveRefetch';\n\ndescribe('getProgressiveRefetch', () => {\n it('should return a function', () => {\n const refetchFn = getProgressiveRefetch({\n minInterval: 1000,\n maxInterval: 10000,\n });\n\n expect(refetchFn).toEqual(expect.any(Function));\n });\n\n it('should return minInterval for the first call (count = 0)', () => {\n const minInterval = 1000;\n const maxInterval = 10000;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n });\n\n const result = refetchFn({} as Query, 0);\n\n expect(result).toBe(minInterval);\n });\n\n it('should increase interval by multiplier for each count', () => {\n const minInterval = 1000;\n const maxInterval = 10000;\n const multiplier = 2;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n multiplier,\n });\n\n expect(refetchFn({} as Query, 0)).toBe(1000);\n expect(refetchFn({} as Query, 1)).toBe(2000);\n expect(refetchFn({} as Query, 2)).toBe(4000);\n expect(refetchFn({} as Query, 3)).toBe(8000);\n });\n\n it('should not exceed maxInterval', () => {\n const minInterval = 1000;\n const maxInterval = 5000;\n const multiplier = 2;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n multiplier,\n });\n\n expect(refetchFn({} as Query, 0)).toBe(1000);\n expect(refetchFn({} as Query, 1)).toBe(2000);\n expect(refetchFn({} as Query, 2)).toBe(4000);\n expect(refetchFn({} as Query, 3)).toBe(5000);\n expect(refetchFn({} as Query, 4)).toBe(5000);\n });\n\n it('should use default multiplier (2) if not provided', () => {\n const minInterval = 1000;\n const maxInterval = 10000;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n });\n\n expect(refetchFn({} as Query, 0)).toBe(1000);\n expect(refetchFn({} as Query, 1)).toBe(2000);\n expect(refetchFn({} as Query, 2)).toBe(4000);\n });\n\n it('should work with custom multiplier', () => {\n const minInterval = 1000;\n const maxInterval = 10000;\n const multiplier = 1.5;\n const refetchFn = getProgressiveRefetch({\n minInterval,\n maxInterval,\n multiplier,\n });\n\n expect(refetchFn({} as Query, 0)).toBe(1000);\n expect(refetchFn({} as Query, 1)).toBe(1500);\n expect(refetchFn({} as Query, 2)).toBe(2250);\n });\n});\n"],"mappings":"AAEA,SAAQA,qBAAqB,QAAO,0BAA0B;AAE9DC,QAAQ,CAAC,uBAAuB,EAAE,YAAM;EACpCC,EAAE,CAAC,0BAA0B,EAAE,YAAM;IACjC,IAAMC,SAAS,GAAGH,qBAAqB,CAAC;MACpCI,WAAW,EAAE,IAAI;MACjBC,WAAW,EAAE;IACjB,CAAC,CAAC;IAEFC,MAAM,CAACH,SAAS,CAAC,CAACI,OAAO,CAACD,MAAM,CAACE,GAAG,CAACC,QAAQ,CAAC,CAAC;EACnD,CAAC,CAAC;EAEFP,EAAE,CAAC,0DAA0D,EAAE,YAAM;IACjE,IAAME,WAAW,GAAG,IAAI;IACxB,IAAMC,WAAW,GAAG,KAAK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XO,UAAU,EAAVA;IACJ,CAAC,CAAC;IAEFN,MAAM,CAACH,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACQ,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACH,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACQ,IAAI,CAAC,IAAI,CAAC;IAC5CL,MAAM,CAACH,SAAS,CAAC,CAAC,CAAC,EAAW,CAAC,CAAC,CAAC,CAACQ,IAAI,CAAC,IAAI,CAAC;EAChD,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ import { normalizeStatus } from '../normalizeStatus';
2
+ describe('normalizeStatus', function () {
3
+ it('should return loading when status is pending and fetchStatus is fetching', function () {
4
+ var status = 'pending';
5
+ var fetchStatus = 'fetching';
6
+ var result = normalizeStatus(status, fetchStatus);
7
+ expect(result).toBe('loading');
8
+ });
9
+ it('should return success when status is pending and fetchStatus is not fetching', function () {
10
+ var status = 'pending';
11
+ var fetchStatus = 'idle';
12
+ var result = normalizeStatus(status, fetchStatus);
13
+ expect(result).toBe('success');
14
+ });
15
+ it('should return success when status is success', function () {
16
+ var status = 'success';
17
+ var fetchStatus = 'idle';
18
+ var result = normalizeStatus(status, fetchStatus);
19
+ expect(result).toBe('success');
20
+ });
21
+ it('should return error when status is error', function () {
22
+ var status = 'error';
23
+ var fetchStatus = 'idle';
24
+ var result = normalizeStatus(status, fetchStatus);
25
+ expect(result).toBe('error');
26
+ });
27
+ });
28
+ // #sourceMappingURL=normalizeStatus.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalizeStatus","describe","it","status","fetchStatus","result","expect","toBe"],"sources":["normalizeStatus.test.ts"],"sourcesContent":["import type {FetchStatus, QueryStatus} from '@tanstack/react-query';\n\nimport {normalizeStatus} from '../normalizeStatus';\n\ndescribe('normalizeStatus', () => {\n it('should return loading when status is pending and fetchStatus is fetching', () => {\n const status: QueryStatus = 'pending';\n const fetchStatus: FetchStatus = 'fetching';\n\n const result = normalizeStatus(status, fetchStatus);\n\n expect(result).toBe('loading');\n });\n\n it('should return success when status is pending and fetchStatus is not fetching', () => {\n const status: QueryStatus = 'pending';\n const fetchStatus: FetchStatus = 'idle';\n\n const result = normalizeStatus(status, fetchStatus);\n\n expect(result).toBe('success');\n });\n\n it('should return success when status is success', () => {\n const status: QueryStatus = 'success';\n const fetchStatus: FetchStatus = 'idle';\n\n const result = normalizeStatus(status, fetchStatus);\n\n expect(result).toBe('success');\n });\n\n it('should return error when status is error', () => {\n const status: QueryStatus = 'error';\n const fetchStatus: FetchStatus = 'idle';\n\n const result = normalizeStatus(status, fetchStatus);\n\n expect(result).toBe('error');\n });\n});\n"],"mappings":"AAEA,SAAQA,eAAe,QAAO,oBAAoB;AAElDC,QAAQ,CAAC,iBAAiB,EAAE,YAAM;EAC9BC,EAAE,CAAC,0EAA0E,EAAE,YAAM;IACjF,IAAMC,MAAmB,GAAG,SAAS;IACrC,IAAMC,WAAwB,GAAG,UAAU;IAE3C,IAAMC,MAAM,GAAGL,eAAe,CAACG,MAAM,EAAEC,WAAW,CAAC;IAEnDE,MAAM,CAACD,MAAM,CAAC,CAACE,IAAI,CAAC,SAAS,CAAC;EAClC,CAAC,CAAC;EAEFL,EAAE,CAAC,8EAA8E,EAAE,YAAM;IACrF,IAAMC,MAAmB,GAAG,SAAS;IACrC,IAAMC,WAAwB,GAAG,MAAM;IAEvC,IAAMC,MAAM,GAAGL,eAAe,CAACG,MAAM,EAAEC,WAAW,CAAC;IAEnDE,MAAM,CAACD,MAAM,CAAC,CAACE,IAAI,CAAC,SAAS,CAAC;EAClC,CAAC,CAAC;EAEFL,EAAE,CAAC,8CAA8C,EAAE,YAAM;IACrD,IAAMC,MAAmB,GAAG,SAAS;IACrC,IAAMC,WAAwB,GAAG,MAAM;IAEvC,IAAMC,MAAM,GAAGL,eAAe,CAACG,MAAM,EAAEC,WAAW,CAAC;IAEnDE,MAAM,CAACD,MAAM,CAAC,CAACE,IAAI,CAAC,SAAS,CAAC;EAClC,CAAC,CAAC;EAEFL,EAAE,CAAC,0CAA0C,EAAE,YAAM;IACjD,IAAMC,MAAmB,GAAG,OAAO;IACnC,IAAMC,WAAwB,GAAG,MAAM;IAEvC,IAAMC,MAAM,GAAGL,eAAe,CAACG,MAAM,EAAEC,WAAW,CAAC;IAEnDE,MAAM,CAACD,MAAM,CAAC,CAACE,IAAI,CAAC,OAAO,CAAC;EAChC,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ import { notReachable } from '../notReachable';
2
+ describe('notReachable', function () {
3
+ it('should throw an error with default message', function () {
4
+ var callNotReachable = function callNotReachable() {
5
+ notReachable('test');
6
+ };
7
+ expect(callNotReachable).toThrow('Not reachable state: test');
8
+ });
9
+ it('should throw an error with custom message', function () {
10
+ var callNotReachable = function callNotReachable() {
11
+ notReachable('test', 'Custom error message');
12
+ };
13
+ expect(callNotReachable).toThrow('Custom error message');
14
+ });
15
+ it('should be used for exhaustive type checking', function () {
16
+ var getNumberName = function getNumberName(num) {
17
+ switch (num) {
18
+ case 1:
19
+ return 'one';
20
+ case 2:
21
+ return 'two';
22
+ case 3:
23
+ return 'three';
24
+ default:
25
+ return notReachable(num);
26
+ }
27
+ };
28
+ expect(getNumberName(1)).toBe('one');
29
+ expect(getNumberName(2)).toBe('two');
30
+ expect(getNumberName(3)).toBe('three');
31
+ });
32
+ });
33
+ // #sourceMappingURL=notReachable.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["notReachable","describe","it","callNotReachable","expect","toThrow","getNumberName","num","toBe"],"sources":["notReachable.test.ts"],"sourcesContent":["import {notReachable} from '../notReachable';\n\ndescribe('notReachable', () => {\n it('should throw an error with default message', () => {\n const callNotReachable = () => {\n notReachable('test' as never);\n };\n\n expect(callNotReachable).toThrow('Not reachable state: test');\n });\n\n it('should throw an error with custom message', () => {\n const callNotReachable = () => {\n notReachable('test' as never, 'Custom error message');\n };\n\n expect(callNotReachable).toThrow('Custom error message');\n });\n\n it('should be used for exhaustive type checking', () => {\n const getNumberName = (num: 1 | 2 | 3): string => {\n switch (num) {\n case 1:\n return 'one';\n case 2:\n return 'two';\n case 3:\n return 'three';\n default:\n return notReachable(num);\n }\n };\n\n expect(getNumberName(1)).toBe('one');\n expect(getNumberName(2)).toBe('two');\n expect(getNumberName(3)).toBe('three');\n });\n});\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,iBAAiB;AAE5CC,QAAQ,CAAC,cAAc,EAAE,YAAM;EAC3BC,EAAE,CAAC,4CAA4C,EAAE,YAAM;IACnD,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAA,EAAS;MAC3BH,YAAY,CAAC,MAAe,CAAC;IACjC,CAAC;IAEDI,MAAM,CAACD,gBAAgB,CAAC,CAACE,OAAO,CAAC,2BAA2B,CAAC;EACjE,CAAC,CAAC;EAEFH,EAAE,CAAC,2CAA2C,EAAE,YAAM;IAClD,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAA,EAAS;MAC3BH,YAAY,CAAC,MAAM,EAAW,sBAAsB,CAAC;IACzD,CAAC;IAEDI,MAAM,CAACD,gBAAgB,CAAC,CAACE,OAAO,CAAC,sBAAsB,CAAC;EAC5D,CAAC,CAAC;EAEFH,EAAE,CAAC,6CAA6C,EAAE,YAAM;IACpD,IAAMI,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,GAAc,EAAa;MAC9C,QAAQA,GAAG;QACP,KAAK,CAAC;UACF,OAAO,KAAK;QAChB,KAAK,CAAC;UACF,OAAO,KAAK;QAChB,KAAK,CAAC;UACF,OAAO,OAAO;QAClB;UACI,OAAOP,YAAY,CAACO,GAAG,CAAC;MAChC;IACJ,CAAC;IAEDH,MAAM,CAACE,aAAa,CAAC,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,KAAK,CAAC;IACpCJ,MAAM,CAACE,aAAa,CAAC,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,KAAK,CAAC;IACpCJ,MAAM,CAACE,aAAa,CAAC,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,OAAO,CAAC;EAC1C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import { nullSymbol, undefinedSymbol } from '../../constants';
2
+ import { parseNullableValue } from '../parseNullableValue';
3
+ describe('parseNullableValue', function () {
4
+ it('should return undefined for undefinedSymbol', function () {
5
+ expect(parseNullableValue(undefinedSymbol)).toBeUndefined();
6
+ });
7
+ it('should return null for nullSymbol', function () {
8
+ expect(parseNullableValue(nullSymbol)).toBeNull();
9
+ });
10
+ it('should return the value for non-symbol values', function () {
11
+ expect(parseNullableValue(42)).toBe(42);
12
+ expect(parseNullableValue(0)).toBe(0);
13
+ expect(parseNullableValue('test')).toBe('test');
14
+ expect(parseNullableValue('')).toBe('');
15
+ expect(parseNullableValue(true)).toBe(true);
16
+ expect(parseNullableValue(false)).toBe(false);
17
+ var obj = {
18
+ a: 1
19
+ };
20
+ expect(parseNullableValue(obj)).toBe(obj);
21
+ var arr = [1, 2, 3];
22
+ expect(parseNullableValue(arr)).toBe(arr);
23
+ });
24
+ });
25
+ // #sourceMappingURL=parseNullableValue.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nullSymbol","undefinedSymbol","parseNullableValue","describe","it","expect","toBeUndefined","toBeNull","toBe","obj","a","arr"],"sources":["parseNullableValue.test.ts"],"sourcesContent":["import {nullSymbol, undefinedSymbol} from '../../constants';\nimport {parseNullableValue} from '../parseNullableValue';\n\ndescribe('parseNullableValue', () => {\n it('should return undefined for undefinedSymbol', () => {\n expect(parseNullableValue(undefinedSymbol)).toBeUndefined();\n });\n\n it('should return null for nullSymbol', () => {\n expect(parseNullableValue(nullSymbol)).toBeNull();\n });\n\n it('should return the value for non-symbol values', () => {\n expect(parseNullableValue(42)).toBe(42);\n expect(parseNullableValue(0)).toBe(0);\n expect(parseNullableValue('test')).toBe('test');\n expect(parseNullableValue('')).toBe('');\n expect(parseNullableValue(true)).toBe(true);\n expect(parseNullableValue(false)).toBe(false);\n\n const obj = {a: 1};\n expect(parseNullableValue(obj)).toBe(obj);\n\n const arr = [1, 2, 3];\n expect(parseNullableValue(arr)).toBe(arr);\n });\n});\n"],"mappings":"AAAA,SAAQA,UAAU,EAAEC,eAAe,QAAO,iBAAiB;AAC3D,SAAQC,kBAAkB,QAAO,uBAAuB;AAExDC,QAAQ,CAAC,oBAAoB,EAAE,YAAM;EACjCC,EAAE,CAAC,6CAA6C,EAAE,YAAM;IACpDC,MAAM,CAACH,kBAAkB,CAACD,eAAe,CAAC,CAAC,CAACK,aAAa,CAAC,CAAC;EAC/D,CAAC,CAAC;EAEFF,EAAE,CAAC,mCAAmC,EAAE,YAAM;IAC1CC,MAAM,CAACH,kBAAkB,CAACF,UAAU,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;EACrD,CAAC,CAAC;EAEFH,EAAE,CAAC,+CAA+C,EAAE,YAAM;IACtDC,MAAM,CAACH,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAACM,IAAI,CAAC,EAAE,CAAC;IACvCH,MAAM,CAACH,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAACM,IAAI,CAAC,CAAC,CAAC;IACrCH,MAAM,CAACH,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAACM,IAAI,CAAC,MAAM,CAAC;IAC/CH,MAAM,CAACH,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAACM,IAAI,CAAC,EAAE,CAAC;IACvCH,MAAM,CAACH,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAACM,IAAI,CAAC,IAAI,CAAC;IAC3CH,MAAM,CAACH,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAACM,IAAI,CAAC,KAAK,CAAC;IAE7C,IAAMC,GAAG,GAAG;MAACC,CAAC,EAAE;IAAC,CAAC;IAClBL,MAAM,CAACH,kBAAkB,CAACO,GAAG,CAAC,CAAC,CAACD,IAAI,CAACC,GAAG,CAAC;IAEzC,IAAME,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACrBN,MAAM,CAACH,kBAAkB,CAACS,GAAG,CAAC,CAAC,CAACH,IAAI,CAACG,GAAG,CAAC;EAC7C,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { nullSymbol, undefinedSymbol } from '../constants';
2
+ export declare const formatNullableValue: <T>(value: T | undefined | null) => T | typeof undefinedSymbol | typeof nullSymbol;
@@ -0,0 +1,11 @@
1
+ import { nullSymbol, undefinedSymbol } from '../constants';
2
+ export var formatNullableValue = function formatNullableValue(value) {
3
+ if (value === undefined) {
4
+ return undefinedSymbol;
5
+ }
6
+ if (value === null) {
7
+ return nullSymbol;
8
+ }
9
+ return value;
10
+ };
11
+ // #sourceMappingURL=formatNullableValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nullSymbol","undefinedSymbol","formatNullableValue","value","undefined"],"sources":["formatNullableValue.ts"],"sourcesContent":["import {nullSymbol, undefinedSymbol} from '../constants';\n\nexport const formatNullableValue = <T>(\n value: T | undefined | null,\n): T | typeof undefinedSymbol | typeof nullSymbol => {\n if (value === undefined) {\n return undefinedSymbol;\n }\n\n if (value === null) {\n return nullSymbol;\n }\n\n return value;\n};\n"],"mappings":"AAAA,SAAQA,UAAU,EAAEC,eAAe,QAAO,cAAc;AAExD,OAAO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAC5BC,KAA2B,EACsB;EACjD,IAAIA,KAAK,KAAKC,SAAS,EAAE;IACrB,OAAOH,eAAe;EAC1B;EAEA,IAAIE,KAAK,KAAK,IAAI,EAAE;IAChB,OAAOH,UAAU;EACrB;EAEA,OAAOG,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import type { QueryKey } from '@tanstack/react-query';
1
+ import type { DefaultError, QueryKey } from '@tanstack/react-query';
2
2
  import type { RefetchIntervalFunction } from '../types/refetch-interval';
3
3
  export interface ProgressiveRefetchOptions {
4
4
  minInterval: number;
5
5
  maxInterval: number;
6
6
  multiplier?: number;
7
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>;
8
+ export declare const getProgressiveRefetch: <TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>({ minInterval, maxInterval, multiplier, }: ProgressiveRefetchOptions) => RefetchIntervalFunction<TQueryFnData, TError, TData, TQueryKey>;
@@ -0,0 +1,2 @@
1
+ import { nullSymbol, undefinedSymbol } from '../constants';
2
+ export declare const parseNullableValue: <T>(value: T | typeof undefinedSymbol | typeof nullSymbol) => T | undefined | null;
@@ -0,0 +1,11 @@
1
+ import { nullSymbol, undefinedSymbol } from '../constants';
2
+ export var parseNullableValue = function parseNullableValue(value) {
3
+ if (value === undefinedSymbol) {
4
+ return undefined;
5
+ }
6
+ if (value === nullSymbol) {
7
+ return null;
8
+ }
9
+ return value;
10
+ };
11
+ // #sourceMappingURL=parseNullableValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nullSymbol","undefinedSymbol","parseNullableValue","value","undefined"],"sources":["parseNullableValue.ts"],"sourcesContent":["import {nullSymbol, undefinedSymbol} from '../constants';\n\nexport const parseNullableValue = <T>(\n value: T | typeof undefinedSymbol | typeof nullSymbol,\n): T | undefined | null => {\n if (value === undefinedSymbol) {\n return undefined;\n }\n\n if (value === nullSymbol) {\n return null;\n }\n\n return value;\n};\n"],"mappings":"AAAA,SAAQA,UAAU,EAAEC,eAAe,QAAO,cAAc;AAExD,OAAO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAC3BC,KAAqD,EAC9B;EACvB,IAAIA,KAAK,KAAKF,eAAe,EAAE;IAC3B,OAAOG,SAAS;EACpB;EAEA,IAAID,KAAK,KAAKH,UAAU,EAAE;IACtB,OAAO,IAAI;EACf;EAEA,OAAOG,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ // #sourceMappingURL=setupTests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["setupTests.ts"],"sourcesContent":["import '@testing-library/jest-dom';\n"],"mappings":"AAAA,OAAO,2BAA2B","ignoreList":[]}